summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helm-mode.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/helm-mode.el b/helm-mode.el
index 92a3570b..bb9a1f8b 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -513,7 +513,10 @@ If COLLECTION is an `obarray', a TEST should be needed. See `obarray'."
;; Don't convert
;; nil to "nil" (i.e the string)
;; it will be delq'ed on top.
- collect (if (null d) d (helm-stringify d)))
+ for str = (if (null d) d (helm-stringify d))
+ when (member str cands)
+ do (setq cands (delete d cands))
+ when str collect str)
cands))
(t cands))))
@@ -1048,16 +1051,18 @@ This handler uses dynamic matching which allows honouring `completion-styles'."
init hist default inherit-input-method
name buffer standard)))
+(defun helm-read-buffer-to-switch (prompt)
+ (let ((minibuffer-completion-table (internal-complete-buffer-except)))
+ (read-buffer prompt (other-buffer (current-buffer))
+ (confirm-nonexistent-file-or-buffer))))
+
(defun helm--generic-read-buffer (prompt &optional default require-match predicate)
"The `read-buffer-function' for `helm-mode'.
Affects `switch-to-buffer' `kill-buffer' and related."
- ;; Use `internal-complete-buffer-except' as default collection,
- ;; assuming `switch-to-buffer' doesn't need the current buffer and
- ;; `kill-buffer' add it on top of completion list. This may be
- ;; wrong in other functions, but lets use this as there is no better
- ;; solutions to abstract this for now.
(helm--completing-read-default
- prompt (internal-complete-buffer-except) predicate require-match nil nil default))
+ prompt (or minibuffer-completion-table
+ (internal-complete-buffer "" nil t))
+ predicate require-match nil nil default))
(cl-defun helm--completing-read-default
(prompt collection &optional
@@ -2015,7 +2020,8 @@ Note: This mode is incompatible with Emacs23."
;; `ffap-read-file-or-url-internal' have been removed in
;; 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 'ffap-read-file-or-url :override #'helm-advice--ffap-read-file-or-url))
+ (advice-add 'read-buffer-to-switch :override #'helm-read-buffer-to-switch))
(progn
(remove-function completing-read-function #'helm--completing-read-default)
(remove-function read-file-name-function #'helm--generic-read-file-name)
@@ -2023,7 +2029,8 @@ Note: This mode is incompatible with Emacs23."
(remove-function completion-in-region-function #'helm--completion-in-region)
(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 'ffap-read-file-or-url #'helm-advice--ffap-read-file-or-url))
+ (advice-remove 'read-buffer-to-switch #'helm-read-buffer-to-switch))))
(provide 'helm-mode)