summaryrefslogtreecommitdiff
path: root/helm-misc.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-12-07 16:38:44 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-12-07 19:56:30 +0100
commit77853cca050f9239c46a607f140de2bf3423be83 (patch)
treee55e191fe770797f68efcd6f0636ff23f8701e14 /helm-misc.el
parent097ce9e789e91f5ed1461e4379f3e785738a6cfe (diff)
Use helm-comp-read in helm-minibuffer-history (#1650).
Remove helm-source-minibuffer-history. * helm-misc.el (helm-minibuffer-history-must-match): New user var. (helm-minibuffer-history): Use it. Prevent using minibuffer history outside minibuffer. * helm-mode.el (helm-comp-read): Add new keyword arguments allow-nest, header-name and multiline.
Diffstat (limited to 'helm-misc.el')
-rw-r--r--helm-misc.el52
1 files changed, 28 insertions, 24 deletions
diff --git a/helm-misc.el b/helm-misc.el
index 33876bd0..338b226c 100644
--- a/helm-misc.el
+++ b/helm-misc.el
@@ -201,26 +201,13 @@ It is added to `extended-command-history'.
(define-key map [remap helm-minibuffer-history] 'undefined)
map))
-(defvar helm-source-minibuffer-history
- (helm-build-sync-source "Minibuffer History"
- :header-name (lambda (name)
- (format "%s (%s)" name minibuffer-history-variable))
- :candidates
- (lambda ()
- (cl-loop for i in
- (symbol-value minibuffer-history-variable)
- unless (string= "" i) collect i into history
- finally return
- (if (consp (car history))
- (mapcar 'prin1-to-string history)
- history)))
- :keymap helm-minibuffer-history-map
- :migemo t
- :multiline t
- :action (lambda (candidate)
- (with-helm-current-buffer
- (delete-minibuffer-contents)
- (insert candidate)))))
+(defcustom helm-minibuffer-history-must-match t
+ "Allow inserting non matching elements when nil or 'confirm."
+ :group 'helm-misc
+ :type '(choice
+ (const :tag "Must match" t)
+ (const :tag "Confirm" 'confirm)
+ (const :tag "Always allow" nil)))
;;; Shell history
;;
@@ -327,10 +314,27 @@ Default action change TZ environment variable locally to emacs."
(defun helm-minibuffer-history ()
"Preconfigured `helm' for `minibuffer-history'."
(interactive)
- (let ((enable-recursive-minibuffers t))
- (helm :sources 'helm-source-minibuffer-history
- :buffer "*helm minibuffer-history*"
- :allow-nest t)))
+ (cl-assert (minibuffer-window-active-p (selected-window)) nil
+ "Error: Attempt to use minibuffer history outside a minibuffer")
+ (let ((enable-recursive-minibuffers t)
+ (elm (helm-comp-read "pattern: "
+ (cl-loop for i in
+ (symbol-value minibuffer-history-variable)
+ unless (string= "" i) collect i into history
+ finally return
+ (if (consp (car history))
+ (mapcar 'prin1-to-string history)
+ history))
+ :header-name
+ (lambda (name)
+ (format "%s (%s)" name minibuffer-history-variable))
+ :buffer "*helm minibuffer-history*"
+ :must-match helm-minibuffer-history-must-match
+ :multiline t
+ :keymap helm-minibuffer-history-map
+ :allow-nest t)))
+ (delete-minibuffer-contents)
+ (insert elm)))
;;;###autoload
(defun helm-comint-input-ring ()