大家能贴一下自己的emacs配置吗 谢谢了

Vim、Emacs配置和使用
回复
jsjcjsjc
帖子: 152
注册时间: 2007-03-03 13:36

大家能贴一下自己的emacs配置吗 谢谢了

#1

帖子 jsjcjsjc » 2007-12-07 19:15

大家能贴一下自己的emacs配置吗 最好有背景和语法高亮的(附效果图最好了 :D ),小弟初学emacs,希望大家多多帮助
jsjcjsjc
帖子: 152
注册时间: 2007-03-03 13:36

#2

帖子 jsjcjsjc » 2007-12-08 22:14

我是Windows版的 大哥大姐帮个忙啊 小弟感激不尽啊
看到别人的emacs都很酷啊
留一个模板页可以啊
jsjcjsjc
帖子: 152
注册时间: 2007-03-03 13:36

#3

帖子 jsjcjsjc » 2007-12-11 21:45

看来还是自己去找吧
flyex
帖子: 3
注册时间: 2007-09-20 21:54

#4

帖子 flyex » 2007-12-18 22:19

后面的是插件,删去即可


(setq default-major-mode 'text-mode);一打开就启用 text 模式。
(global-font-lock-mode t);语法高亮
(auto-image-file-mode 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)
(setq display-time-use-mail-icon t) ;;时间栏旁边启用邮件设置
(setq display-time-interval 10) ;;时间的变化频率,单位多少来着?
(setq inhibit-startup-message t);;去掉emacs和gnus启动时的引导界面
(setq gnus-inhibit-startup-message t)
;;是用aspell程序作为emacs的拼写检查成学
(setq-default ispell-program-name "aspell")
(setq enable-recursive-minibuffers t) ;; 递归使用minibuffer.
(transient-mark-mode t);; 高亮显示要拷贝的区域
(tool-bar-mode nil);去掉那个大大的工具栏
(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 "flyex@%b"); 在标题栏提示你目前在什么位置。你要把idealee改成自己的用户名
(setq default-fill-column 60);默认显示 80列就换行
;;滚动页面时比较舒服,不要整页的滚动
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
;;设定句子结尾,主要是针对中文设置
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)

;;把c语言风格设置为k&r风格
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "k&r")))
;;set c++ style as stroustrup style
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "strostrup")))

;;备份设置
;;emacs还有一个自动保存功能,默认在~/.emacs.d/auto-save-list里,这个非常有用,我这里没有改动,具体可以参见Sams teach yourself emacs in 24hours(我简称为sams24)
;;启用版本控制,即可以备份多次
(setq version-control t)
;;备份最原始的版本两次,记第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;;备份最新的版本五次,理解同上
(setq kept-new-versions 5)
;;删掉不属于以上7中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路
(setq backup-directory-alist '(("." . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
;;(setq backup-by-copying t)

;;字体解码优先顺序
;;;;从王垠那拷过来的,不用怎么再改吧。
;;(setq font-encoding-alist)
(append '(("MuleTibetan-0" (tibetan . 0))
("GB2312" (chinese-gb2312 . 0))
("JISX0208" (japanese-jisx0208 . 0))
("JISX0212" (japanese-jisx0212 . 0))
("VISCII" (vietnamese-viscii-lower . 0))
("KSC5601" (korean-ksc5601 . 0))
("MuleArabic-0" (arabic-digit . 0))
("MuleArabic-1" (arabic-1-column . 0))
("MuleArabic-2" (arabic-2-column . 0))) font-encoding-alist)

(load-file "/home/flyex/.EmacsPlugins/color-theme.el")
(color-theme-comidia);选择 gray30 的为默认的配色方案

(add-hook 'texinfo-mode-hook (lambda () (require 'sb-texinfo)))
(load-file "/home/flyex/.EmacsPlugins/cedet-1.0pre3/common/cedet.el")
(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])

(add-to-list 'load-path "/home/flyex/.EmacsPlugins/ecb-2.32")
(require 'ecb)
;;(require 'ecb-activate)

(load-file "/home/flyex/.EmacsPlugins/tabbar.el")
(require 'tabbar)
(tabbar-mode)
(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-options-version "2.32"))
(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.
)

(add-to-list 'load-path "/home/flyex/.EmacsPlugins/dictionary-1.8.7")
(require 'dictionary)

(autoload 'dictionary-search "dictionary"
"Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
"Ask for a word and search all matching words in the dictionaries" t)
(autoload 'dictionary-lookup-definition "dictionary"
"Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
"Create a new dictionary buffer" t)
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
"Display entries matching the word at the cursor" t)
(autoload 'dictionary-popup-matching-words "dictionary"
"Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
"Display tooltips for the current word" t)
(autoload 'global-dictionary-tooltip-mode "dictionary"
"Enable/disable dictionary-tooltip-mode for all buffers" t)
;; key bindings
(global-set-key "\C-cs" 'dictionary-search)
(global-set-key "\C-cm" 'dictionary-match-words)
附件
emacs.png
jsjcjsjc
帖子: 152
注册时间: 2007-03-03 13:36

#5

帖子 jsjcjsjc » 2007-12-21 18:44

flyex 写了:后面的是插件,删去即可
谢谢了 不过哪个是插件啊 这句话什么意思
头像
newage
帖子: 143
注册时间: 2007-08-31 16:28

#6

帖子 newage » 2007-12-25 19:32

代码: 全选

(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.
 )
附件
Screenshot.png
Linux gentoo 2.6.23-gentoo-r1 #4 PREEMPT Sat Nov 10 11:51:13 CST 2007 i686 AMD Duron(tm) processor AuthenticAMD GNU/Linux
jsjcjsjc
帖子: 152
注册时间: 2007-03-03 13:36

#7

帖子 jsjcjsjc » 2007-12-27 16:58

3Q 原来回收站也可以啊
xxmv99
帖子: 166
注册时间: 2007-12-26 11:02

#8

帖子 xxmv99 » 2008-01-09 17:01

6楼我也是用你的配置,怎么这么难看?

:shock: :evil: :twisted:
xxmv99
帖子: 166
注册时间: 2007-12-26 11:02

截图

#9

帖子 xxmv99 » 2008-01-09 17:14

截图
附件
Screenshot-@emacs.png
回复