bind! -> map!; new minimalistic keybinding macro

This commit is contained in:
Henrik Lissner 2015-11-30 05:31:20 -05:00
parent 2e4a083bbb
commit 81df2830a9
19 changed files with 431 additions and 441 deletions

View file

@ -6,46 +6,35 @@
(eval-when-compile (require 'core-defuns))
(bind!
-
;; See `narf-leader-prefix' & `narf-localleader-prefix' in ../core/core-vars.el
(map!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global keymaps ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"M-x" 'helm-M-x
"M-;" 'eval-expression
"M-/" 'evil-commentary-line
"M-x" 'helm-M-x
"M-;" 'eval-expression
"M-/" 'evil-commentary-line
"A-x" 'helm-M-x
"A-;" 'eval-expression
"A-/" 'evil-commentary-line
"A-x" 'helm-M-x
"A-;" 'eval-expression
"A-/" 'evil-commentary-line
"M-0" (λ (text-scale-set 0))
"M-=" 'text-scale-increase
"M--" 'text-scale-decrease
(:when window-system
"M-0" (λ (text-scale-set 0))
"M-=" 'text-scale-increase
"M--" 'text-scale-decrease)
"M-b" 'narf:build
"M-t" 'helm-projectile-find-file
"<f9>" 'what-face
"A-`" 'narf-switch-to-iterm
"C-`" 'narf/popup-toggle
"C-~" 'rtog/toggle-repl
"M-b" 'narf:build
"M-t" 'helm-projectile-find-file
"A-`" 'narf-switch-to-iterm
"C-`" 'narf/popup-toggle
"C-~" 'rtog/toggle-repl
"<f9>" 'what-face
"M-w" 'evil-window-delete
"M-W" 'delete-frame
"M-n" (λ (switch-to-buffer (generate-new-buffer "*new*")))
"M-N" (λ (let ((nlinum-p (and (featurep 'nlinum)
(memq 'nlinum--setup-window window-configuration-change-hook))))
;; Disable nlinum to fix elusive "invalid face linum" bug
(remove-hook 'window-configuration-change-hook 'nlinum--setup-window t)
(let ((frame (new-frame))
(frame-name (format "*new-%s*" (length narf-wg-frames))))
(with-selected-frame frame
(wg-create-workgroup frame-name t)
(add-to-list 'narf-wg-frames (cons frame frame-name))))
(when nlinum-p
(add-hook 'window-configuration-change-hook 'nlinum--setup-window nil t))))
"M-w" 'evil-window-delete
"M-W" 'delete-frame
"M-n" 'narf/new-buffer
"M-N" 'narf/new-frame
;; Simpler window navigation
"C-j" 'evil-window-down
@ -72,21 +61,6 @@
:m "M-9" (λ (narf:switch-to-workgroup-at-index 8))
(:when IS-MAC
:ni "M-d" 'dash-at-point
;; Add animated transitions to OSX emacs
"M-w" 'evil-window-delete
"M-W" (λ (let ((data (assq (selected-frame) narf-wg-frames)))
(if data
(progn (wg-delete-workgroup (wg-get-workgroup (cdr data)))
(delete-frame (car data)))
(delete-frame))))
"M-n" (λ (switch-to-buffer (generate-new-buffer "*new*")))
;; Textmate-esque indent shift left/right
:i "M-[" (kbd "C-o m l C-o I DEL C-o ` l")
:i "M-]" (λ (evil-shift-right (point-at-bol) (point-at-eol)))
"<A-left>" 'backward-word
"<A-right>" 'forward-word
"<M-backspace>" 'narf/backward-kill-to-bol-and-indent
@ -98,7 +72,17 @@
"M-q" 'evil-quit-all
"M-z" 'undo
"M-Z" 'redo
"C-M-f" 'narf:toggle-fullscreen)
"C-M-f" 'narf:toggle-fullscreen
:ni "M-d" 'dash-at-point
;; Textmate-esque indent shift left/right
:i "M-[" (kbd "C-o m l C-o I DEL C-o ` l")
:i "M-]" (λ (evil-shift-right (point-at-bol) (point-at-eol)))
;; Restore osx text objects
:i "<A-backspace>" 'evil-delete-backward-word
:i "<A-delete>" (λ (evil-forward-word) (evil-delete-backward-word)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -106,69 +90,67 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:m ";" 'evil-ex
(:leader
:nv "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list)))
:nv "<" 'helm-buffers-list
:nv "." 'helm-find-files
:nv ">" 'helm-projectile-find-file-in-known-projects
:nv "/" 'helm-projectile-find-file
:nv ";" 'helm-semantic-or-imenu
:nv ":" 'helm-imenu-in-all-buffers
:nv "]" 'helm-etags-select
:nv "a" 'helm-projectile-find-other-file
:nv "E" (λ (in! narf-emacs-dir (helm-projectile-find-file)))
:nv "m" 'helm-recentf
:nv "M" 'helm-projectile-recentf ; recent PROJECT files
:nv "P" 'helm-projectile-switch-project
:v "=" 'align-regexp
:nv "r" 'emr-show-refactor-menu
:n "R" 'narf/reset-theme
;; <leader>
(:prefix ","
:nv "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list)))
:nv "<" 'helm-buffers-list
:nv "." 'helm-find-files
:nv ">" 'helm-projectile-find-file-in-known-projects
:nv "/" 'helm-projectile-find-file
:nv ";" 'helm-semantic-or-imenu
:nv ":" 'helm-imenu-in-all-buffers
:n "s" (λ (narf:yas-snippets t)) ; ido snippets dir
:n "h" 'diff-hl-diff-goto-hunk
:n "e" 'narf/flycheck-errors
:nv "p" 'helm-show-kill-ring
:nv "]" 'helm-etags-select
:nv "a" 'helm-projectile-find-other-file
:nv "E" (λ (in! narf-emacs-dir (helm-projectile-find-file)))
:nv "m" 'helm-recentf
:nv "M" 'helm-projectile-recentf ; recent PROJECT files
:nv "p" 'helm-projectile-switch-project
:v "=" 'align-regexp
:nv "r" 'emr-show-refactor-menu
:n "b" 'helm-bookmarks
:n "w" 'narf:workgroup-display
:n "W" 'narf:helm-wg
:nv "qq" 'evil-save-and-quit
:nv "QQ" 'narf/kill-all-buffers-do-not-remember
:nv "n" 'narf/neotree-toggle
:nv "N" 'narf/neotree-find
:nv "t" 'narf-switch-to-iterm
:nv "l" 'narf/nlinum-toggle
:nv "\\" 'evil-emacs-state
:n "oo" 'narf-open-with
:n "ob" (λ (narf-open-with "Google Chrome"))
:n "of" (λ (narf-open-with "Finder.app" default-directory))
:n "oF" (λ (narf-open-with "Finder.app" (narf/project-root)))
:n "ou" (λ (narf-open-with "Transmit"))
:n "oU" (λ (narf-open-with "Transmit" default-directory))
:n "ol" (λ (narf-open-with "LaunchBar"))
:n "oL" (λ (narf-open-with "LaunchBar" default-directory))
:n "ot" (λ (narf:tmux-chdir nil t))
:n "oT" 'narf:tmux-chdir
:nv "qq" 'evil-save-and-quit
:nv "QQ" 'narf/kill-all-buffers-do-not-remember
;; Org
:nv "n." (λ (in! org-directory (let ((helm-ff-skip-boring-files t)) (helm-find-files-1 org-directory))))
:nv "n/" 'narf/helm-org
:nv "np" 'narf/helm-org-projects
:nv "nc" 'narf/helm-org-contacts
:nv "ni" 'narf/helm-org-invoices
:nv "nw" 'narf/helm-org-writing)
;; Open with O/S
:n "oo" 'narf-open-with
:n "ob" (λ (narf-open-with "Google Chrome"))
:n "of" (λ (narf-open-with "Finder.app" default-directory))
:n "oF" (λ (narf-open-with "Finder.app" (narf/project-root)))
:n "ou" (λ (narf-open-with "Transmit"))
:n "oU" (λ (narf-open-with "Transmit" default-directory))
:n "ol" (λ (narf-open-with "LaunchBar"))
:n "oL" (λ (narf-open-with "LaunchBar" default-directory))
:n "ot" (λ (narf:tmux-chdir nil t))
:n "oT" 'narf:tmux-chdir
;; <localleader>
(:prefix "\\"
:nv "\\" 'narf/neotree-toggle
:nv "|" 'narf-switch-to-iterm
:nv "." 'narf/neotree-find
:nv ";" 'narf/nlinum-toggle
:nv "E" 'evil-emacs-state
;; Org notes
:nv "x." (λ (in! org-directory (let ((helm-ff-skip-boring-files t)) (helm-find-files-1 org-directory))))
:nv "x/" 'narf/helm-org
:nv "xp" 'narf/helm-org-projects
:nv "xc" 'narf/helm-org-contacts
:nv "xi" 'narf/helm-org-invoices
:nv "xw" 'narf/helm-org-writing)
:n "]" 'next-buffer
:n "[" 'previous-buffer
(:localleader
:n "\\" 'narf/neotree-toggle
:n "." 'narf/neotree-find)
:n "c" 'narf/reset-theme
:n "s" (λ (narf:yas-snippets t)) ; ido snippets dir
:n "g" 'diff-hl-diff-goto-hunk
:n "e" (λ (call-interactively 'flycheck-buffer) (flycheck-list-errors))
:n "p" 'helm-show-kill-ring
:n "b" 'helm-bookmarks
:n "w" 'narf:helm-wg
:n "W" 'narf:workgroup-display)
:nv "K" 'smart-up
:nv "K" 'smart-up
;; Don't move cursor on indent
:n "=" (λ (save-excursion (call-interactively 'evil-indent)))
@ -195,10 +177,10 @@
:n "g=" 'evil-numbers/inc-at-pt
:n "g-" 'evil-numbers/dec-at-pt
:n "gR" 'narf:eval-buffer
:n "gc" 'evil-commentary
:n "gx" 'evil-exchange
:n "gr" 'narf:eval-region
:n "gR" 'narf:eval-buffer
:v "gR" 'narf:eval-region-and-replace
:m "gl" 'avy-goto-line
:m "g]" 'smart-right
@ -242,15 +224,10 @@
(hs-toggle-hiding)
(call-interactively 'evilmi-jump-items)))))
;; Restore osx text objects
:i "<A-backspace>" 'evil-delete-backward-word
:i "<A-delete>" (λ (evil-forward-word) (evil-delete-backward-word))
;; Newline magic
;; Textmate-esque newlines
:i "<backspace>" 'backward-delete-char-untabify
:i "<M-backspace>" 'narf/backward-kill-to-bol-and-indent
:i "<C-return>" 'evil-ret-and-indent
:i "<C-SPC>" (λ (insert ", "))
;; escape from insert mode (more responsive than using key-chord-define)
:ir "j" 'narf:exit-mode-maybe
@ -262,7 +239,7 @@
:n "!" 'rotate-word-at-point
:v "!" 'rotate-region
:e [escape] 'evil-normal-state
:e "<escape>" 'evil-normal-state
(:map evil-window-map ; prefix "C-w"
"u" 'narf/undo-window-change
@ -290,6 +267,7 @@
;; Vim omni-complete emulation
:i "C-SPC" 'company-complete-common
:i "C-x C-l" 'narf/company-whole-lines
:i "C-x C-k" 'company-dict
:i "C-x C-f" 'company-files
:i "C-x C-]" 'company-tags
@ -313,12 +291,12 @@
"C-SPC" 'company-complete-common-or-cycle
[tab] 'narf/company-complete-common-or-complete-full
"<backtab>" 'company-select-previous
[escape] 'company-abort
[escape] (λ (company-abort) (evil-normal-state 1))
"<C-return>" 'helm-company)
(:map company-search-map
"C-n" 'company-search-repeat-forward
"C-p" 'company-search-repeat-backward
[escape] 'company-abort))
[escape] 'company-search-abort))
(:after help-mode
(:map help-mode-map
@ -354,67 +332,67 @@
;; Restores "dumb" indentation to the tab key. This rustles a lot of
;; peoples' jimmies, apparently, but it's how I like it.
(bind! :i "<tab>" 'narf/dumb-indent
:i "<C-tab>" 'indent-for-tab-command
(map! :i "<tab>" 'narf/dumb-indent
:i "<C-tab>" 'indent-for-tab-command
;; No dumb-tab for lisp
:i :map lisp-mode-map [remap narf/dumb-indent] 'indent-for-tab-command
:i :map emacs-lisp-mode-map [remap narf/dumb-indent] 'indent-for-tab-command
;; No dumb-tab for lisp
:i :map lisp-mode-map [remap narf/dumb-indent] 'indent-for-tab-command
:i :map emacs-lisp-mode-map [remap narf/dumb-indent] 'indent-for-tab-command
;; Highjacks space/backspace to:
;; a) delete spaces on either side of the cursor, if present ( | ) -> (|)
;; b) allow backspace to delete space-indented blocks intelligently
;; c) and not do any of this magic when inside a string
:i "SPC" 'narf/inflate-space-maybe
:i [remap backward-delete-char-untabify] 'narf/deflate-space-maybe
:i [remap newline] 'narf/newline-and-indent
;; Highjacks space/backspace to:
;; a) delete spaces on either side of the cursor, if present ( | ) -> (|)
;; b) allow backspace to delete space-indented blocks intelligently
;; c) and not do any of this magic when inside a string
:i "SPC" 'narf/inflate-space-maybe
:i [remap backward-delete-char-untabify] 'narf/deflate-space-maybe
:i [remap newline] 'narf/newline-and-indent
;; Smarter move-to-beginning-of-line
:i [remap move-beginning-of-line] 'narf/move-to-bol
;; Smarter move-to-beginning-of-line
:i [remap move-beginning-of-line] 'narf/move-to-bol
;; Restore bash-esque keymaps in insert mode; C-w and C-a already exist
:i "C-e" 'narf/move-to-eol
:i "C-u" 'narf/backward-kill-to-bol-and-indent
;; Restore bash-esque keymaps in insert mode; C-w and C-a already exist
:i "C-e" 'narf/move-to-eol
:i "C-u" 'narf/backward-kill-to-bol-and-indent
;; Fixes delete
:i "<kp-delete>" 'delete-char
;; Fixes delete
:i "<kp-delete>" 'delete-char
;; Fix osx keymappings and then some
:i "<M-left>" 'narf/move-to-bol
:i "<M-right>" 'narf/move-to-eol
:i "<M-up>" 'beginning-of-buffer
:i "<M-down>" 'end-of-buffer
:i "<C-up>" 'smart-up
:i "<C-down>" 'smart-down
;; Fix osx keymappings and then some
:i "<M-left>" 'narf/move-to-bol
:i "<M-right>" 'narf/move-to-eol
:i "<M-up>" 'beginning-of-buffer
:i "<M-down>" 'end-of-buffer
:i "<C-up>" 'smart-up
:i "<C-down>" 'smart-down
;; Fix emacs motion keys
:i "A-b" 'evil-backward-word-begin
:i "A-w" 'evil-forward-word-begin
:i "A-e" 'evil-forward-word-end
;; Fix emacs motion keys
:i "A-b" 'evil-backward-word-begin
:i "A-w" 'evil-forward-word-begin
:i "A-e" 'evil-forward-word-end
;; Textmate-esque insert-line before/after
:i "<M-return>" 'evil-open-below
:i "<S-M-return>" 'evil-open-above
;; insert lines in-place)
:n "<M-return>" (λ (save-excursion (evil-insert-newline-below)))
:n "<S-M-return>" (λ (save-excursion (evil-insert-newline-above)))
;; Textmate-esque insert-line before/after
:i "<M-return>" 'evil-open-below
:i "<S-M-return>" 'evil-open-above
;; insert lines in-place)
:n "<M-return>" (λ (save-excursion (evil-insert-newline-below)))
:n "<S-M-return>" (λ (save-excursion (evil-insert-newline-above)))
;; Make ESC quit all the things
:e [escape] 'narf-minibuffer-quit
(:map (minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map
minibuffer-local-isearch-map)
[escape] 'narf-minibuffer-quit)
;; Make ESC quit all the things
:e [escape] 'narf-minibuffer-quit
(:map (minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map
minibuffer-local-isearch-map)
[escape] 'narf-minibuffer-quit)
:map read-expression-map "C-w" 'backward-kill-word)
:map read-expression-map "C-w" 'backward-kill-word)
(bind! :i "A-o" (λ (insert "ø"))
:i "A-O" (λ (insert "Ø"))
(map! :i "A-o" (λ (insert "ø"))
:i "A-O" (λ (insert "Ø"))
:i "A--" (λ (insert ""))
:i "A-_" (λ (insert "")))
:i "A--" (λ (insert ""))
:i "A-_" (λ (insert "")))
;; Disable the global drag-mouse map; clicking in new buffers often sends evil
;; into visual mode, which is UN...ACCEPTAABBLLLEEEE!