diff options
-rw-r--r-- | helm-global-bindings.el | 26 | ||||
-rw-r--r-- | helm-misc.el | 61 | ||||
-rw-r--r-- | helm-mode.el | 7 |
3 files changed, 66 insertions, 28 deletions
diff --git a/helm-global-bindings.el b/helm-global-bindings.el index 1f4dd044..008e5ad0 100644 --- a/helm-global-bindings.el +++ b/helm-global-bindings.el @@ -17,32 +17,6 @@ ;;; Code: -(defcustom helm-minibuffer-history-key "C-r" - "The key `helm-minibuffer-history' is bound to in minibuffer local maps." - :type '(choice (string :tag "Key") (const :tag "no binding")) - :group 'helm-misc - :set - (lambda (var key) - (cl-dolist (map '(minibuffer-local-completion-map - minibuffer-local-filename-completion-map - minibuffer-local-filename-must-match-map ; Emacs 23.1.+ - minibuffer-local-isearch-map - minibuffer-local-map - minibuffer-local-must-match-filename-map ; Older Emacsen - minibuffer-local-must-match-map - minibuffer-local-ns-map)) - (let ((vmap (and (boundp map) (symbol-value map)))) - (when (keymapp vmap) - (let ((val (and (boundp var) (symbol-value var)))) - (when val - (define-key vmap - (if (stringp val) (read-kbd-macro val) val) - nil))) - (when key - (define-key (symbol-value map) - (if (stringp key) (read-kbd-macro key) key) - 'helm-minibuffer-history))))) - (set var key))) ;;; Command Keymap ;; diff --git a/helm-misc.el b/helm-misc.el index 4a2bbf79..ffcc9c15 100644 --- a/helm-misc.el +++ b/helm-misc.el @@ -205,6 +205,67 @@ It is added to `extended-command-history'. (const :tag "Confirm" 'confirm) (const :tag "Always allow" nil))) +(defcustom helm-minibuffer-history-key "C-r" + "The key `helm-minibuffer-history' is bound to in minibuffer local maps." + :type '(choice (string :tag "Key") (const :tag "no binding")) + :group 'helm-mode) + +(defconst helm-minibuffer-history-old-key + (cl-loop for map in '(minibuffer-local-completion-map + minibuffer-local-filename-completion-map + minibuffer-local-filename-must-match-map ; Emacs 23.1.+ + minibuffer-local-isearch-map + minibuffer-local-map + minibuffer-local-must-match-filename-map ; Older Emacsen + minibuffer-local-must-match-map + minibuffer-local-ns-map) + collect (cons map (lookup-key (symbol-value map) "\C-r")))) + +;;;###autoload +(define-minor-mode helm-minibuffer-history-mode + "Bind `helm-minibuffer-history-key' in al minibuffer maps. +This mode is enabled by `helm-mode', so there is no need to enable it directly." + :group 'helm-misc + :global t + (if helm-minibuffer-history-mode + (let ((key helm-minibuffer-history-key)) + (cl-dolist (map '(minibuffer-local-completion-map + minibuffer-local-filename-completion-map + minibuffer-local-filename-must-match-map ; Emacs 23.1.+ + minibuffer-local-isearch-map + minibuffer-local-map + minibuffer-local-must-match-filename-map ; Older Emacsen + minibuffer-local-must-match-map + minibuffer-local-ns-map)) + (let ((vmap (and (boundp map) (symbol-value map)))) + (when (keymapp vmap) + (let ((val (and (boundp 'helm-minibuffer-history-key) + (symbol-value 'helm-minibuffer-history-key)))) + (when val + (define-key vmap + (if (stringp val) (read-kbd-macro val) val) + nil))) + (when key + (define-key (symbol-value map) + (if (stringp key) (read-kbd-macro key) key) + 'helm-minibuffer-history)))))) + (cl-dolist (map '(minibuffer-local-completion-map + minibuffer-local-filename-completion-map + minibuffer-local-filename-must-match-map + minibuffer-local-isearch-map + minibuffer-local-map + minibuffer-local-must-match-filename-map + minibuffer-local-must-match-map + minibuffer-local-ns-map)) + (let ((vmap (and (boundp map) (symbol-value map)))) + (when (keymapp vmap) + (let ((val (and (boundp 'helm-minibuffer-history-key) + (symbol-value 'helm-minibuffer-history-key)))) + (when val + (define-key vmap + (if (stringp val) (read-kbd-macro val) val) + (assoc-default map helm-minibuffer-history-old-key))))))))) + ;;; Helm ratpoison UI ;; diff --git a/helm-mode.el b/helm-mode.el index e6a65c52..b904796c 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -21,6 +21,7 @@ (require 'helm) (require 'helm-lib) (require 'helm-files) +(require 'helm-misc) (defvar crm-separator) (defvar ido-everywhere) @@ -2138,7 +2139,8 @@ Note: This mode is incompatible with Emacs23." ;; emacs-27 and `ffap-read-file-or-url' is fixed, so no need ;; to advice it. (advice-add 'ffap-read-file-or-url :override #'helm-advice--ffap-read-file-or-url)) - (advice-add 'read-buffer-to-switch :override #'helm-mode--read-buffer-to-switch)) + (advice-add 'read-buffer-to-switch :override #'helm-mode--read-buffer-to-switch) + (helm-minibuffer-history-mode 1)) (progn (remove-function completing-read-function #'helm--completing-read-default) (remove-function read-file-name-function #'helm--generic-read-file-name) @@ -2147,7 +2149,8 @@ Note: This mode is incompatible with Emacs23." (remove-hook 'ido-everywhere-hook #'helm-mode--ido-everywhere-hook) (when (fboundp 'ffap-read-file-or-url-internal) (advice-remove 'ffap-read-file-or-url #'helm-advice--ffap-read-file-or-url)) - (advice-remove 'read-buffer-to-switch #'helm-mode--read-buffer-to-switch)))) + (advice-remove 'read-buffer-to-switch #'helm-mode--read-buffer-to-switch) + (helm-minibuffer-history-mode -1)))) (provide 'helm-mode) |