Polish helm support + add in! macro

This commit is contained in:
Henrik Lissner 2015-10-23 04:42:34 -04:00
parent 2bfe7670c2
commit 66abf1522c
3 changed files with 52 additions and 41 deletions

View file

@ -28,6 +28,11 @@ during compilation."
'with-no-warnings) 'with-no-warnings)
(with-eval-after-load ',feature ,@forms))) (with-eval-after-load ',feature ,@forms)))
(defmacro in! (dir &rest forms)
(declare (indent defun))
`(let ((default-directory ,dir))
,@forms))
(defmacro add-hook! (hook &rest func-or-forms) (defmacro add-hook! (hook &rest func-or-forms)
"A convenience macro for `add-hook'. "A convenience macro for `add-hook'.

View file

@ -3,24 +3,27 @@
(use-package helm (use-package helm
:init :init
(defvar helm-global-prompt ">>> ") (defvar helm-global-prompt ">>> ")
(setq helm-quick-update t (setq-default
helm-reuse-last-window-split-state t helm-quick-update t
helm-reuse-last-window-split-state t
helm-buffers-fuzzy-matching t helm-buffers-fuzzy-matching t
helm-apropos-fuzzy-match t
helm-M-x-fuzzy-match t
helm-recentf-fuzzy-match t
;; helm-mode-fuzzy-match t
helm-ff-auto-update-initial-value t helm-ff-auto-update-initial-value nil
helm-find-files-doc-header nil helm-find-files-doc-header nil
helm-candidate-number-limit 30 helm-candidate-number-limit 30
helm-bookmark-show-location t helm-bookmark-show-location t
;; let popwin handle this ;; let popwin handle this
helm-split-window-default-side 'other helm-split-window-default-side 'other
helm-split-window-preferred-function 'narf/helm-split-window) helm-split-window-preferred-function 'narf/helm-split-window)
:config :config
(evil-set-initial-state 'helm-mode 'emacs) (evil-set-initial-state 'helm-mode 'emacs)
(helm-adaptive-mode 1)
;; Rewrite prompt for all helm windows ;; Rewrite prompt for all helm windows
(defun helm (&rest plist) (defun helm (&rest plist)
(let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest)) (let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest))
@ -59,10 +62,14 @@
"*Helm Swoop*")) "*Helm Swoop*"))
(push bufname winner-boring-buffers))) (push bufname winner-boring-buffers)))
(bind! (:map (helm-map helm-find-files-map) (bind! (:map (helm-map helm-generic-files-map helm-find-files-map)
"C-w" 'evil-delete-backward-word "C-w" 'evil-delete-backward-word
"C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious! "C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
[escape] 'helm-keyboard-quit) [escape] 'helm-keyboard-quit)
(:map helm-find-files-map
"C-w" 'helm-find-files-up-one-level
"TAB" 'helm-execute-persistent-action
"/" 'helm-execute-persistent-action)
(:map helm-ag-map (:map helm-ag-map
"<backtab>" 'helm-ag-edit) "<backtab>" 'helm-ag-edit)
(:map helm-ag-edit-map (:map helm-ag-edit-map
@ -76,6 +83,12 @@
(use-package projectile (use-package projectile
:diminish projectile-mode :diminish projectile-mode
;; :commands (helm-projectile-find-file
;; helm-projectile-find-file-in-known-projects
;; helm-projectile-find-other-file
;; helm-projectile-switch-to-buffer
;; helm-projectile-switch-project
;; helm-projectile-recentf)
:config :config
(add-hook! kill-emacs 'narf|projectile-invalidate-cache-maybe) (add-hook! kill-emacs 'narf|projectile-invalidate-cache-maybe)
@ -167,15 +180,7 @@
(use-package helm-files (use-package helm-files
:commands (helm-recentf :commands (helm-recentf
helm-buffers helm-buffers
helm-buffers-list) helm-buffers-list))
:config
(defun helm-recentf ()
"Reconfigured `helm-recentf' to use `helm', instead of `helm-other-buffer'"
(interactive)
(let ((helm-ff-transformer-show-only-basename nil))
(helm :sources '(helm-source-recentf)
:buffer "*helm recentf*"
:prompt helm-global-prompt))))
(use-package helm-css-scss ; https://github.com/ShingoFukuyama/helm-css-scss (use-package helm-css-scss ; https://github.com/ShingoFukuyama/helm-css-scss
:commands (helm-css-scss :commands (helm-css-scss
@ -197,6 +202,7 @@
(use-package helm-semantic :commands helm-semantic-or-imenu) (use-package helm-semantic :commands helm-semantic-or-imenu)
(use-package helm-elisp :commands helm-apropos) (use-package helm-elisp :commands helm-apropos)
(use-package helm-command :commands helm-M-x) (use-package helm-command :commands helm-M-x)
(use-package helm-descbinds :config (helm-descbinds-mode 1))
(provide 'core-helm) (provide 'core-helm)
;;; core-helm.el ends here ;;; core-helm.el ends here

View file

@ -77,27 +77,27 @@
;; <leader> ;; <leader>
(:prefix "," (:prefix ","
:n "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list))) :nv "," (λ (if (narf/project-p) (helm-projectile-switch-to-buffer) (helm-buffers-list)))
:n "<" 'helm-buffers-list :nv "<" 'helm-mini
:n "." 'narf/ido-find-file :nv "." 'helm-find-files
:n ">" 'narf/ido-find-file-other-window :nv ">" 'helm-projectile-find-file-in-known-projects
:n "/" 'helm-projectile-find-file :nv "/" 'helm-projectile-find-file
:n ";" 'helm-semantic-or-imenu :nv ";" 'helm-semantic-or-imenu
:nv ":" 'helm-imenu-in-all-buffers
:n "]" 'helm-etags-select :nv "]" 'helm-etags-select
:n "a" 'helm-projectile-find-other-file :nv "a" 'helm-projectile-find-other-file
:n "E" 'narf:ido-find-file-in-emacsd :nv "E" (λ (in! narf-emacs-dir (helm-projectile-find-file)))
:n "h" 'helm-apropos :nv "n" 'narf/ido-find-org-file
;; :n "n" 'narf/ido-find-org-file :nv "N" 'narf:org-search-files-or-headers
;; :n "N" 'narf:org-search-files-or-headers :nv "m" 'helm-recentf
:n "m" 'narf/ido-recentf :nv "M" 'helm-projectile-recentf ; recent PROJECT files
:n "M" 'helm-projectile-recentf ; recent PROJECT files :nv "p" 'helm-projectile-switch-project
:n "p" 'helm-projectile-switch-project :v "=" 'align-regexp
:v "=" 'align-regexp :nv "r" 'emr-show-refactor-menu
:nv "r" 'emr-show-refactor-menu
:n "qq" 'evil-save-and-quit :nv "qq" 'evil-save-and-quit
:n "QQ" 'narf/kill-all-buffers-do-not-remember :nv "QQ" 'narf/kill-all-buffers-do-not-remember
:n "oo" 'narf-open-with :n "oo" 'narf-open-with
:n "ob" (λ (narf-open-with "Google Chrome")) :n "ob" (λ (narf-open-with "Google Chrome"))