帖帖dotemacs更健康
;; zklhp's dotEmacs;; QQ 493165744 Email zklhp*At*
;; 参考了无数的配置 不过网上的配置也不全对 我的Emacs是24.0.92.1 平台是Windows XP
;; 亮点是中文用冬青黑体 也就是苹果的黑体 也就是Hiragino Sans GB 英文用Inconsolata 是混合字体 要使用这个配置要有这些字体 当然里面用的很多东西也得装啦
;; 冬青黑体不是等宽字体 对齐是个问题 所以用Inconsolata作为英文字体
;; 本人小菜一个 如果发现问题或者能解决已知问题的方法欢迎提出来 谢谢~
;; 下面的是系统生成的 但在这里设置 字体再打开就乱了 只能在下面设置了 不知道原因 是编码的问题?
(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.
'(TeX-DVI-via-PDFTeX t)
'(TeX-PDF-mode t)
'(TeX-engine (quote xetex))
'(ac-quick-help-delay 0.5)
'(bidi-paragraph-direction nil)
'(blink-cursor-mode nil)
'(c-basic-offset 4)
'(calculator-2s-complement t)
'(calculator-number-digits 16)
'(column-number-mode t)
'(compile-command "gcc -Wall")
'(display-battery-mode t)
'(display-time-24hr-format t)
'(display-time-mode t)
'(explicit-bash-args (quote ("--noediting" "--login" "-i")))
'(explicit-shell-file-name "E:\\MinGW\\msys\\1.0\\bin\\bash.exe")
'(fringe-mode (quote (nil . 0)) nil (fringe))
'(gdb-many-windows t)
'(global-hl-line-mode t)
'(global-hl-line-sticky-flag t)
'(global-semantic-idle-completions-mode t nil (semantic/idle))
'(global-semantic-idle-scheduler-mode t)
'(global-semanticdb-minor-mode t)
'(gud-tooltip-mode t)
'(help-at-pt-display-when-idle t nil (help-at-pt))
'(icomplete-mode t)
'(js-indent-level 8)
'(linum-delay t)
'(linum-eager nil)
'(no-redraw-on-reenter t)
'(org-export-html-footnote-format "<sup>[%s]</sup>")
'(org-export-html-toplevel-hlevel 1)
'(org-export-with-footnotes t)
'(org-footnote-section "Footnotes:")
'(org-footnote-tag-for-non-org-mode-files nil)
'(org-support-shift-select t)
'(preview-TeX-style-dir nil t)
'(preview-default-document-pt 15.0)
'(preview-fast-conversion nil)
'(preview-gs-options (quote ("-q" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4")))
'(preview-scale-function (quote preview-scale-from-face))
'(read-quoted-char-radix 16)
'(scroll-conservatively 0)
'(semantic-c-dependency-system-include-path (quote ("E:/MinGW/include")))
'(semantic-idle-work-parse-neighboring-files-flag t)
'(semantic-mode t)
'(semantic-stickyfunc-indent-string " ")
'(send-mail-function (quote smtpmail-send-it))
'(server-window (quote switch-to-buffer-other-frame))
'(sh-indentation 8)
'(shell-file-name "D:/emacs/bin/cmdproxy.exe")
'(show-paren-mode t)
'(size-indication-mode t)
'(smtpmail-smtp-server "smtp.)
'(smtpmail-smtp-service 25)
'(tab-always-indent nil)
'(text-scale-mode-step 1.05)
'(tool-bar-mode nil)
'(tooltip-hide-delay 3600)
'(uniquify-buffer-name-style (quote forward) nil (uniquify)))
(custom-set-faces
;; custom-set-faces 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.
'(default ((t (:inherit nil :stipple nil :background "gray91" :foreground "SystemWindowText" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight light :height 100 :width normal :foundry "outline"))))
'(font-lock-comment-face ((t (:foreground "#008000"))))
'(font-lock-keyword-face ((t (:foreground "Red" :weight bold))))
'(hl-line ((t (:background "white"))))
'(lazy-highlight ((((class color) (min-colors 88) (background light)) (:foreground "red" :weight bold))))
'(linum ((t (:inherit (shadow default) :weight bold :height 1.0 :width extra-expanded :family "Inconsolata"))))
'(org-footnote ((t (:foreground "Purple"))))
'(preview-face ((t nil)))
'(region ((t (:background "#C0C0C0"))))
'(show-paren-match ((((class color) (background light)) (:foreground "red" :weight bold)))))
;; 上面的都是用菜单配置的 配色效果可以看我传的图
;; 语法加亮
(global-font-lock-mode 1)
;; 最大语法高亮
(setq font-lock-maximum-decoration t)
;; 不知道具体什么效果 行号模式 前面两个没用
;; (setq column-number-mode t)
;; (setq line-number-mode t)
;; 这句才好用
(global-linum-mode 1)
;; (setq default-tab-width 4)
;; (set-default tab-width 4)
;; (setq c-basic-indent 4)
;; 设置TAB缩进习惯
;; (set-default indent-tabs-mode t)
;; (setq default-tab-width 4)
;; (setq tab-width 4)
;; (setq indent-tabs-mode t)
(setq tab-stop-list ())
(setq tab-stop-list (number-sequence tab-width 256 tab-width))
;; (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96))
;; 高亮显示区域选择
(transient-mark-mode 1)
;; 鼠标选择不复制
(setq mouse-drag-copy-region nil)
;; 不用这个功能
(define-prefix-command 'ctl-z-map)
(global-set-key (kbd "C-z") 'ctl-z-map)
(global-set-key "r" (lambda() (interactive) (when (buffer-file-name) (revert-buffer buffer-file-name t))))
(global-set-key "" (lambda() (interactive) (when (buffer-file-name) (revert-buffer buffer-file-name t))))
;; F12就是C-z的功能 考虑把C-z绑定到其他功能 但是还没想好
;; (global-set-key [f12] 'suspend-frame)
;; 不响
(setq visible-bell t)
;; 不闪
(setq ring-bell-function 'ignore)
;; 习惯使然 光标形状
(setq-default cursor-type 'bar)
;; 更快显示我按的命令 看的到才放心
(setq suggest-key-bindings 0.1)
;; 颜色
;; (set-background-color "gray91")
;; (set-face-background 'highlight "white")
;; (set-face-background 'region "#C0C0C0")
;; 高亮当前行
;; (require 'hl-line)
(hl-line-mode 1)
;; 禁止产生备份文件
(setq make-backup-files nil)
;; 始终在行尾
(setq track-eol t)
;; 显示buffer的名字
(setq frame-title-format "%b@Emacs")
;; 选择文字输入后自动替换 习惯啦
(delete-selection-mode 1)
;; (setq c-default-style
;; '((c-mode . "bsd") (other . "gnu")))
;; (setq c-basic-offset 4)
(require 'cedet)
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "bsd")
(c-toggle-hungry-state)
(c-toggle-auto-state)
(c-toggle-auto-newline)
;; (load-file "~/lisp/cedet.el")
(require 'cedet)
(require 'eassist)
;; (require 'semantic-c)
(require 'semantic-gcc)
(require 'semanticdb)
(require 'semantic-decorate-include)
(require 'semantic-ia)
(require 'semantic-lex-spp)
(require 'semantic-analyze-complete)
(require 'semantic-analyze-refs)
(require 'semantic-decorate-include)
(when (not (member system-type '(gnu gnu/linux darwin cygwin)))
(if (executable-find "gcc")
(semantic-gcc-setup)
(message "GCC is not installed and semantic analysis will be restriced.")))
(setq pulse-flag 'never)
(setq semanticdb-default-save-directory
(expand-file-name "~/.emacs.d/semanticdb"))
(require 'semantic-c nil 'noerror)
(eval-after-load "semantic-c" ;;e:/emacs/home 是我的 $HOME
'(dolist (d (list "E:/MinGW/include"
;; "/usr/include/c++/4.1.0/x86_64-suse-linux"
;; "/usr/include/c++/4.1.0/backward"
;; "/usr/local/include"
;; "/usr/lib64/gcc/x86_64-suse-linux/4.1.0/include"
;; "/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/include"
;; "/usr/include"
))
(semantic-add-system-include d)
))
(setq semantic-c-dependency-system-include-path "E:/MinGW/include")
(setq-mode-local c-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
;; (semantic-add-system-include "E:/MinGW/include" 'c-mode)
;; (add-to-list 'semantic-lex-c-preprocessor-symbol-file "E:/MinGW/include/stdio.h")
;; (semantic-add-system-include "E:/Program Files/VC2008/include" 'c-mode)
;; (semantic-add-system-include "E:/Program Files/VC2008/atlmfc/include" 'c-mode)
;; (semantic-load-enable-minimum-features)
(semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-semantic-debugging-helpers)
;; (global-ede-mode 1) ;; Enable the Project management system
;; (global-srecode-minor-mode 1) ;; Enable template insertion menu
(global-semantic-tag-folding-mode 1) ;; Enable semantic code folding
(defvar semantic-tags-location-ring (make-ring 64))
;; (global-ede-mode 1)
(setq ac-sources (append '(ac-source-semantic) ac-sources))
))
(add-hook 'c++-mode-hook
'(lambda ()
(c-set-style "bsd")
(c-toggle-hungry-state)
(c-toggle-auto-state)
(c-toggle-auto-newline)
(load-file "~/lisp/cedet.el")
(semantic-mode 1)
(global-ede-mode 1)
(require 'semantic-c nil 'noerror)
(semantic-add-system-include "E/MinGW/lib/gcc/mingw32/4.7.0/include" 'c++-mode)
(setq-mode-local c++-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
;; (semantic-add-system-include "E:/Program Files/VC2008/include" 'c-mode)
;; (semantic-add-system-include "E:/Program Files/VC2008/atlmfc/include" 'c-mode)
(setq ac-sources (append '(ac-source-semantic) ac-sources))
))
;; 一个ESC是C-g
;; (if (Alt-works-as-meta?) ;; don't map if console has broken Alt key
;; (progn
(global-set-key [escape] 'keyboard-quit) ;; all platforms?
;; (setq w32-quit-key 27) ;; needed in MicroSCOft cages?
;; ))
;; Rect-mark 区块选择 抄的
;; Support for marking a rectangle of text with highlighting.
;; (load-file "~/site-lisp/rect-mark.el")
(define-key ctl-x-map "r\C-@" 'rm-set-mark)
(define-key ctl-x-map [?\r ?\C-\ ] 'rm-set-mark)
(define-key ctl-x-map "r\C-x" 'rm-exchange-point-and-mark)
(define-key ctl-x-map "r\C-w" 'rm-kill-region)
(define-key ctl-x-map "r\M-w" 'rm-kill-ring-save)
;; 改成 M-左键 是区域选择 貌似win里这个叫区块操作
;; (global-set-key [M-drag-mouse-1] nil)
(define-key global-map [M-drag-mouse-1] 'rm-mouse-drag-region)
(define-key global-map [M-down-mouse-1] 'rm-mouse-drag-region)
(autoload 'rm-set-mark "rect-mark"
"Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
"Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
"Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
"Copy a rectangular region to the kill ring." t)
(autoload 'rm-mouse-drag-region "rect-mark"
"Drag out a rectangular region with the mouse." t)
(global-set-key [(C-down-mouse-1)] (quote mouse-set-secondary))
(global-set-key [(C-drag-mouse-1)] (quote mouse-set-secondary))
(global-set-key [C-wheel-down] 'text-scale-decrease)
(global-set-key [C-wheel-up] 'text-scale-increase)
;; 加一个Shift+空格作为设定标记
(global-set-key (kbd "S-SPC") (quote set-mark-command))
;; 自动对一行操作 抄的
;; Smart copy, if no region active, it simply copy the current whole line
;; (ad-unadvise 'kill-line)
(defadvice kill-line (before check-position activate)
(if (member major-mode
'(emacs-lisp-mode scheme-mode lisp-mode
c-mode c++-mode objc-mode js-mode
latex-mode plain-tex-mode))
(if (and (eolp) (not (bolp)))
(progn (forward-char 1)
(just-one-space 0)
(backward-char 1)))))
;; (ad-unadvise 'kill-ring-save)
(defadvice kill-ring-save (before slick-copy activate compile)
"When called interactively with no active region, copy a single line instead."
(interactive (if mark-active (list (region-beginning) (region-end))
(message "Copied line")
(list (line-beginning-position)
(line-beginning-position 2)))))
;; (ad-unadvise 'kill-region)
(defadvice kill-region (before slick-cut activate compile)
"When called interactively with no active region, kill a single line instead."
(interactive (if mark-active (list (region-beginning) (region-end))
(message "Cut line")
(list (line-beginning-position)
(line-beginning-position 2)))))
;; auto-complete的配置
;; !!!请根据情况写!!!
(add-to-list 'load-path "~/site-lisp/auto-complete")
(require 'auto-complete-config)
;; !!!请根据情况写!!!
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/site-lisp/auto-complete/ac-dict")
;; 两个字母开始
(setq ac-auto-start 2)
;; 10行
(setq ac-menu-height 10)
;; 根据文档能防止乱(?) 貌似不管用
;; (setq popup-use-optimized-column-computation nil)
;; 改了这个auto-complete就不会乱了 撒花。。
(set-face-font 'ac-candidate-face "Inconsolata")
(set-face-font 'ac-selection-face "Inconsolata")
;; 下面是我用auto-complete实现的一个字典补全 第一次比较慢 不过优点是可以比较方便的自定义
;; 放在配置里还不错 但单独弄我就没这个水平了 呵呵
(require 'auto-complete)
(defun ac-english-candidates ()
(apply 'append
(mapcar 'ac-read-file-dictionary '("~/site-lisp/auto-complete/ac-dict/englishwords/web2"
;; "~/site-lisp/auto-complete/ac-dict/englishwords/web2a"
"~/site-lisp/auto-complete/ac-dict/englishwords/dict"))))
(ac-define-source english-words
'((candidates . ac-english-candidates)
(cache . t)
(symbol . "D")
))
;; 撒花 根据词典补全英语
(global-set-key (kbd "C-M-/") 'ac-complete-english-words)
;; 特定模式补全
;; (add-to-list 'ac-modes 'text-mode)
;; (add-to-list 'ac-modes 'org-mode)
;; 拼写检查
;; !!请根据实际目录填!!!
;; (add-to-list 'exec-path "D:/Aspell/bin")
;; (setq ispell-process-directory "D:/Aspell/bin")
(setq ispell-program-name "aspell")
(setq ispell-local-dictionary "american")
;; (setq-default ispell-dictionary "D:\\Aspell")
;; (setq-default ispell-local-dictionary "american")
;; (setq ispell-local-dictionary "D:\\Aspell\\dict\\en-only.rws")
;; 这个感觉能装满1280X800的屏幕了
(setq initial-frame-alist '((top . 0) (left . 0) (width . 1280) (height . 768)))
;; 纠正org-mode的换号问题
(add-hook 'org-mode-hook
(lambda ()(setq truncate-lines nil)))
;; 语法缩进线
;; (require 'aux-line)
;; (indent-vline-fixed)
(add-to-list 'load-path
"~/site-lisp/site-start.d")
;; (load "AucTeX.el" nil t t)
;; (load "preview-latex.el" nil t t)
;; (set-default preview-image-type 'png)
(if (string-equal system-type "windows-nt")
(require 'tex-mik))
(mapc (lambda (mode)
(add-hook 'LaTeX-mode-hook mode))
(list 'auto-fill-mode
'LaTeX-math-mode
'turn-on-reftex))
;; 'linum-mode))
;; 不立即刷新试试
;; (setq redisplay-dont-pause nil)
;; 屏保 不好用
;; (require 'zone)
;; (require 'zone-settings)
;; (add-to-list 'load-path "~/site-lisp/emacs-w3m")
;; (autoload 'w3m "w3m" "Interface for w3m on Emacs." t)
;; (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; (autoload 'w3m-search "w3m-search" "Search words using emacs-w3m." t)
;; (setq w3m-use-favicon nil)
;; (setq w3m-command-arguments '("-cookie" "-F"))
;; (setq w3m-use-cookies t)
;; (setq w3m-home-page "http://www.baidu.com")
;; 不好用
;; (require 'w3m)
;; (require 'w3m-lnum)
;; (setq w3m-default-display-inline-image t)
;; 中文字体 不需要这样了
;; (set-fontset-font "fontset-default" 'han '("Hiragino Sans GB" . "unicode-bmp"))
;; (set-fontset-font "fontset-default" 'unicode '("Hiragino Sans GB" . "unicode-bmp"))
;; 貌似会被后面的那个覆盖
;; (set-frame-font "Hiragino Sans GB 13")
;; 来自一个普雷斯顿网站上找到的网页的配置。。
;; Setting English Font
(set-face-attribute
'default nil :font "Inconsolata 10") ;DejaVu Sans Inconsolata 还是现在用的好看
;; Chinese Font
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "冬青黑体简体中文 W3")))
;; 行距为0
(setq line-spacing 0)
;; 这样设置就好了 不错。。
;; 而且解决了新建窗口乱码的问题 我发现这样写就好了 C-x 5 2 不乱码了
;; (setq default-frame-alist
;; (append
;; '((font . "Hiragino Sans GB 10")) default-frame-alist))
;; (defun w32-restore-frame ()
;; "Restore a minimized frame"
;; (interactive)
;; (w32-send-sys-command 61728))
;; 大log文件支持
(require 'biglogviewer)
(electric-pair-mode 1)
(load "~/.kmacros")
;; (fset 'del-at-end
;; "\C-e\C-d\C-e")
;; (put 'del-at-end 'kmacro t)
(defun make-a-long-sentence ()
"make a long sentence"
(interactive)
(let (str pt)
(end-of-line)
(delete-char 1)
(backward-char)
(setq str (buffer-substring (setq pt (point)) (1+ pt)))
(if (not (string-equal str " "))
(progn
(forward-char)
(insert " ")
)
)
)
)
(global-set-key [67108923] (quote make-a-long-sentence))
(defun dwim-make-a-long-sentence ()
"make a long sentence"
(interactive)
(end-of-line)
(delete-char 1)
)
(global-set-key [201326651] (quote dwim-make-a-long-sentence))
(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 gdb-disassembly-mode-map [(f7)] 'gud-stepi)
(define-key gdb-disassembly-mode-map [(f8)] 'gud-nexti)
(define-key c-mode-base-map [(f9)] 'gud-go)
(define-key c-mode-base-map [(f2)] 'gud-tbreak)
;; (gdb-display-disassembly-buffer)
))
;; use bash as shell
(defun my-shell-setup ()
"For bash"
(setq comint-scroll-show-maximum-output 'this)
(make-variable-buffer-local 'comint-completion-addsuffix))
(setq comint-completion-addsuffix t)
;; (setq comint-process-echoes t) ;; reported that this is no longer needed
;; (setq comint-eol-on-send t)
(setq w32-quote-process-args ?\")
(setq shell-mode-hook 'my-shell-setup)
;; use ibuffer
(defalias 'list-buffers 'ibuffer)
(defun byte-compile-current-buffer ()
"`byte-compile' current buffer if it's emacs-lisp-mode and compiled file exists."
(interactive)
(when (and (eq major-mode 'emacs-lisp-mode)
(file-exists-p (byte-compile-dest-file buffer-file-name)))
(byte-compile-file buffer-file-name)))
(add-hook 'after-save-hook 'byte-compile-current-buffer)
(add-hook 'dired-load-hook
(lambda ()
(load "dired-x")
(load "dired-aux")
;; Set global variables here. For example:
;; (setq dired-guess-shell-gnutar "gtar")
))
(add-hook 'dired-mode-hook
(lambda ()
;; Set buffer-local variables here. For example:
;; (dired-omit-mode 1)
))
;; use dired+
;; (require 'dired+)
(defun open-in-external-app ()
"Open the current file or dired marked files in external app.
Works in Microsoft Windows, Mac OS X, Linux."
(interactive)
(let ( doIt
(myFileList
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
(t (list (buffer-file-name))) ) ) )
(setq doIt (if (<= (length myFileList) 5)
t
(y-or-n-p "Open more than 5 files?") ) )
(when doIt
(cond
((string-equal system-type "windows-nt")
(mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList)
)
((string-equal system-type "darwin")
(mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "open" fPath)) ) myFileList) )
((string-equal system-type "gnu/linux")
(mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList)) ) ) ) )
;; 不用C-h了
(define-key global-map "\C-h" 'backward-delete-char)
;; 启动最大化
(defun w32-maximize-frame (&optional arg)
"Maximize the current frame"
(interactive)
;; (set-frame-width (selected-frame) 1280)
(set-frame-height (selected-frame) 768)
(w32-send-sys-command #xf030 arg)
)
;; Emacs是个操作系统 应该是服务模式好~
(server-mode 1)
(w32-maximize-frame)
;; (add-hook 'after-make-frame-functions 'w32-maximize-frame)
;; (add-hook 'window-setup-hook 'w32-maximize-frame)
(add-hook 'after-make-frame-functions 'w32-maximize-frame)