emacs 配置文件
来源:互联网 发布:mac mysql安装教程 编辑:程序博客网 时间:2024/05/21 21:01
最近又捡起了 emacs。由于前段时间学过一段 Lisp/Scheme,发现配置和运用要得心应手得多,只是一些 VIM 下的习惯经常出来捣乱。在此贴一下配置文件吧,都是到处抄来的,以后慢慢增补。
-------配置文件--------
Windows 下需要在注册表中设定 emacs 启动时载入配置文件的 HOME 目录,下面是注册表文件
-------配置文件--------
- ;;; The running on system stuff.
- (defvar running-on-windows (memq system-type '(windows-nt cygwin)))
- (defvar running-on-linux (not running-on-windows))
- (defvar running-on-x (eq window-system 'x))
- ;;;
- (setq visible-bell t)
- ;;;
- (fset 'yes-or-no-p 'y-or-n-p)
- ;;; Lose the menu bar
- ;;(if (fboundp 'menu-bar-mode) (menu-bar-mode nil))
- ;;; Lose the toolbar
- (tool-bar-mode nil)
- ;;; Lose the scroll bar
- (set-scroll-bar-mode nil)
- ;;(customize-set-variable 'scroll-bar-mode 'right)
- (set-cursor-color "steelblue")
- (set-mouse-color "steelblue")
- ;;; Time
- (setq display-time-day-and-date t)
- (display-time)
- ;;
- (display-time-mode 1)
- (setq display-time-24hr-format t)
- (setq display-time-day-and-date t)
- (setq display-time-use-mail-icon t)
- (setq display-time-interval 10)
- ;;Emacs@Windows maximum
- ;;(w32-send-sys-command #xf030)
- ;;; Window size for starting up
- (setq default-frame-alist
- '((height . 35) (width . 100)))
- ;;; Disable startup screen
- (custom-set-variables
- '(inhibit-startup-screen t))
- (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.
- )
- ;;; Useful key strokes
- ;;; goto-line --> ctrl+g
- (global-set-key "/C-c/C-g" 'goto-line)
- (global-set-key "/C-cb" 'whitespace-cleanup)
- (global-set-key "/M-?" 'help-command)
- ;;;
- (setq backup-directory-alist '(("" . "D:/GS/emacs_msw/backup")))
- (setq make-backup-files nil)
- (setq-default make-backup-files nil)
- (auto-compression-mode 1)
- ;;; Show trailing whitespace
- (setq-default show-trailing-whitespace t)
- ;;;
- (setq require-final-newline t)
- ;;;
- (setq mouse-yank-at-point t)
- (setq x-select-enable-clipboard t)
- ;;;
- (setq column-number-mode t)
- ;;
- (add-to-list 'load-path "D:/GS/emacs_msw/myemacs")
- (require 'linum)
- (global-linum-mode 1)
- (require 'xcscope)
- ;;
- (cond
- (running-on-windows
- (require 'color-theme)
- (require 'color-theme-tango)
- (color-theme-tango))
- (running-on-x
- (require 'color-theme)
- (color-theme-gnome2))
- )
- (setq-default indent-tabs-mode nil)
- ;;(setq standard-indent 4)
- ;;(setq tab-stop-list ())
- (global-set-key (kbd "TAB") 'self-insert-command)
- (global-set-key (kbd "TAB") 'tab-to-tab-stop)
- (setq-default tab-width 4)
- (setq-default
- tab-stop-list
- (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 100 104 108))
- (setq show-paren-mode t) ;;打开括号匹配显示模式
- (setq show-paren-style 'parenthesis)
- (setq auto-image-file-mode t)
- (setq w32-charset-info-alist
- (cons '("gbk" w32-charset-gb2312 . 936) w32-charset-info-alist))
- (setq default-frame-alist
- (append
- '((font . "fontset-gbk")) default-frame-alist))
- (create-fontset-from-fontset-spec
- "-outline-Courier New-normal-r-normal-normal-16-97-96-96-c-*-fontset-gbk")
- (set-fontset-font
- "fontset-default" nil
- "-outline-新宋体-normal-r-normal-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
- (set-fontset-font
- "fontset-gbk" 'kana
- "-outline-新宋体-normal-r-normal-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
- (set-fontset-font
- "fontset-gbk" 'han
- "-outline-新宋体-normal-r-normal-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
- (set-fontset-font
- "fontset-gbk" 'cjk-misc
- "-outline-新宋体-normal-r-normal-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
- (set-fontset-font
- "fontset-gbk" 'symbol
- "-outline-新宋体-normal-r-normal-*-16-*-96-96-c-*-iso10646-1" nil 'prepend)
- (set-default-font "fontset-gbk")
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; mode
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (add-hook 'c++-mode-hook
- (lambda ()
- (c-set-style "bsd")
- (hs-minor-mode)
- (local-set-key "/C-c/t" 'complete-symbol)
- (local-set-key "/C-m" 'newline-and-indent)
- (setq mslk-c++-key (make-keymap))
- (local-set-key "/C-j" mslk-c++-key)
- (define-key mslk-c++-key "/C-j" 'complete-symbol)
- (define-key mslk-c++-key "/C-o" 'hs-hide-all)
- (define-key mslk-c++-key "/C-p" 'hs-show-all)
- (define-key mslk-c++-key "/C-h" 'hs-hide-block)
- (define-key mslk-c++-key "/C-u" 'hs-show-block)
- (define-key mslk-c++-key "/C-l" 'hs-hide-level)
- (define-key mslk-c++-key "/C-m" 'hs-toggle-hiding)
- ))
- (add-hook 'c-mode-hook 'c++-mode)
- (defun my-c-mode-common-hook()
- (setq tab-width 4 indent-tabs-mode nil)
- ;;; hungry-delete and auto-newline
- (c-toggle-auto-hungry-state 1)
- ;;按键定义
- (define-key c-mode-base-map [(control /`)] 'hs-toggle-hiding)
- (define-key c-mode-base-map [(return)] 'newline-and-indent)
- (define-key c-mode-base-map [(f7)] 'compile)
- (define-key c-mode-base-map [(meta /`)] 'c-indent-command)
- ;; (define-key c-mode-base-map [(tab)] 'hippie-expand)
- (define-key c-mode-base-map [(tab)] 'my-indent-or-complete)
- (define-key c-mode-base-map [(meta ?/)] 'semantic-ia-complete-symbol-menu)
- ;;预处理设置
- (setq c-macro-shrink-window-flag t)
- (setq c-macro-preprocessor "cpp")
- (setq c-macro-cppflags " ")
- (setq c-macro-prompt-flag t)
- (setq hs-minor-mode t)
- (setq abbrev-mode t)
- )
- (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
- ;;;;我的C++语言编辑策略
- (defun my-c++-mode-hook()
- (setq tab-width 4 indent-tabs-mode nil)
- (c-set-style "stroustrup")
- ;; (define-key c++-mode-map [f3] 'replace-regexp)
- )
- (defun my-indent-or-complete ()
- (interactive)
- (if (looking-at "//>")
- (hippie-expand nil)
- (indent-for-tab-command))
- )
- (global-set-key [(control tab)] 'my-indent-or-complete)
- (setq compile-command "make")
- (define-key global-map (read-kbd-macro "M-RET") 'hippie-expand)
- (load "completion")
- (initialize-completions)
- ;; Make actionscript-mode the default mode for .as files
- ;;(load "actionscript-mode")
- ;;(add-to-list ‘auto-mode-alist ‘(”//.as[123]?$” . actionscript-mode))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Various functions
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Convert DOS cr-lf to UNIX newline
- (defun dos-unix () (interactive) (goto-char (point-min))
- (while (search-forward "/r/n" nil t) (replace-match "/n")))
- ;; Convert UNIX newline to DOS cr-lf
- (defun unix-dos () (interactive) (goto-char (point-min))
- (while (search-forward "/n" nil t) (replace-match "/r/n")))
- ;; Replace all tab with four blank spaces
- (defun notab () (interactive) (goto-char (point-min))
- (while (search-forward "/t" nil t) (replace-match " ")))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; auto-indent
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq x-select-enable-clipboard t)
- ; for copying word
- (defun copy-word (&optional arg)
- "Copy words at point into kill-ring"
- (interactive "P")
- (let ((beg (progn (if (looking-back "[a-zA-Z0-9]" 1) (backward-word 1)) (point)))
- (end (progn (forward-word arg) (point))))
- (copy-region-as-kill beg end))
- )
- (global-set-key (kbd "C-c w") (quote copy-word))
- ; for copying line
- (defun copy-line (&optional arg)
- "Save current line into Kill-Ring without mark the line "
- (interactive "P")
- (let ((beg (line-beginning-position))
- (end (line-end-position arg)))
- (copy-region-as-kill beg end))
- )
- (global-set-key (kbd "C-c l") (quote copy-line))
- ; for copying paragraph
- (defun copy-paragraph (&optional arg)
- "Copy paragraphes at point"
- (interactive "P")
- (let ((beg (progn (backward-paragraph 1) (point)))
- (end (progn (forward-paragraph arg) (point))))
- (copy-region-as-kill beg end))
- )
- (global-set-key (kbd "C-c p") (quote copy-paragraph))
- ; for copying string
- (defun copy-string (&optional arg)
- "Copy a sequence of string into kill-ring"
- (interactive)
- (setq onPoint (point))
- (let (
- ( beg (progn (re-search-backward "[/t ]" (line-beginning-position) 3 1)
- (if (looking-at "[/t ]") (+ (point) 1) (point) ) )
- )
- ( end (progn (goto-char onPoint) (re-search-forward "[/t ]" (line-end-position) 3 1)
- (if (looking-back "[/t ]") (- (point) 1) (point) ) )
- )
- )
- (copy-region-as-kill beg end)
- )
- )
- (global-set-key (kbd "C-c s") (quote copy-string))
Windows 下需要在注册表中设定 emacs 启动时载入配置文件的 HOME 目录,下面是注册表文件
- Windows Registry Editor Version 5.00
- [HKEY_CURRENT_USER/Software/GNU]
- [HKEY_CURRENT_USER/Software/GNU/Emacs]
- "HOME"="D://GS//emacs_msw"
- Emacs 配置文件
- emacs 配置文件
- emacs配置文件
- Emacs 配置文件
- emacs 配置文件
- Emacs 配置文件
- emacs配置文件
- emacs配置文件
- Emacs 配置文件
- emacs配置文件
- Emacs 配置文件
- emacs配置文件
- Emacs 配置文件
- emacs配置文件——.emacs
- 我的emacs配置文件
- emacs的配置文件
- emacs配置文件浅谈
- 我的 Emacs 配置文件
- 大型网站架构演变和知识体系
- log4j 使用
- 关于打开网页FLASH显示叉叉问题
- vs2008编译 boost 1_35_0 regex 库
- vbs 讲解
- emacs 配置文件
- 熊猫烧香病毒vbs版本 仅供研究
- Windows 2003 安全设置之PHP篇
- LINK : fatal error LNK1104: cannot open file "Debug/工程.exe"(小的常识)
- vbs病毒代码
- PHP COM组件调用绕过安全模式执行任意文件漏洞
- disable_functions关闭的函数
- Ubuntu 8.10发布进入倒计时阶段
- windows2003目录权限设置(iis+php+mysql)