emacs推广,配置详细介绍

Vim、Emacs配置和使用
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
送出感谢: 3 次
接收感谢: 1 次
联系:

#16

帖子 jarodlau » 2008-07-15 23:26

下面是一些零碎的小扩展,这些小扩展很实用

代码: 全选

;;; jerry-other-elisp.el ---
;; ASCII码表
(autoload 'ascii "ascii-table" "ASCII TABLE" t)
;; 保存状态
(require 'session)
(add-hook 'after-init-hook
	  'session-initialize)
;;use both desktop and session
;(setq desktop-globals-to-save '(desktop-missing-file-warning))

;; redo
(require 'redo)

;; Add "Open Recent" menu to the Files menu.
;; Must be set before require, else not passed on initial call to
;; package it seems. Not sure why.
(setq recentf-save-file (expand-file-name "recentf" "~/.emacs.d/")
      recentf-max-saved-items 100
      recentf-max-menu-items  20
      ;recentf-exclude '("/VM/" "/Gnus/" "/bbdb" "\\`/[a-zA-Z0-9@]+:")
      )
;; 一个使用recentf可以打开最近打开文件列表的功能
(defun recentf-open-files-compl ()
  (interactive)
  (let* ((all-files recentf-list)
         (tocpl (mapcar (function
                         (lambda (x) (cons (file-name-nondirectory x) x))) all-files))
         (prompt (append '("最近打开的文件: ") tocpl))
	 ;;(prompt (append '("File name: ") tocpl))
         (fname (completing-read (car prompt) (cdr prompt) nil nil)))
    (find-file (cdr (assoc-string fname tocpl)))))

(require 'recentf)
(recentf-mode 1)

;;firefox风格的tabbar
(require 'tabbar)
(tabbar-mode)

;;快速切换buffer
(require 'swbuff)
(setq swbuff-exclude-buffer-regexps
     '("^ " "\\*.*\\*"))
(setq swbuff-status-window-layout 'scroll)
(setq swbuff-clear-delay 1)
(setq swbuff-separator "|")
(setq swbuff-window-min-text-height 1)

;;制作图表的
;(require 'table)
(autoload 'table-insert "table" "WYGIWYS table editor")
(add-hook 'text-mode-hook 'table-recognize)

;; 观看kill-ring
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

(autoload 'sawfish-mode "sawfish" "sawfish-mode" t)

(autoload 'maxima "maxima" "Maxima interaction" t)
(autoload 'maxima-mode "maxima" "Maxima mode" t)
(autoload 'emaxima-mode "emaxima" "Emaxima" t)
(add-hook 'emaxmia-mode-hook 'emaxima-mark-file-as-emaxima)

(autoload 'imaxima "imaxima" "Image support for Maxima." t)

;;2种编辑html的好模式
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(autoload 'css-mode "css-mode" "Mode for editing CSS files" t)

;;查看端口
(autoload 'services-lookup      "services" "Perform a service lookup" t)
(autoload 'services-clear-cache "services" "Clear the service cache"  t)

;;查看C的type
(require 'ctypes)
(ctypes-auto-parse-mode 1)
;;使用xcscope
(require 'xcscope)

;;emacs的grep
;(require 'igrep)
(autoload 'igrep "igrep"
     "*Run `grep` PROGRAM to match EXPRESSION in FILES..." t)
(autoload 'igrep-find "igrep"
     "*Run `grep` via `find`..." t)
(autoload 'igrep-visited-files "igrep"
     "*Run `grep` ... on all visited files." t)
(autoload 'dired-do-igrep "igrep"
     "*Run `grep` on the marked (or next prefix ARG) files." t)
(autoload 'dired-do-igrep-find "igrep"
     "*Run `grep` via `find` on the marked (or next prefix ARG) directories." t)
(autoload 'Buffer-menu-igrep "igrep"
     "*Run `grep` on the files visited in buffers marked with '>'." t)
(autoload 'igrep-insinuate "igrep"
     "Define `grep' aliases for the corresponding `igrep' commands." t)
(autoload 'igrep-find-query-replace "igrep-find-query-replace" "" t)
(put 'igrep-files-default 'c++-mode
	 (lambda () "*.h *.cpp *.c"))
(put 'igrep-files-default 'c-mode
	 (lambda () "*.[ch]"))

;;fvwm的高亮显示
;(require 'fvwm-mode)
(autoload 'fvwm-mode "fvwm-mode" "Mode for editing for fvwm files" t)

;;cscope的前端
;(require 'xcscope)


;; hide region
(require 'hide-region)

;; hide lines
(require 'hide-lines)

;; sdcv mode使用sdcv查字典
(require 'sdcv-mode)

;; windzoom平滑分割窗口
;(require 'windzoom)

;; emms 配置
;;; setup emms
;;(add-to-list 'load-path
;;             (expand-file-name "~/emacs/packages/emms"))

(require 'emms-source-file)
(require 'emms-source-playlist)
(require 'emms-player-simple)
(require 'emms-player-mplayer)
(require 'emms-playlist-mode)
(require 'emms-info)
(require 'emms-cache)
(require 'emms-mode-line)
(require 'emms-playing-time)
(require 'emms-score)
(require 'emms-volume)

(setq emms-playlist-default-major-mode 'emms-playlist-mode)
(add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
(add-to-list 'emms-info-functions 'kid-emms-info-simple)
(setq emms-track-description-function 'kid-emms-info-track-description)
(when (fboundp 'emms-cache)
  (emms-cache 1))

(setq emms-player-list
      '(emms-player-mpg321
        emms-player-ogg123
        emms-player-mplayer))

(setq emms-info-asynchronously nil)
(setq emms-playlist-buffer-name "*Music*")
; use faster finding facility if you have GNU find
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
; My musics
(setq emms-source-file-default-directory "/media/hda6/舞曲")
(add-hook 'emms-player-started-hook 'emms-show)
; mode line format
(setq emms-mode-line-format "[ %s "
      emms-playing-time-display-format "%s ]")
(setq global-mode-string
      '("" emms-mode-line-string " " emms-playing-time-string))
;
(defun kid-emms-info-simple (track)
  "Get info from the filename.
mp3 标签的乱码问题总是很严重,幸好我系统里面的音乐文件
都放得比较有规律,所以我决定直接从文件名获取标签信息。"
  (when (eq 'file (emms-track-type track))
    (let ((regexp "/\\([^/]+\\)/\\([^/]+\\)\\.[^.]+$")
          (name (emms-track-name track)))
      (if (string-match regexp name)
          (progn
            (emms-track-set track 'info-artist (match-string 1 name))
            (emms-track-set track 'info-title (match-string 2 name)))
          (emms-track-set track
                          'info-title
                          (file-name-nondirectory name))))))

(defun kid-emms-info-track-description (track)
  "Return a description of the current track."
  (let ((artist (emms-track-get track 'info-artist))
        (title (emms-track-get track 'info-title)))
    (format "%-10s +| %s"
            (or artist
                "")
            title)))

;; show the line number
(require 'setnu)
(autoload 'setnu-plus "setnu-plus" t)

;; 把高亮显示的文本输出为html
;(require 'htmlize)
(setq htmlize-html-charset "gb2312")
(autoload 'htmlize-buffer "htmlize" "" t)

;; 高亮过于长的行
(require 'highlight-beyond-fill-column)

;;CJK Table
(if window-system
    (autoload 'keisen-mode "keisen-mouse" "MULE table" t)
  (autoload 'keisen-mode "keisen-mule" "MULE table" t))

;;图像化的矩形操作
(require 'rect-mark)

;; Auto rename the重名buffer
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)

;; svn的客户端
(require 'psvn)

;;;;;"Remember" is a mode for remembering data.
(autoload 'remember "remember" nil t)
(autoload 'remember-region "remember" nil t)

;; 多主模式的使用
(autoload 'mmm-mode "mmm-mode" "Multiple Major Modes" t)
(autoload 'mmm-parse-buffer "mmm-mode" "Automatic MMM-ification" t)
;(set-face-background 'mmm-default-submode-face nil)

;;使用ibuffer,把菜单里的也换掉
(require 'ibuffer)
(setq ibuffer-delete-window-on-quit t)
(defadvice ibuffer-quit (after kill-ibuffer activate)
  "Kill the ibuffer buffer on exit."
  (kill-buffer "*Ibuffer*"))
;; NB unusual way to modify menu entry. Found by C-h v menu-bar- [TAB].
(setq menu-bar-buffers-menu-command-entries
      ;;'(list-all-buffers menu-item "List All Buffers" ibuffer
      ;; 	 (nil)
      ;; 	 :help "Pop up a window listing all Emacs buffer"))
      '((command-separator "--")
	;;(next-buffer menu-item "Next Buffer" next-buffer
	(next-buffer menu-item "下一个Buffer" next-buffer
		     ([24 C-right]
		      . "  (C-x <C-right>)")
		     :help "在一个循环里切换到 \"next\" buffer")
		     ;;:help "Switch to the \"next\" buffer in a cyclic order")
	;;(previous-buffer menu-item "Previous Buffer" previous-buffer
	(previous-buffer menu-item "前一个Buffer" previous-buffer
			 ([24 C-left]
			  . "  (C-x <C-left>)")
			 :help "在一个循环里切换到 \"previous\" buffer")
			 ;;:help "Switch to the \"previous\" buffer in a cyclic order")
	;;(select-named-buffer menu-item "Select Named Buffer..." switch-to-buffer
	(select-named-buffer menu-item "从Buffer的名字里选择..." switch-to-buffer
			     ([24 98]
			      . "  (C-x b)")
			     :help "提示buffer的名字,并把选中的buffer显示在当前的窗口")
			     ;;:help "Prompt for a buffer name, and select that buffer in the current window")
	;;(list-all-buffers menu-item "List All Buffers" ibuffer ;;就是这样
	(list-all-buffers menu-item "列出所有的buffers" ibuffer ;;就是这样
			  ([24 98]
			      . "  (C-x C-b)")
			  ;;(nil)
			  :help "弹出一个窗口列出所有打开的buffer")))
			  ;;:help "Pop up a window listing all Emacs buffers")))
;; Ibuffer的彩色效果
(setq ibuffer-formats '((mark modified read-only " " (name 16 16) " "
                        (size 6 -1 :right) " " (mode 16 16 :center)
                         " " (process 8 -1) " " filename)
                    	   (mark " " (name 16 -1) " " filename))
      ibuffer-elide-long-columns t
      ibuffer-eliding-string "&")

;; edit-env 编辑环境变量
(require 'edit-env)

;; keywiz游戏- 训练你的键绑定-crazy game
(require 'keywiz)

;; todo mode
(autoload 'todo-mode "todo-mode"
  "Major mode for editing TODO lists." t)
(autoload 'todo-show "todo-mode"
  "Show TODO items." t)
(autoload 'todo-insert-item "todo-mode"
  "Add TODO item." t)
(setq todo-file-do "~/.emacs.d/todo-do")
(setq todo-file-done "~/.emacs.d/todo-done")
(setq todo-file-top "~/.emacs.d/todo-top")

;; slime
(add-to-list 'load-path "~/lib/emacs-lisp/slime-2.0/")  ; your SLIME directory
;;(setq inferior-lisp-program "/opt/sbcl/bin/sbcl") ; your Lisp system
(require 'slime)
(slime-setup)
;;如果安装了 Emacs-w3m 的话,直接在 Emacs-w3m 里面打开 HyperSpec 就更方便了:
(require 'hyperspec)
(setq common-lisp-hyperspec-root "file:/usr/share/doc/hyperspec/")
;; (setq browse-url-browser-function
;;       '(("/usr/share/doc/hyperspec/" . w3m-browse-url)
;;         ("." . browse-url-default-browser)))

(provide 'jerry-other-elisp)

;;; jerry-other-elisp.el ends here
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
送出感谢: 3 次
接收感谢: 1 次
联系:

#17

帖子 jarodlau » 2008-07-15 23:33

我把所有的热键配置都放到这里,最后加载,这样就不会被前面加载的插件所干扰,配置也方便

代码: 全选

;;; jerry-key-bindings.el --- 全局键盘绑定设置

;;; Code:

;;统一设置键帮定,并尽量放在配置文件的最后,以免被绑定的键不小心被后面
;;的配置文件覆盖
;;常用习惯,F1打开帮助,常用帮助有info和woman(就是在emacs中看man)
(global-set-key [f1] 'info)
;;使用woman显示man在一个buffer里面,常用
(global-set-key [(control f1)] 'woman)
;;恢复,常用键
(global-set-key [f2] 'undo)
;;打开sawfish的配置文件,我现在使用sawfish,帮定到这里,我可以随时更改
(global-set-key [(control f3)] 'my-open-dot-sawfishrc)
;;打开.emacs的快捷方式
(global-set-key [(control f2)] 'my-open-dot-emacs)
;;打开fvwm的.fvwm2rc和config的快速方式,以前使用fvwm,现在不用了,呵呵
;(global-set-key [(control f3)] 'my-open-fvwmconfig)
;;反恢复,不是很常用,但是绑定了还是方便些
(global-set-key [f3] 'redo)
;;F4,kill键,习惯设置,关闭当前buffer
(global-set-key [f4] 'kill-this-buffer)
;(global-set-key [f5] 'speedbar)
;;文件管理器,常用
(global-set-key [f6] 'dired-jump)
;;打开一个终端,根据你的爱好可以绑定为:eshell,shell,terminal-emulator
(global-set-key [f5] 'eshell)
;(global-set-key [f5] 'ansi-term)
;;同clear相识,具体功能在jerry-functions.el讲过
(global-set-key [f7] 'my-line-to-top-of-window)
;;本人正在学scheme,常用
;(global-set-key [f8] 'run-scheme)
;;;F9:列举我的书签
(global-set-key [f8] 'list-bookmarks)
;;;F9:添加当前页到书签中
;;(global-set-key [f9] 'bookmark-set)
;;看新闻组,常用的很,不过更多时间现在sir里
(global-set-key [f9] 'gnus)
;;习惯设置,打开/关闭菜单
(global-set-key [f10] 'menu-bar-mode)
;;编译等,暂时还不常用
(global-set-key [f11] 'compile)
;(global-set-key [f12] 'todo-show)
(global-set-key [f12] 'gdb)

;;习惯设置,Home键设定光标到文件开头
(global-set-key [(home)] 'beginning-of-buffer)
;;习惯设置,End键设定光标到文件结尾
(global-set-key [(end)] 'end-of-buffer)

;; Meta
(global-set-key "\M- " 'set-mark-command)
(global-set-key "\M-\C-h" 'backward-kill-word)
(global-set-key "\M-\C-r" 'query-replace)
(global-set-key "\M-r" 'replace-string)
;(global-set-key "\M-g" 'goto-line)
(global-set-key "\M-h" 'help-command)
;;Alt+s : 让speedbar获得焦点
(global-set-key (kbd "M-s") 'speedbar-get-focus)

;;meta在常用PC键上就是Alt键
;;这三个绑定主要是光标移动的
(global-set-key [(meta down)] 'goto-line)
(global-set-key [(meta left)] 'backward-sexp)
(global-set-key [(meta right)] 'forward-sexp)
;;NB:这下面的几个快捷键还没有熟练使用
;;注释region
;;比较常用,来回改的麻烦,还是这个方便
(global-set-key [(meta   m)] 'comment-region)
(global-set-key [(meta   u)] 'uncomment-region)
;; 常用补全命令
(global-set-key (kbd "M-/") 'hippie-expand)

;; ;;小键盘的bindings
;; (global-set-key [up] "\C-p")
;; (global-set-key [down] "\C-n")
;; (global-set-key [left] "\C-b")
;; (global-set-key [right] "\C-f")
;; ;(global-set-key [home] "\C-a")
;; ;(global-set-key [end] "\C-e")
;; (global-set-key [prior] "\M-v"); prior就是上翻页pg up
;; (global-set-key [next] "\C-v"); AKA pg dn
;; (global-set-key [C-up] "\M-\C-b")
;; (global-set-key [C-down] "\M-\C-f")
;; (global-set-key [C-left] "\M-b")
;; (global-set-key [C-right] "\M-f")
;; (global-set-key [C-home] "\M-<")
;; (global-set-key [C-end] "\M->")
;; ;(global-set-key [C-prior] "\M-<"); AKA pg up
;; ;(global-set-key [C-next] "\M->") ; AKA pg dn

;;快速切换buffer,prior就是上翻页pg up,next就是pg dn键盘
(global-set-key [C-prior] 'swbuff-switch-to-previous-buffer)
(global-set-key [C-next] 'swbuff-switch-to-next-buffer)
;;Win更换tabbar不错吧,前两个是在不同的分组切换,后面的是在同组
;;切换
(global-set-key [s-up] 'tabbar-backward-group)
(global-set-key [s-down] 'tabbar-backward-group)
;(global-set-key (kbd "M-]") 'tabbar-forward-group)
(global-set-key [s-left] 'tabbar-backward-tab)
(global-set-key [s-right] 'tabbar-forward-tab)
;;括号配对
(global-set-key "%" 'my-match-paren)
;;类似vi的f命令,使用方法为C-c a "x",x为任意字符,找第几个字符
(define-key global-map (kbd "C-c a") 'my-go-to-char)
;;hide region
(global-set-key (kbd "C-c r") 'hide-region-hide)
(global-set-key (kbd "C-c R") 'hide-region-unhide)
;;hide lines
(global-set-key (kbd "C-c l") 'hide-lines)
(global-set-key (kbd "C-c L") 'show-all-invisible)
;; 因为C-c m不是已有的前缀,所以要先定义一下
(define-prefix-command 'ctl-cm-map)
(global-set-key (kbd "C-c m") 'ctl-cm-map)
;; msf-abbrev的几个快捷键
(global-set-key (kbd "C-c ml") 'msf-abbrev-goto-root)
(global-set-key (kbd "C-c ma") 'msf-abbrev-define-new-abbrev-this-mode)
;;todo的几个快捷键
(global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer
(global-set-key "\C-ci" 'todo-insert-item) ;; insert new item
;;使用的ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; (global-set-key (kbd "C-x C-b") 'ibuffer-other-window)
;;remember的快捷键
(define-key global-map (kbd "C-c C-r") 'remember)
;(define-key global-map [f9] 'remember-region)
;;C-x C-r ,TAP列出最近打开的文件列表
(global-set-key "\C-x\C-r" 'recentf-open-files-compl)
;;让当前buffer生效的快捷方式
(add-hook 'emacs-lisp-mode-hook
	  (lambda ()
	    (local-set-key "\C-c\C-c" 'eval-buffer)
	    ))
;;为什么我就不能使用这个键呢,原来和fcitx输入法冲突了
(global-set-key [C-k] 'kill-line)


;;打开org的记事本,纪念,网络链接等
(define-key global-map "\C-cs" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
;(define-key global-map "\C-cr" 'org-remember)
;;用Emacs时常用多个窗口,窗口之间的移动很常见
;; 默认的打开文件太差劲,使用通用的操作方式吧
;(global-set-key [(control o)] 'ido-find-file)
(global-set-key [(meta   o)] 'other-window)
;;这就是我的切换buffer的设置,同windows操作相识
;;没法,windows用了两年多,有些习惯还真不好改
;;不过emacs的配置就是好配,随你配
(global-set-key [(control tab)] 'tabbar-forward)
;;这个设置是改变outline的快捷键前缀
;;outline主要用于编程等,目前用的不多
(setq outline-minor-mode-prefix (kbd "C-o"))
(mapc (lambda (bind)
        (define-key outline-minor-mode-map
            (car bind)
          (cdr bind)))
      `((,(kbd "C-o q") . hide-sublevels)
        (,(kbd "C-o a") . show-all)
        (,(kbd "C-o t") . hide-body)
        (,(kbd "C-o c") . hide-entry)
        (,(kbd "C-o e") . show-entry)
        (,(kbd "C-o l") . hide-leaves)
        (,(kbd "C-o k") . show-branches)
        (,(kbd "C-o d") . hide-subtree)))

;;自定义自动补齐命令,这部分是抄hhuu的,如果在单词中间就补齐,否则
;; 就是tab。
;(global-set-key [(control tab)] 'my-indent-or-complete)
;; 直观地把矩形显示出来
;; 作为和绑定到 C-x C-x 的 exchange-point-and-mark 对应起来
(global-set-key (kbd "C-x r C-x") 'rm-exchange-point-and-mark)
;;快速跳转到当前buffer所对应的目录
;(define-key global-map (kbd "C-x C-j") 'dired-jump)
(define-key global-map (kbd "C-x 4 C-j") 'dired-jump-other-window)


;;默认的Ctrl-z是什么来着,关闭emacs吧,好像还是强行关闭,不好,用
;;C-x c就好了
;;我就将Ctrl-z作为我的键的绑定
(define-prefix-command 'ctl-z-map)
(global-set-key (kbd "C-z") 'ctl-z-map)
;;启动picture (artist)模式
(global-set-key (kbd "C-z a") 'artist-mode)
;;编译当前emacs-lisp源码为elc
(global-set-key (kbd "C-z b") 'emacs-lisp-byte-compile)
;;打开我得日历
(global-set-key (kbd "C-z c") 'calendar)
;;字典功能,就是查单词
(global-set-key (kbd "C-z d d") 'dictionary-lookup-definition)
;;与上面类似
(global-set-key (kbd "C-z d s") 'dictionary-search)
;;查询当前单词的匹配的单词,用于补全单词
(global-set-key (kbd "C-z d m") 'dictionary-match-words)
;;字典提示模式,同字典的自动取词功能相似
;;查stardict字典
(global-set-key (kbd "C-z d t") 'sdcv-search)
;(global-set-key (kbd "C-z d t") 'kid-sdcv-to-buffer)
;(global-set-key (kbd "C-z d m") 'kid-star-dict)
;(global-set-key (kbd "C-z d t") 'dictionary-tooltip-mode)
;;编辑环境变量,很好用的功能
(global-set-key (kbd "C-z e e") 'edit-env)
;;启动我的IRC客户端,到sir去
(global-set-key (kbd "C-z e s") 'erc-irc)
;;到fans聊天去
(global-set-key (kbd "C-z e f") 'erc-fans)
;;启动拼写检查模式,只检查打开后输入的单词
(global-set-key (kbd "C-z f m") 'flyspell-mode)
;;对整个buffer进行拼写检查
(global-set-key (kbd "C-z f b") 'flyspell-buffer)
;;打开gnus
(global-set-key (kbd "C-z g") 'gnus)
;;数数本文件有多少文字
(global-set-key (kbd "C-z h c") 'my-count-words-region)
;;同Clear键
(global-set-key (kbd "C-z h l") 'my-line-to-top-of-window)
;;使用hyperspec查询common lisp的symbol定义
(global-set-key (kbd "C-z h s") 'hyperspec-lookup)
;;把高亮显示当前buffer输出为html格式的文件
(global-set-key (kbd "C-z h z") 'htmlize-buffer)
;;拼写检查
(global-set-key (kbd "C-z i") 'ispell-minor-mode)
;;debug
(global-set-key (kbd "C-z j") 'jdb)
;;查看前面删除的内容记录
(global-set-key (kbd "C-z k") 'browse-kill-ring)
;;关闭没有用的buffer
(global-set-key (kbd "C-c k") 'my-clean-buffers)
;;打印当前buffer
;(global-set-key (kbd "C-z l") 'lpr-buffer)
(global-set-key (kbd "C-z l") 'my-longest-line)
;;启动我得maxima,漂亮模式
;(global-set-key (kbd "C-z m m") 'imaxima)
;;看看我的键绑定
(global-set-key (kbd "C-z m k") 'my-keytable)
;;emms相关的快捷键-emacs 有了这个扩展完全可以当个媒体中心,呵呵
;; global key-map
(global-set-key (kbd "H-b") 'emms-playlist-mode-go)

(global-set-key (kbd "C-c e t") 'emms-play-directory-tree)
(global-set-key (kbd "C-c e x") 'emms-start)
(global-set-key (kbd "C-c e v") 'emms-stop)
(global-set-key (kbd "C-c e n") 'emms-next)
(global-set-key (kbd "C-c e p") 'emms-previous)
(global-set-key (kbd "C-c e o") 'emms-show)
(global-set-key (kbd "C-c e h") 'emms-shuffle)
(global-set-key (kbd "C-c e e") 'emms-play-file)
(global-set-key (kbd "C-c e f") 'emms-play-playlist)
(global-set-key (kbd "C-c e SPC") 'emms-pause)
(global-set-key (kbd "C-c e a") 'emms-add-directory-tree)

(global-set-key (kbd "C-c e r")   'emms-toggle-repeat-track)
(global-set-key (kbd "C-c e R")   'emms-toggle-repeat-playlist)

(global-set-key (kbd "C-c e s u") 'emms-score-up-playing)
(global-set-key (kbd "C-c e s d") 'emms-score-down-playing)
(global-set-key (kbd "C-c e s o") 'emms-score-show-playing)
;; playlist-mode-map
(define-key emms-playlist-mode-map (kbd "SPC") 'emms-pause)
(define-key emms-playlist-mode-map (kbd "+") 'emms-volume-raise)
(define-key emms-playlist-mode-map (kbd "-") 'emms-volume-lower)
(define-key emms-playlist-mode-map (kbd "<right>")
   (lambda () (interactive) (emms-seek-forward)));;+10)))
(define-key emms-playlist-mode-map (kbd "<left>")
   (lambda () (interactive) (emms-seek-backward)));;-10)))
(define-key emms-playlist-mode-map (kbd "<up>")
    (lambda () (interactive) (emms-seek +60)))
(define-key emms-playlist-mode-map (kbd ("<down>"))
   (lambda () (interactive) (emms-seek -60)))
(define-key emms-playlist-mode-map (kbd "S u") 'emms-score-up-file-on-line)
(define-key emms-playlist-mode-map (kbd "S d") 'emms-score-down-file-on-line)
(define-key emms-playlist-mode-map (kbd "S o") 'emms-score-show-file-on-line)
(define-key emms-playlist-mode-map (kbd "S l") 'emms-score-less-tolerant)
(define-key emms-playlist-mode-map (kbd "S m") 'emms-score-more-tolerant)
(define-key emms-playlist-mode-map (kbd "S t") 'emms-score-set-tolerance)
(define-key emms-playlist-mode-map (kbd "S s") 'emms-score-show-playing)

;;发送邮件
(global-set-key (kbd "C-z m s") 'mew-send)
;;接收邮件
(global-set-key (kbd "C-z m r")  'mew)

;;绑定两个narrow功能
(global-set-key (kbd "C-z n n") 'narrow-to-region)
(global-set-key (kbd "C-z n w") 'widen)
;;occur使用正则查找,列出一个buffer
(global-set-key (kbd "C-z o") 'occur)

;;几个小游戏
(global-set-key (kbd "C-z p g") 'gomoku)
(global-set-key (kbd "C-z p t") 'tetris)
;;训练绑定键盘的-看看你能记住多少热键
(global-set-key (kbd "C-z p k") 'keywiz)
;;由于在html-helper-mode模式中F4键失效,用这个绑定来关闭buffer
(global-set-key (kbd "C-z q") 'kill-this-buffer)
;;带正则表达式的搜索
(global-set-key (kbd "C-z r") 'query-replace-regexp)
;;我得scheme也是可以在emacs中运行的
;(global-set-key (kbd "C-z s") 'run-scheme)
;;打开行号显示,和vi一样的
(global-set-key (kbd "C-z s s") 'setnu-mode)
;;把speedbar集成到emacs的frame里
;(global-set-key (kbd "C-z s b") 'reset-window-config)
;;我的终端
(global-set-key (kbd "C-z t") 'term)
;;我的文件管理器
(global-set-key (kbd "C-z u d") 'dired-jump)
;; ;;FIXME 还是使用dired-single吧
;; (global-set-key (kbd "C-z u d")
;;                 'joc-dired-magic-buffer)
;; (global-set-key (kbd "C-z 4 d")
;;                 (lambda (directory)
;;                   (interactive "D")
;;                   (let ((win-list (window-list)))
;;                     (when (null (cdr win-list)) ; only one window
;;                       (split-window-vertically))
;;                     (other-window 1)
;;                     (joc-dired-magic-buffer directory))))
(global-set-key (kbd "C-z u f") 'folding-mode)
(global-set-key (kbd "C-z u o") 'outline-minor-mode)
;;查询service,见jerry-other-elisp.el
(global-set-key (kbd "C-z u s") 'services-lookup)
;;可以在emacs编辑文件使用vim习惯,常用的是vi-mode和viper-mode
(global-set-key (kbd "C-z v") 'vi-mode)
;;wiki中的绑定设置,还用的不多
(global-set-key (kbd "C-z w c") 'emacs-wiki-change-project)
(global-set-key (kbd "C-z w f") 'emacs-wiki-find-file)
(global-set-key (kbd "C-z w h") 'emacs-wiki-preview-html)
(global-set-key (kbd "C-z w i") 'emacs-wiki-index)
(global-set-key (kbd "C-z w p") 'emacs-wiki-publish)
(global-set-key (kbd "C-z w s") 'emacs-wiki-search)
;;我的浏览器
(global-set-key (kbd "C-z w w") 'w3m)
;;同C-z b有点不同,在编译后并加载
(global-set-key (kbd "C-z x") 'emacs-lisp-byte-compile-and-load)
;;同yank有点不一样,但具体怎样忘了,感觉这个比yank好点
(global-set-key (kbd "C-z y") 'clipboard-yank)
;;修改后的设定mark的绑定,由于经常忘了放住control键,就给这个功能两个绑
;;定了
(global-set-key (kbd "C-z z") 'set-mark-command)
(global-set-key (kbd "C-z C-z") 'set-mark-command)


;;there are severl other key-map below in other files
;;ctrl-f-folding-mode-prefix
;;ido key-map
;;severl self define functions related key-bindings.

(provide 'jerry-key-bindings)

;;; jerry-key-bindings.el ends here
cvgmt
帖子: 322
注册时间: 2007-02-26 2:29
来自: 广东
送出感谢: 0
接收感谢: 0

#18

帖子 cvgmt » 2008-07-16 9:25

精华!!!
虽然现在用的是 emacs23 以及法国人 Ivaldi 的 emacs.d.tgz 配置,不过大多数是不太知道原理的,现在有这个内容丰富,讲解清楚的配置,我们初学者有福了!
sschenri
帖子: 8
注册时间: 2008-03-25 10:30
送出感谢: 0
接收感谢: 0

#19

帖子 sschenri » 2008-07-16 20:17

好贴,谢谢楼主。
头像
siziki
帖子: 44
注册时间: 2008-07-08 20:12
送出感谢: 0
接收感谢: 0
联系:

#20

帖子 siziki » 2008-07-18 16:02

学习了
头像
siziki
帖子: 44
注册时间: 2008-07-08 20:12
送出感谢: 0
接收感谢: 0
联系:

#21

帖子 siziki » 2008-07-18 17:11

试验了一下emms的配置,lz的配置会把原来mode-line上的时间显示覆盖掉
头像
QuITh
帖子: 85
注册时间: 2007-11-27 15:46
来自: USTC
送出感谢: 0
接收感谢: 0
联系:

#22

帖子 QuITh » 2008-07-18 18:26

Thumbs up and added it to the Favorites!

And there is a muse-el ...
Patrick Hoo, a physics enthusiast.
OS: Debian(Xfce) GNU/Linux, LFS.
TeX, Vim, Emacs, JabRef, Wiki, etc.
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
送出感谢: 3 次
接收感谢: 1 次
联系:

#23

帖子 jarodlau » 2008-07-18 20:06

siziki 写了:试验了一下emms的配置,lz的配置会把原来mode-line上的时间显示覆盖掉
和23不兼容,我在22的时候一点问题都没有,所以说大家一起解决问题,我这个配置文件在22的情况下完全没有问题,碰到23的兼容性问题的话,希望大家一起解决一下。

一起进步,我调试了调试,那个calendar的配置里好多变量也改了,大家自己看一下编译的过程修改就可以了
头像
siziki
帖子: 44
注册时间: 2008-07-08 20:12
送出感谢: 0
接收感谢: 0
联系:

#24

帖子 siziki » 2008-07-18 23:48

是这样啊,多向lz学习,呵呵。

另外,用w3m似乎也有问题。
头像
lovewine
帖子: 1233
注册时间: 2006-03-25 10:36
送出感谢: 0
接收感谢: 0
联系:

#25

帖子 lovewine » 2008-07-19 10:27

楼主是大牛,还是大好人,赞一个
让自由的声音传传传传传传传传天下。。。
Spread the words of freedom.
头像
vvoody
帖子: 749
注册时间: 2007-01-21 20:10
送出感谢: 0
接收感谢: 0
联系:

#26

帖子 vvoody » 2008-07-19 10:52

赞啊!

@jarodlau
你现在用啥收信? 我用Mew, 你为啥不用了呢
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
送出感谢: 3 次
接收感谢: 1 次
联系:

#27

帖子 jarodlau » 2008-07-19 10:56

现在使用opera的邮件功能,我本本的配置比较老了,想升级内存,DDR333的现在我们这里没有货,所以现在能少开一个程序就少开一个,emacs一般都是在虚拟终端开,x的窗口只开一个浏览器和一个terminal就可以了,呵呵
头像
vvoody
帖子: 749
注册时间: 2007-01-21 20:10
送出感谢: 0
接收感谢: 0
联系:

#28

帖子 vvoody » 2008-07-19 11:19

jarodlau 写了:现在使用opera的邮件功能,我本本的配置比较老了,想升级内存,DDR333的现在我们这里没有货,所以现在能少开一个程序就少开一个,emacs一般都是在虚拟终端开,x的窗口只开一个浏览器和一个terminal就可以了,呵呵
以前我也几乎全在Opera上用, 现在主要还是用它来浏览网页了.
如果没开Opera , 邮件用Opera就不太方便

问个问题, require, load, auto-load, load-library 有啥区别, 特别是 require 和 load
我把 xml-rpc.el, igrep.el 编译成了 *.elc 放在了我自己的 load-path 里, 有没有把那些 key-bindings.el, language.el 也编译一下?
头像
jarodlau
帖子: 501
注册时间: 2005-09-06 20:34
送出感谢: 3 次
接收感谢: 1 次
联系:

#29

帖子 jarodlau » 2008-07-19 11:29

vvoody 写了:
jarodlau 写了:现在使用opera的邮件功能,我本本的配置比较老了,想升级内存,DDR333的现在我们这里没有货,所以现在能少开一个程序就少开一个,emacs一般都是在虚拟终端开,x的窗口只开一个浏览器和一个terminal就可以了,呵呵
以前我也几乎全在Opera上用, 现在主要还是用它来浏览网页了.
如果没开Opera , 邮件用Opera就不太方便

问个问题, require, load, auto-load, load-library 有啥区别, 特别是 require 和 load
我把 xml-rpc.el, igrep.el 编译成了 *.elc 放在了我自己的 load-path 里, 有没有把那些 key-bindings.el, language.el 也编译一下?
这几个命令都是加载插件的,区别就是,加载的快和慢。
require一般都是一些插件默认的加载模式,如果用这个加载,有可能不能使用;
load,auto-load,这两个的区别就是:load是把整个插件加载进来,而auto-load只是把插件的function表加载进来,等你使用的时候在加载程序模块
load-library一般都是在M-x后使用,比较适合作自己编辑的模块的加载

key-bindings.el, language.el 最好是编译一下,可以提高启动速度的。
你看看我前面的function的那一部分,里面涉及到了自动编译的内容,不过要根据你自己的情况改一改。
头像
vvoody
帖子: 749
注册时间: 2007-01-21 20:10
送出感谢: 0
接收感谢: 0
联系:

#30

帖子 vvoody » 2008-07-19 12:39

jarodlau 写了:这几个命令都是加载插件的,区别就是,加载的快和慢。
require一般都是一些插件默认的加载模式,如果用这个加载,有可能不能使用;
load,auto-load,这两个的区别就是:load是把整个插件加载进来,而auto-load只是把插件的function表加载进来,等你使用的时候在加载程序模块
load-library一般都是在M-x后使用,比较适合作自己编辑的模块的加载

key-bindings.el, language.el 最好是编译一下,可以提高启动速度的。
你看看我前面的function的那一部分,里面涉及到了自动编译的内容,不过要根据你自己的情况改一改。
谢谢牛牛 :D
回复

回到 “Vim和Emacs”