emacs - commit all stale emacs config
[dotfiles.git] / emacs.d / config / init-key-binding.el
index bf90894..cadcf29 100644 (file)
@@ -1,8 +1,49 @@
 ;; This  file is for some global key binding
 
+
+(setq mac-command-modifier 'super) ; make cmd key do Meta
+
+(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
+
+;; global swith project - plugin projectile
+(global-set-key (kbd "s-t") 'helm-projectile-switch-project)
+(global-set-key (kbd "s-n") 'persp-next)
+(global-set-key (kbd "s-p") 'persp-prev)
+(global-set-key (kbd "s-h") 'persp-switch)
+(global-set-key (kbd "s-j") 'helm-projectile-switch-to-buffer)
+(global-set-key (kbd "s-k") 'helm-cmd-t)
+
+
+(defun pl-make-keymap (key bindings)
+  (setq keymap (make-sparse-keymap))
+  (dolist (binding bindings)
+    (define-key keymap (car binding) (cdr binding)))
+  (global-set-key key keymap))
+
+;; Esc s or M-s as prefix key
+(pl-make-keymap "\M-s"
+            '(("j" . pl-switch-buffers)
+             ("h" . persp-switch)
+             ("k" . helm-cmd-t)
+             ("w" . save-buffer)
+             ("q" . helm-find-files)
+             ("-" . split-window-below)
+             ("\\" . split-window-right)
+             ("o" . occur)
+             ("b" . helm-find-files)))
+
+;; if current is not a project, useing helm-mini instead
+(defun pl-switch-buffers ()
+  (interactive)
+  (if (projectile-project-p)
+      (helm-projectile-switch-to-buffer)
+    (helm-mini)))
+  
+
+;; key-chord
 (require 'key-chord)
 
-;(setq key-chord-two-keys-delay 0.2)
+(setq key-chord-two-keys-delay 0.5)
 
 ;; from emacs conference 2015 workshop
 (defun keychord-keymap (keychord bindings)
     (define-key keymap (car binding) (cdr binding)))
   (key-chord-define-global keychord keymap))
 
-
-
-
-;;; keychord
-;;;
 (defun switch-to-previous-buffer ()
   "Switch to previously open buffer. Repeated invocations toggle between the two most recently open buffers."
   (interactive)
 ;(key-chord-define-global "sk" 'helm-find-files)
 
 
-(key-chord-define-global "JJ" 'save-buffer)
-(key-chord-define-global "HH" 'save-buffer)
-(key-chord-define-global "KK" 'save-buffer)
-(key-chord-define-global "LL" 'save-buffer)
-(key-chord-define-global "LL" 'save-buffer)
-(key-chord-define-global "UU" 'save-buffer)
-(key-chord-define-global "II" 'save-buffer)
-(key-chord-define-global "OO" 'save-buffer)
-(key-chord-define-global "NN" 'save-buffer)
-(key-chord-define-global "MM" 'save-buffer)
-(key-chord-define-global "PP" 'save-buffer)
-(key-chord-define-global "YY" 'save-buffer)
+;(key-chord-define-global "JJ" 'save-buffer)
+;(key-chord-define-global "HH" 'save-buffer)
+;(key-chord-define-global "KK" 'save-buffer)
+;(key-chord-define-global "LL" 'save-buffer)
+;(key-chord-define-global "LL" 'save-buffer)
+;(key-chord-define-global "UU" 'save-buffer)
+;(key-chord-define-global "II" 'save-buffer)
+;(key-chord-define-global "OO" 'save-buffer)
+;(key-chord-define-global "NN" 'save-buffer)
+;(key-chord-define-global "MM" 'save-buffer)
+;(key-chord-define-global "PP" 'save-buffer)
+;(key-chord-define-global "YY" 'save-buffer)
 
 
 
-
-(key-chord-define minibuffer-local-map "qq" "\C-g")
-
-
 (key-chord-define minibuffer-local-map "jj"  'keyboard-escape-quit)
 (key-chord-define minibuffer-local-ns-map "jj"  'keyboard-escape-quit)
 (key-chord-define minibuffer-local-isearch-map "jj"  'keyboard-escape-quit)
 (key-chord-define minibuffer-local-filename-must-match-map "jj"  'keyboard-escape-quit)
 
 
+(define-key minibuffer-local-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-ns-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-isearch-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-completion-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-must-match-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-must-match-filename-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-filename-completion-map [escape]  'keyboard-escape-quit)
+(define-key minibuffer-local-filename-must-match-map [escape]  'keyboard-escape-quit)
 
-(key-chord-mode 1)
 
 
+(key-chord-mode 1)
+
 
-;;; global key mapping, windows buffer, tab, project
-;;;
-(defun pl-make-keymap (key bindings)
-  (setq keymap (make-sparse-keymap))
-  (dolist (binding bindings)
-    (define-key keymap (car binding) (cdr binding)))
-  (global-set-key key keymap))
 
-;; ESC s j
-(pl-make-keymap "\M-s"
-            '(("j" . helm-mini)
-             ("k" . helm-find-files)
-             ("w" . save-buffer)
-             ("q" . helm-find-files)
-             ("-" . split-window-below)
-             ("\\" . split-window-right)
-;            ("\M-s" . split-window-below)
-;            ("\M-v" . split-window-right)
-             ("o" . occur)
-             ("b" . helm-find-files)))
 
 ;; ESC ; j M-; add comment, 
 (pl-make-keymap "\M-;"
 
 
 
-(defvar sacha/windmove-map (make-sparse-keymap))
-(define-key sacha/windmove-map "h" 'windmove-left)
-(define-key sacha/windmove-map "t" 'windmove-up)
-(define-key sacha/windmove-map "n" 'windmove-down)
-(define-key sacha/windmove-map "s" 'windmove-right)
-(define-key sacha/windmove-map "[left]" 'windmove-left)
-(define-key sacha/windmove-map "[up]" 'windmove-up)
-(define-key sacha/windmove-map "[down]" 'windmove-down)
-(define-key sacha/windmove-map "[right]" 'windmove-right)
-;(key-chord-define-global "yy"     sacha/windmove-map)
-
-
-
 ;; project
 ;(global-set-key (kbd "<escape> M-n") 'find-file)
 ;(global-set-key (kbd "<escape> M-m") 'find-file)
 
 
 
-(setq mac-command-modifier 'super) ; make cmd key do Meta
-
-
 
-;; super key for elscreen tabs
-(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
-(global-set-key (kbd "s-t") 'elscreen-create)
-(global-set-key (kbd "s-n") 'elscreen-next)
-(global-set-key (kbd "s-p") 'elscreen-previous)
 ;;(global-set-key (kbd "s-k") (lambda () (interactive) (elscreen-kill (elscreen-get-current-screen))))
 ;;(global-set-key (kbd "s-d") (lambda () (interactive) (elscreen-kill (elscreen-get-current-screen))))
 ;; C-c C-d
 (global-set-key (kbd "s-8") (lambda () (interactive) (elscreen-goto 8)))
 
 ;; super key for windows
-(global-set-key (kbd "s-l") 'split-window-below)
-(global-set-key (kbd "s-h") 'split-window-right)
-(global-set-key (kbd "s-i") 'other-window)
-(global-set-key (kbd "s-j") 'delete-other-windows)
-
-(global-set-key (kbd "s-k") (lambda () (interactive)
-                             (split-window-right)
-                             (other-window 1)
-                             (ido-find-file)))
+;(global-set-key (kbd "s-l") 'split-window-below)
+;(global-set-key (kbd "s-h") 'split-window-right)
+;(global-set-key (kbd "s-i") 'other-window)
+;(global-set-key (kbd "s-j") 'delete-other-windows)
+
+;(global-set-key (kbd "s-k") (lambda () (interactive)
+;                            (split-window-right)
+;                            (other-window 1)
+;                            (ido-find-file)))
                                
                              
 
 
 ;(global-set-key (kbd "M-g M-w") 'other-window)
 
-;;----------------------------------------------------------------------------
-;; C-o prefix binding for some File/Buffer switching/openning
-;;
-;;(global-unset-key "\C-o")
-;;(global-set-key (kbd "C-o C-o") 'keyboard-quit);; same as C-g to quit
-;;; c-o c-o swith to normal mode 
-;(global-set-key (kbd "C-o C-o") 'evil-normal-state)
-;;(global-set-key (kbd "C-o C-o") 'fiplr-find-file)
-;(global-set-key (kbd "C-o C-f") 'ido-find-file)
-;(global-set-key (kbd "C-o C-n") 'recentf-ido-find-file)
-;(global-set-key (kbd "C-o C-j") 'ido-switch-buffer)
-;(global-set-key (kbd "C-o C-j") 'ido-find-file)
 
 
 ;(global-set-key (kbd "C-o C-g") 'ggtags-find-file)