1 ;; This file is for some global key binding
8 (setq key-chord-two-keys-delay 0.2)
10 ;; from emacs conference 2015 workshop
11 (defun keychord-keymap (keychord bindings)
12 (setq keymap (make-sparse-keymap))
13 (dolist (binding bindings)
14 (define-key keymap (car binding) (cdr binding)))
15 (key-chord-define-global keychord keymap))
18 (defun switch-to-previous-buffer ()
19 "Switch to previously open buffer. Repeated invocations toggle between the two most recently open buffers."
21 (switch-to-buffer (other-buffer (current-buffer) 1)))
30 ("o" . delete-other-windows)))
34 ;; packet-list-install
38 ;; for some helm key mapping
39 (key-chord-define-global "sj" 'helm-mini)
40 (key-chord-define-global "sk" 'helm-find-files)
43 (key-chord-define-global ";w" 'save-buffer)
44 (key-chord-define-global ";s" 'split-window-below)
45 (key-chord-define-global ";v" 'split-window-right)
46 (key-chord-define-global ";q" 'delete-window)
48 ;(key-chord-define-global "x0" 'other-window)
49 ;(key-chord-define-global "x1" 'delete-other-windows)
52 ;; same set ESC ESC as a prefix key map
54 ;(global-set-key (kbd "<escape> M-a") 'find-file)
55 (global-set-key (kbd "<escape> M-o") 'delete-other-windows)
56 (global-set-key (kbd "<escape> M-h") 'other-window)
57 (global-set-key (kbd "<escape> M-j") 'find-file)
58 (global-set-key (kbd "<escape> M-k") 'find-file)
59 (global-set-key (kbd "<escape> M-l") 'find-file)
63 (global-set-key (kbd "<escape> M-n") 'find-file)
64 (global-set-key (kbd "<escape> M-m") 'find-file)
65 (global-set-key (kbd "<escape> M-p") 'find-file)
66 (global-set-key (kbd "<escape> M-u") 'find-file)
67 (global-set-key (kbd "<escape> M-y") 'find-file)
68 ;(global-set-key (kbd "<escape> <escape>") 'find-file)
71 (key-chord-define-global "JJ" 'save-buffer)
72 (key-chord-define-global "HH" 'save-buffer)
73 (key-chord-define-global "KK" 'save-buffer)
74 (key-chord-define-global "LL" 'save-buffer)
75 (key-chord-define-global "LL" 'save-buffer)
76 (key-chord-define-global "UU" 'save-buffer)
77 (key-chord-define-global "II" 'save-buffer)
78 (key-chord-define-global "OO" 'save-buffer)
79 (key-chord-define-global "NN" 'save-buffer)
80 (key-chord-define-global "MM" 'save-buffer)
81 (key-chord-define-global "PP" 'save-buffer)
82 (key-chord-define-global "YY" 'save-buffer)
87 (key-chord-define minibuffer-local-map "qq" "\C-g")
90 (key-chord-define minibuffer-local-map "jj" 'keyboard-escape-quit)
91 (key-chord-define minibuffer-local-ns-map "jj" 'keyboard-escape-quit)
92 (key-chord-define minibuffer-local-isearch-map "jj" 'keyboard-escape-quit)
93 (key-chord-define minibuffer-local-completion-map "jj" 'keyboard-escape-quit)
94 (key-chord-define minibuffer-local-must-match-map "jj" 'keyboard-escape-quit)
95 (key-chord-define minibuffer-local-must-match-filename-map "jj" 'keyboard-escape-quit)
96 (key-chord-define minibuffer-local-filename-completion-map "jj" 'keyboard-escape-quit)
97 (key-chord-define minibuffer-local-filename-must-match-map "jj" 'keyboard-escape-quit)
103 ;;;;;;;;;;;;;(provide 'init-keychord)
106 (setq mac-command-modifier 'super) ; make cmd key do Meta
108 ;; super key for elscreen tabs
109 (global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
110 (global-set-key (kbd "s-t") 'elscreen-create)
111 (global-set-key (kbd "s-n") 'elscreen-next)
112 (global-set-key (kbd "s-p") 'elscreen-previous)
113 ;;(global-set-key (kbd "s-k") (lambda () (interactive) (elscreen-kill (elscreen-get-current-screen))))
114 ;;(global-set-key (kbd "s-d") (lambda () (interactive) (elscreen-kill (elscreen-get-current-screen))))
117 (global-set-key (kbd "s-`") (lambda () (interactive) (elscreen-goto 0)))
118 (global-set-key (kbd "s-1") (lambda () (interactive) (elscreen-goto 1)))
119 (global-set-key (kbd "s-2") (lambda () (interactive) (elscreen-goto 2)))
120 (global-set-key (kbd "s-3") (lambda () (interactive) (elscreen-goto 3)))
121 (global-set-key (kbd "s-4") (lambda () (interactive) (elscreen-goto 4)))
122 (global-set-key (kbd "s-5") (lambda () (interactive) (elscreen-goto 5)))
123 (global-set-key (kbd "s-6") (lambda () (interactive) (elscreen-goto 6)))
124 (global-set-key (kbd "s-7") (lambda () (interactive) (elscreen-goto 7)))
125 (global-set-key (kbd "s-8") (lambda () (interactive) (elscreen-goto 8)))
127 ;; super key for windows
128 (global-set-key (kbd "s-l") 'split-window-below)
129 (global-set-key (kbd "s-h") 'split-window-right)
130 (global-set-key (kbd "s-i") 'other-window)
131 (global-set-key (kbd "s-j") 'delete-other-windows)
133 (global-set-key (kbd "s-k") (lambda () (interactive)
141 ;(global-set-key (kbd "M-g M-w") 'other-window)
143 ;;----------------------------------------------------------------------------
144 ;; C-o prefix binding for some File/Buffer switching/openning
146 (global-unset-key "\C-o")
147 ;;(global-set-key (kbd "C-o C-o") 'keyboard-quit);; same as C-g to quit
148 ;;; c-o c-o swith to normal mode
149 (global-set-key (kbd "C-o C-o") 'evil-normal-state)
150 ;;(global-set-key (kbd "C-o C-o") 'fiplr-find-file)
151 (global-set-key (kbd "C-o C-f") 'ido-find-file)
152 (global-set-key (kbd "C-o C-n") 'recentf-ido-find-file)
153 (global-set-key (kbd "C-o C-j") 'ido-switch-buffer)
154 ;(global-set-key (kbd "C-o C-j") 'ido-find-file)
157 (global-set-key (kbd "C-o C-g") 'ggtags-find-file)
158 (global-set-key (kbd "C-o C-t") 'ggtags-find-tag-dwim)
160 (global-set-key (kbd "M-g M-g") 'magit-status)
163 (defun recentf-ido-find-file ()
164 "Find a recent file using Ido."
166 (let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
171 ;;----------------------------------------------------------------------------
172 ;; M-g prefix binding for some commands
177 (provide 'init-key-binding)