Helm: prompt hacks and refactor

This commit is contained in:
Henrik Lissner 2014-12-07 15:13:48 -05:00
parent 7d8c577f7c
commit 29ce34cc55

View file

@ -14,12 +14,6 @@
(my--cleanup-buffers-add "^\\*[Hh]elm.*\\*$")
(bind helm-map
(kbd "C-w") 'evil-delete-backward-word
(kbd "C-u") 'helm-delete-minibuffer-contents
(kbd "C-r") 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
[escape] 'helm-keyboard-quit)
(evil-ex-define-cmd "a" 'helm-projectile-find-other-file)
(evil-ex-define-cmd "proj[ect]" 'helm-projectile-switch-project)
(evil-ex-define-cmd "ag" 'my:helm-ag-search)
@ -83,24 +77,18 @@
helm-swoop-speed-or-color t
helm-swoop-split-window-function 'popwin:popup-buffer)
(after "helm-css-scss"
;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or
;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is
;; `scss-mode'
(evil-define-command my:helm-swoop (&optional search bang)
:repeat nil
(interactive "<a><!>")
(if (eq major-mode 'scss-mode)
(if bang (helm-css-scss-multi search) (helm-css-scss search))
(if bang (helm-multi-swoop-all search) (helm-swoop :$query search)))))))
;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or
;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is
;; `scss-mode'
(evil-define-command my:helm-swoop (&optional search bang)
:repeat nil
(interactive "<a><!>")
(if (eq major-mode 'scss-mode)
(if bang (helm-css-scss-multi search) (helm-css-scss search))
(if bang (helm-multi-swoop-all search) (helm-swoop :$query search))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(after "projectile"
(use-package helm-projectile
:config
(setq projectile-switch-project-action 'helm-projectile)))
(after "winner"
;; Tell winner-mode to ignore helm buffers
(dolist (bufname '("*helm recentf*"
@ -126,11 +114,37 @@
:prompt helm-global-prompt
:candidate-number-limit helm-company-candidate-number-limit)))))
(progn ; helm hacks
(after "projectile"
(use-package helm-projectile
:config
(setq projectile-switch-project-action 'helm-projectile))
;; Don't show the project name in the prompts; I already know.
(defun projectile-prepend-project-name (string)
(format helm-global-prompt string))
;; All this for a smaller prompt (it was redundant with helm headers)
(defmacro helm-projectile-command (command source prompt)
`(defun ,(intern (concat "helm-projectile-" command)) (&optional arg)
(interactive "P")
(if (projectile-project-p)
(projectile-maybe-invalidate-cache arg))
(let ((helm-ff-transformer-show-only-basename nil)
;; for consistency, we should just let Projectile take care of ignored files
(helm-boring-file-regexp-list nil))
(helm :sources ,source
:buffer "*helm projectile*"
:prompt helm-global-prompt))))
(helm-projectile-command "switch-project" 'helm-source-projectile-projects helm-global-prompt)
(helm-projectile-command "find-file" helm-source-projectile-files-and-dired-list helm-global-prompt)
(helm-projectile-command "find-file-in-known-projects" 'helm-source-projectile-files-in-all-projects-list helm-global-prompt)
(helm-projectile-command "find-file-dwim" 'helm-source-projectile-files-dwim-list helm-global-prompt)
(helm-projectile-command "find-dir" helm-source-projectile-directories-and-dired-list helm-global-prompt)
(helm-projectile-command "recentf" 'helm-source-projectile-recentf-list helm-global-prompt)
(helm-projectile-command "switch-to-buffer" 'helm-source-projectile-buffers-list helm-global-prompt))
(progn ; helm hacks
;; No persistent header
(defadvice helm-display-mode-line (after undisplay-header activate)
(setq header-line-format nil))
@ -163,8 +177,6 @@
(propertize (concat " " hlstr hlend) 'face 'helm-header))))
(when force (force-mode-line-update))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(progn ; popwin
(push '("^\\*helm.*\\*$" :position bottom :regexp t :height 18)
popwin:special-display-config))
@ -178,4 +190,10 @@
(evil-define-command my:helm-recentf (&optional bang)
:repeat nil
(interactive "<!>")
(if bang (helm-recentf) (helm-projectile-recentf))))))
(if bang (helm-recentf) (helm-projectile-recentf))))
(bind helm-map
"C-w" 'evil-delete-backward-word
"C-u" 'helm-delete-minibuffer-contents
"C-r" 'evil-ex-paste-from-register ; Evil registers in helm! Glorious!
[escape] 'helm-keyboard-quit)))