From 9bb0500ca8e1d6ec865b555bf36dfc677247bf95 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Thu, 5 Feb 2015 22:55:56 -0500 Subject: [PATCH] Improve helm micro-state bind actions to numbers add custom variable spacemaces-helm-micro-state-color `l` and `h` are now used to got the next/previous source --- doc/DOCUMENTATION.md | 14 ++++++++++++-- spacemacs/packages.el | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/doc/DOCUMENTATION.md b/doc/DOCUMENTATION.md index d5cca0d19..b955937ab 100644 --- a/doc/DOCUMENTATION.md +++ b/doc/DOCUMENTATION.md @@ -972,13 +972,23 @@ will turn-off the micro-state). Key Binding | Description --------------------|------------------------------------------------------------ TAB | initiate the micro-state +1 | execute action 0 +2 | execute action 1 +3 | execute action 2 +4 | execute action 3 +5 | execute action 4 +6 | execute action 5 +7 | execute action 6 +8 | execute action 7 +9 | execute action 8 +0 | execute action 9 a | switch to actions page g | go to first candidate G | go to last candidate -h | go to previous page +h | go to previous source j | select next candidate k | select previous candidate -l | go to next page +l | go to next source r | switch to actions page and leave the micro-state (useful combined with TAB) t | mark current candidate T | mark all candidates diff --git a/spacemacs/packages.el b/spacemacs/packages.el index 38cbacb54..321bf8bb9 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -1148,11 +1148,12 @@ which require an initialization must be listed explicitly in the list.") (use-package helm :defer t :init - (setq helm-split-window-in-side-p nil - helm-bookmark-show-location t - helm-buffers-fuzzy-matching t - helm-always-two-windows t) - (evil-leader/set-key + (progn + (setq helm-split-window-in-side-p nil + helm-bookmark-show-location t + helm-buffers-fuzzy-matching t + helm-always-two-windows t) + (evil-leader/set-key dotspacemacs-command-key 'helm-M-x "bs" 'helm-mini "sl" 'helm-semantic-or-imenu @@ -1163,12 +1164,16 @@ which require an initialization must be listed explicitly in the list.") "rm" 'helm-all-mark-rings "fh" 'helm-find-files "fr" 'helm-recentf - "" 'helm-apropos - ) + "" 'helm-apropos) + (defcustom spacemacs-helm-micro-state-color (face-attribute + 'error :foreground) + "Background color of helm header when helm micro-state is activated." + :type 'color + :group 'spacemacs)) + :config (progn (helm-mode +1) - ;; alter helm-bookmark key bindings to be simpler (defun simpler-helm-bookmark-keybindings () (define-key helm-bookmark-map (kbd "C-d") 'helm-bookmark-run-delete) @@ -1208,8 +1213,9 @@ which require an initialization must be listed explicitly in the list.") "Set a temporary overlay map to navigate in a helm buffer." (interactive) (set-face-attribute - 'helm-header nil :background (face-attribute - 'error :foreground)) + 'helm-header nil + :background spacemacs-helm-micro-state-color) + ;; deactivate TAB during the micro-state (any key can be used to exit ;; the micro-state but this one seems to be a better choice so it ;; deserves a special treatment) @@ -1217,16 +1223,21 @@ which require an initialization must be listed explicitly in the list.") (define-key helm-map (kbd "") '(lambda () (interactive))) ;; "r" switches to the action buffer and exit the micro-state (define-key helm-map "r" 'helm-select-action) + ;; bind actions on numbers starting from 1 which executes action 0 + (dotimes (n 10) + (define-key helm-map (number-to-string n) + `(lambda () (interactive) (helm-select-nth-action + ,(% (+ n 9) 10))))) (set-temporary-overlay-map (let ((map (make-sparse-keymap))) (define-key map "?" 'helm-help) (define-key map "a" 'helm-select-action) (define-key map "g" 'helm-beginning-of-buffer) (define-key map "G" 'helm-end-of-buffer) - (define-key map "h" 'helm-previous-page) + (define-key map "h" 'helm-previous-source) (define-key map "j" 'helm-next-line) (define-key map "k" 'helm-previous-line) - (define-key map "l" 'helm-next-page) + (define-key map "l" 'helm-next-source) (define-key map "t" 'helm-toggle-visible-mark) (define-key map "T" 'helm-toggle-all-marks) (define-key map "v" 'helm-execute-persistent-action) @@ -1241,10 +1252,12 @@ which require an initialization must be listed explicitly in the list.") (define-key helm-map (kbd "") 'spacemacs/helm-navigation-micro-state) (define-key helm-map "r" nil) + (dotimes (n 10) + (define-key helm-map (number-to-string n) nil)) ;; restore faces (set-face-attribute - 'helm-header nil :background (face-attribute - 'header-line :background))) + 'helm-header nil + :background (face-attribute 'header-line :background))) (spacemacs/on-exit-helm-micro-state)) (eval-after-load "helm-mode" ; required