原地址:点击打开链接
;;使用C-x C-e检测配置的正确性
(global-linum-mode t);显示行号
(setq column-number-mode t);显示列号
(setq auto-image-file-mode t);让Emacs可以直接打开和显示图片
(auto-compression-mode t);打开压缩文件时自动解压缩
;(setq global-font-lock-mode t);进行语法加亮
(setq x-select-enable-clipboard t);允许emacs和外部其他程序的粘贴
(setq mouse-yank-at-point t);使用鼠标中键可以粘贴
(set-scroll-bar-mode nil);;取消滚动栏
(tool-bar-mode nil);取消工具栏
;;;;;;;;;;;;;;;;;;;;;;;;;;;; 显示时间设置 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(display-time-mode 1);;启用时间显示设置,在minibuffer上面的那个杠上
(setq display-time-24hr-format t);;时间使用24小时制
(setq display-time-day-and-date t);;时间显示包括日期和具体时间
(setq display-time-use-mail-icon t);;时间栏旁边启用邮件设置
(setq display-time-interval 10);;时间的变化频率,单位多少来着?
;;;;;;;;;;;;;;;;;;;;;;;;;;; 显示时间设置结束 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq visible-bell t)
;;关闭烦人的出错时的提示声
(setq inhibit-startup-message t)
;;关闭emacs启动时的画面
;(setq font-lock-maximum-decoration t)
;(setq font-lock-global-modes '(not shell-mode text-mode))
;(setq font-lock-verbose t)
;(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。
(fset 'yes-or-no-p 'y-or-n-p)
;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no。
(ansi-color-for-comint-mode-on)
;真正shell-mode乱码解决。
(setq default-fill-column 80)
;默认显示 80列就换行
(setq default-fill-column 120)
;;把 fill-column 设为 60. 这样的文字更好读
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;设置缺省主模式是text,,并进入auto-fill次模式.而不是基本模式fundamental-mode
(show-paren-mode t);显示括号匹配
(setq show-paren-style 'parenthesis)
;;括号匹配时可以高亮显示另外一边的括号,但光标不会烦人的跳到另一个括号处。
(mouse-avoidance-mode 'animate)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。
;;;;;;;disable tip of the day
(setq ecb-tip-of-the-day nil)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-stop-list ())
;;不用 TAB 字符来indent, 这会引起很多奇怪的错误。编辑 Makefile 的时候也不用担心,因为 makefile-mode 会把 TAB 键设置成真正的 TAB 字符,并且加亮显示的。
(setq-default make-backup-files nil);不要生成临时文件
(setq backup-directory-alist '(("." . "~/.autosave")))
;;设置自动备份文件保存的目录,以免把你的磁盘弄得乱七八糟(你可以
;;去掉这一行试试看:P ~/.autosave 表示 主目录下的一个叫.autosave 的子目录,
;;按照前面的方法设置主目录。
;;最大化
(defun my-maximized ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(my-maximized)
;;自动插入匹配的括号
;;C/C++ mode
(defun my-c-mode-auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
;; (?' _ "'")
(?\" _ "\"")
(?\( _ ")")
(?\[ _ "]")
(?{ \n > _ \n ?} >)))
(setq skeleton-pair t)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
;; (local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
;;输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
;;;;自动补齐
(defun my-indent-or-complete ();;;;如果在单词中间就补齐,否则就是tab
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command))
)
(global-set-key [(control tab)] 'my-indent-or-complete)
;;;hippie的自动补齐策略,优先调用了senator的分析结果:
(autoload 'senator-try-expand-semantic "senator")
(setq hippie-expand-try-functions-list
'(
senator-try-expand-semantic
try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-expand-list
try-expand-list-all-buffers
try-expand-line
try-expand-line-all-buffers
try-complete-file-name-partially
try-complete-file-name
try-expand-whole-kill
)
)
;;;; 当输入"."或">"时,在另一个窗口中列出结构体或类的成员
;; (defun my-c-mode-cedet-hook ()
;; (local-set-key "." 'semantic-complete-self-insert)
;; (local-set-key ">" 'semantic-complete-self-insert))
;; (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
;; (add-hook 'c++-mode-commom-hook 'my-c-mode-cedet-hook)
;;配置CEDET
(load-file "~/.emacs.d/my_plus/cedet-1.0/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
(global-ede-mode t)
(require 'semantic-ia)
(require 'semantic-gcc)
(global-srecode-minor-mode 1)
(semantic-load-enable-semantic-debugging-helpers)
(global-set-key [f12] 'semantic-ia-fast-jump);代码跳转
;;
(global-set-key [S-f12]
(lambda ()
(interactive)
(if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
(error "Semantic Bookmark ring is currently empty"))
(let* ((ring (oref semantic-mru-bookmark-ring ring))
(alist (semantic-mrub-ring-to-assoc-list ring))
(first (cdr (car alist))))
(if (semantic-equivalent-tag-p (oref first tag)
(semantic-current-tag))
(setq first (cdr (car (cdr alist)))))
(semantic-mrub-switch-tags first))))
;;代码跳转(跳回上次的位置)
(require 'eassist nil 'noerror)
(add-hook 'c-mode-common-hook
(lambda ()
(define-key c-mode-base-map [M-f12] 'eassist-switch-h-cpp)
));;;;;eassist.el就提供了一个在C++的头文件和实现文件间跳转
(setq eassist-header-switches
'(("h" . ("cpp" "cxx" "c++" "CC" "cc" "C" "c" "mm" "m"))
("hh" . ("cc" "CC" "cpp" "cxx" "c++" "C"))
("hpp" . ("cpp" "cxx" "c++" "cc" "CC" "C"))
("hxx" . ("cxx" "cpp" "c++" "cc" "CC" "C"))
("h++" . ("c++" "cpp" "cxx" "cc" "CC" "C"))
("H" . ("C" "CC" "cc" "cpp" "cxx" "c++" "mm" "m"))
("HH" . ("CC" "cc" "C" "cpp" "cxx" "c++"))
("cpp" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
("cxx" . ("hxx" "hpp" "h++" "HH" "hh" "H" "h"))
("c++" . ("h++" "hpp" "hxx" "HH" "hh" "H" "h"))
("CC" . ("HH" "hh" "hpp" "hxx" "h++" "H" "h"))
("cc" . ("hh" "HH" "hpp" "hxx" "h++" "H" "h"))
("C" . ("hpp" "hxx" "h++" "HH" "hh" "H" "h"))
("c" . ("h"))
("m" . ("h"))
("mm" . ("h"))));;;;填补eassist-switch-h-cpp扩展名不全的BUG
;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;(defun my-c-mode-common-hook()
(add-hook 'c-mode-common-hook
(lambda ()
;(define-key c-mode-base-map [M-S-f12] 'semantic-analyze-proto-impl-toggle);;;;;在函数和声明和实现间跳转,不是这个功能不是十分准确,一般在cpp中函数实现处想跳到函数声明处正常,但是从声明处跳到实现处的话cedet不一定能找到cpp文件的位置。
(define-key c-mode-base-map (kbd "M-n") 'semantic-ia-complete-symbol-menu);;;;;;代码补全
))
;;;;;;;;;;;;;;配置ecb
(add-to-list 'load-path "~/.emacs.d/my_plus/ecb-2.40")
(require 'ecb)
(ecb-activate)
;;定制ecb窗口布局
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ecb-fix-window-size t)
'(ecb-layout-window-sizes nil)
'(ecb-options-version "2.40")
;; '(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
'(ecb-windows-width 0.18))
;颜色配置
(add-to-list 'load-path "~/.emacs.d/my_plus")
(require 'color-theme)
(color-theme-initialize)
(color-theme-calm-forest)
(global-set-key [f1] 'shell) ; 进入shell
(global-set-key [S-f9] 'gdb) ; 调试
;(setq compile-command "g++ ") ; 编译
(global-set-key [f9] 'compile)
;; c-mode公共设置
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(defun my-c-mode-common-hook ()
(setq default-tab-width 4)
(setq tab-width 4)
(setq c-basic-offset 4)
(hs-minor-mode t)
(define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
(define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
;;;最后两行是代码自动补齐的快捷键
)
(global-set-key [S-f10] 'comment-or-uncomment-region) ; 注释 / 取消注释
(global-set-key [f10] 'c-indent-line-or-region) ; 格式化代码
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
;; (x-send-client-message
;; nil 0 nil "_NET_WM_STATE" 32
;; '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
)
;; (my-fullscreen)
(global-set-key [f11] 'my-fullscreen) ; emacs全屏
;gdb快捷键设置
(add-hook 'gdb-mode-hook '(lambda ()
(define-key c-mode-base-map [(f5)] 'gud-go)
(define-key c-mode-base-map [(f7)] 'gud-step)
(define-key c-mode-base-map [(f8)] 'gud-next)
(define-key c-mode-base-map [(f6)] 'gud-cont)))
;;代码折叠
(global-set-key [f2] 'hs-toggle-hiding)
;;;auctex配置
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(add-hook 'LaTeX-mode-hook #'LaTeX-install-toolbar)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook (lambda()
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")
(setq TeX-save-query nil )
(setq TeX-show-compilation t)
))
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-engine 'xetex)
(setq TeX-PDF-mode t)
;;;;;;;;;;;;weibo;;;;;;;;;;
;;;;;;使用M-x weibo-timeline
(add-to-list 'load-path "~/.emacs.d/my_plus/austin------weibo.emacs-0cf9784")
(require 'weibo)
;;;;;;保存上次emacs关闭时的状态
(load "desktop")
(desktop-load-default)
(desktop-read)
;;当emacs退出时保存文件打开状态
(add-hook 'kill-emacs-hook
'(lambda()(desktop-save "~/")))
;;;;;;;;;;;;;;;;w3m设置;;;;;;;;;;;;;;;;;
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/w3m/")
;; (require 'w3m)
;; (setq w3m-home-page "http://www.google.com.hk") ;设置主页
;; (require 'mime-w3m)
;; ;设置显示图片
;; (setq w3m-default-display-inline-images t)
;; (setq w3m-default-toggle-inline-images t)
;; ;;显示图标
;; (setq w3m-show-graphic-icons-in-header-line t)
;; (setq w3m-show-graphic-icons-in-mode-line t)
;; ;;启用cookie
;; (setq w3m-use-cookies t)
;; ;;设定w3m运行的参数,分别为使用cookie和使用框架
;; (setq w3m-command-arguments '("-cookie" "-F"))
;; ;;;解决wrong type argument: stringp, nil问题
;; (setq debug-on-error t);;