大家能贴一下自己的emacs配置吗 谢谢了
发表于 : 2007-12-07 19:15
大家能贴一下自己的emacs配置吗 最好有背景和语法高亮的(附效果图最好了
),小弟初学emacs,希望大家多多帮助

谢谢了 不过哪个是插件啊 这句话什么意思flyex 写了:后面的是插件,删去即可
代码: 全选
(add-to-list 'load-path "/home/drmagic/myemacs/")
(add-to-list 'load-path "/home/drmagic/myemacs/ecb")
(add-to-list 'load-path "/home/drmagic/myemacs/cedet/common")
;自定义按键
(global-set-key [f1] 'shell);F1进入Shell
(global-set-key [f5] 'gdb);F5调试程序
(setq compile-command "make -f Makefile")
(global-set-key [f7] 'do-compile);F7编译文件
(global-set-key [f8] 'other-window);F8窗口间跳转
(global-set-key [C-return] 'kill-this-buffer);C-return关闭当前buffer
(global-set-key [f10] 'split-window-vertically);F10分割窗口
(global-set-key [f11] 'delete-other-windows);F11 关闭其它窗口
;(global-set-key [f12] 'my-fullscreen);F12 全屏
(global-set-key (kbd "C-,") 'backward-page);文件首
(global-set-key (kbd "C-.") 'forward-page);文件尾
;(set-default-font "-bitstream-bitstream vera sans mono-medium-r-normal--0-0-0-0-m-0-iso10646-1")
;普通设置
(setq inhibit-startup-message t);关闭起动时闪屏
(setq visible-bell t);关闭出错时的提示声
(setq make-backup-files nil);不产生备份文件
(setq default-major-mode 'c-mode);一打开就起用 text 模式
(global-font-lock-mode t);语法高亮
(auto-image-file-mode t);打开图片显示功能
(setq mouse-yank-at-point t)
(fset 'yes-or-no-p 'y-or-n-p);以 y/n代表 yes/no
(column-number-mode t);显示列号
(show-paren-mode t);显示括号匹配
(display-time-mode 1);显示时间,格式如下
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(tool-bar-mode nil);去掉那个大大的工具栏
(menu-bar-mode nil);去掉菜单栏
(global-set-key [f12] 'menu-bar-mode);F12 全屏
(scroll-bar-mode nil);去掉滚动条
;(mouse-avoidance-mode 'animate);光标靠近鼠标指针时,让鼠标指针自动让开
(setq mouse-yank-at-point t);支持中键粘贴
(transient-mark-mode t);允许临时设置标记
(setq x-select-enable-clipboard t);支持emacs和外部程序的粘贴
(setq frame-title-format '("" buffer-file-name "@emacs" ));在标题栏显示buffer名称
(setq default-fill-column 120);默认显示 80列就换行
;鼠标滚轮,默认的滚动太快,这里改为3行
(defun up-slightly () (interactive) (scroll-up 3))
(defun down-slightly () (interactive) (scroll-down 3))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly)
;;非交互式编译
(defun do-compile ()
"Save buffers and start compile"
(interactive)
(save-some-buffers t)
(setq compilation-read-command nil)
(compile compile-command)
(setq compilation-read-command t))
;shell,gdb退出后,自动关闭该buffer
(add-hook 'shell-mode-hook 'mode-hook-func)
(add-hook 'gdb-mode-hook 'mode-hook-func)
(defun mode-hook-func ()
(set-process-sentinel (get-buffer-process (current-buffer))
#'kill-buffer-on-exit))
(defun kill-buffer-on-exit (process state)
(message "%s" state)
(if (or
(string-match "exited abnormally with code.*" state)
(string-match "finished" state))
(kill-buffer (current-buffer))))
;全屏
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(1 "_NET_WM_STATE_FULLSCREEN" 0)))
;最大化
;(defun my-maximized-horz ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
;(defun my-maximized-vert ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(defun my-maximized ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(my-maximized)
;加入标签功能
(require 'tabbar)
(tabbar-mode)
;(global-set-key (kbd "") 'tabbar-backward-group)
;(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "C-`") 'tabbar-backward)
(global-set-key (kbd "C-<tab>") 'tabbar-forward)
;设置tabbar字体
;(set-face-attribute 'tabbar-default-face
; nil :family "Sans")
;加入color-theme插件
(require 'color-theme)
(color-theme-aalto-dark)
;启动最大化
;(require 'maxframe)
;(setq mf-max-width 1024)
;(setq mf-max-height 768)
;(add-hook 'window-setup-hook 'maximize-frame t)
;加入cedet插件
;(add-hook 'texinfo-mode-hook (lambda () (require 'sb-texinfo)))
(require 'cedet)
(semantic-load-enable-code-helpers)
(autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
(autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t)
(define-key-after (lookup-key global-map [menu-bar tools])
[speedbar]
'("Speedbar" .
speedbar-frame-mode)
[calendar])
(global-set-key [f4] 'speedbar);F4打开/关闭speedbar
;;;;semantic /usr/include
(setq semanticdb-search-system-databases t)
(add-hook 'c-mode-common-hook
(lambda ()
(setq semanticdb-project-system-databases
(list (semanticdb-create-database
semanticdb-new-database-class
"/home/drmagic/")))))
(setq semanticdb-project-roots
(list
(expand-file-name "/")))
(defun my-indent-or-complete ()
(interactive)
(if (looking-at "\\>")
(hippie-expand nil)
(indent-for-tab-command))
)
(global-set-key [tab] 'my-indent-or-complete)
;; 自动补全,M-/ 原来的绑定 dabbrev-expand 也是这个功能,然而 hippie-expand
;; 功能更强而且可以扩展
(global-set-key "\M-/" 'hippie-expand)
;;ECB设置;
;(require 'ecb)
;ecb设置
;(require 'ecb-autoloads)
;(setq ecb-auto-activate t
; ecb-tip-of-the-day nil
; inhibit-startup-message t
; ecb-auto-compatibility-check nil
; ecb-version-check nil)
;(global-set-key [(meta return)] 'semantic-ia-complete-symbol-menu) ;;设置Alt+Enter为自动补全菜单
;(global-set-key [F3] 'ecb-goto-window-edit-last) ;;切换到编辑窗口
;(global-set-key [F2] 'ecb-goto-window-methods) ;;切换到函数窗口
;;CC- mode 设置;
(defun my-c-initialization-hook ()
(define-key c-mode-base-map "\C-m" 'c-context-line-break))
(add-hook 'c-initialization-hook 'my-c-initialization-hook)
;; offset customizations not in my-c-style
;; This will take precedence over any setting of the syntactic symbol
;; made by a style.
(setq c-offsets-alist '((member-init-intro . ++)))
;; Create my personal style.
(defconst drmagic
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t))
"DrMagic's C Programming Style")
(c-add-style "drmagic" drmagic)
;; Customizations for all modes in CC Mode.
(defun drmagic-hook ()
;; set my personal style for the current buffer
(c-set-style "linux")
;; other customizations
(setq tab-width 4
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;(c-setup-filladapt)
;(filladapt-mode 1)
;; we like auto-newline, but not hungry-delete
(c-toggle-auto-newline 1))
(add-hook 'c-mode-common-hook 'drmagic-hook)
;;CC-mode 设置结束;
;;显示行号;
(require 'display-line-number)
(setq display-line-number-format "%3d|")
(add-hook 'c-mode-hook 'display-line-number-mode)
;;代码补全设置;
;; ensure abbrev mode is always on
;(setq-default abbrev-mode t)
;; do not bug me about saving my abbreviations
;(setq save-abbrevs nil)
;; load up modes I use
(require 'cc-mode)
;(require 'perl-mode)
;(require 'cperl-mode)
;(require 'sh-script)
;(require 'shell)
;(require 'tex-site) ;; I use AUCTeX
;(require 'latex) ;; needed to define LaTeX-mode-hook under AUCTeX
;(require 'tex) ;; needed to define TeX-mode-hook under AUCTeX
;; (require 'python) ;; I use python.el from Emacs CVS, uncomment if you do also
(require 'msf-abbrev)
(setq msf-abbrev-verbose t) ;; optional
(setq msf-abbrev-root "/home/drmagic/myemacs/mode-abbrevs")
(global-set-key (kbd "C-c l") 'msf-abbrev-goto-root)
(global-set-key (kbd "C-c a") 'msf-abbrev-define-new-abbrev-this-mode)
(msf-abbrev-load)
(global-set-key [(meta ?/)] 'hippie-expand)
(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-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;;代码补全设置结束;
;;GDB UI 设置
(setq gdb-many-windows t)
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
;; 日历设置 ;;
(setq diary-file "~/myemacs/diary"
view-diary-entries-initially t
calendar-latitude +45.75
calendar-longitude +126.63
calendar-location-name "Harbin"
calendar-remove-frame-by-deleting t
calendar-week-start-day 1
chinese-calendar-celestial-stem
["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"]
chinese-calendar-terrestrial-branch
["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"]
general-holidays
'((holiday-fixed 1 1 "元旦") (holiday-fixed 2 14 "情人节")
(holiday-fixed 4 1 "愚人节") (holiday-float 5 0 2 "母亲节")
(holiday-float 6 0 3 "父亲节") (holiday-fixed 12 25 "圣诞节")
(holiday-fixed 1 19 "考研")
)
local-holidays
'((holiday-chinese 1 15 "元宵节 (正月十五)")
(holiday-chinese 5 5 "端午节 (五月初五)")
(holiday-chinese 7 7 "七月七 (七月初七)")
(holiday-chinese 9 9 "重阳节 (九月初九)")
(holiday-chinese 8 15 "中秋节 (八月十五)")
(holiday-chinese 12 -1 "除夕")
(holiday-chinese 1 19 "考研"))
christian-holidays nil
hebrew-holidays nil
islamic-holidays nil
;; solar-holidays nil
bahai-holidays nil
solar-n-hemi-seasons '("春分" "夏至" "秋分" "冬至"))
(setq mark-diary-entries-in-calendar t
appt-message-warning-time 30
mark-holidays-in-calendar t)
(setq diary-date-forms '((year "-" month "-" day "[^/0-9]"))
calendar-date-display-form '(year "-" month "-" day)
calendar-time-display-form
'(24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")")))
(eval-after-load 'calendar
'(progn
;; (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)
(add-hook 'diary-hook 'appt-make-list)
(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'calendar-load-hook
(lambda ()
(define-key calendar-mode-map ">" 'scroll-calendar-left)
(define-key calendar-mode-map "<" 'scroll-calendar-right)
(define-key calendar-mode-map "N" 'scroll-calendar-left-three-months)
(define-key calendar-mode-map "P" 'scroll-calendar-right-three-months)
(define-key calendar-mode-map "\M-n" 'scroll-calendar-left-three-months)
(define-key calendar-mode-map "\M-p" 'scroll-calendar-right-three-months)
(define-key calendar-mode-map "f" 'calendar-forward-day)
(define-key calendar-mode-map "b" 'calendar-backward-day)
(define-key calendar-mode-map "j" 'calendar-forward-week)
(define-key calendar-mode-map "k" 'calendar-backward-week)
(define-key calendar-mode-map "\C-z" 'calendar-set-mark)))
(autoload 'chinese-year "cal-china" "Chinese year data" t)
(defun holiday-chinese (cmonth cday string)
"Chinese calendar holiday, month and day in Chinese calendar (CMONTH, CDAY).
If corresponding MONTH and DAY in gregorian calendar is visible,
the value returned is the list \(((MONTH DAY year) STRING)).
Returns nil if it is not visible in the current calendar window."
(let* ((m displayed-month)
(y displayed-year)
(gdate (calendar-gregorian-from-absolute
(+ (cadr (assoc cmonth (chinese-year (+ y (/ cmonth 12))))) (1- cday)))))
(increment-calendar-month m y (- 11 (car gdate)))
(if (> m 9) (list (list gdate string)))))))
;;日历设置结束 ;
(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.
'(semantic-default-c-path (quote ("/usr/include")))
'(semanticdb-find-default-throttle (quote (file project unloaded system recursive omniscience)))
)
(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.
)