;;; jerry-other-elisp.el ends here
;;; 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