branch: externals/consult commit e0bd3c0293b1792da34e0d288a958748f67fc1a1 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add consult--to-list --- consult.el | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/consult.el b/consult.el index b06ff08..a794c6f 100644 --- a/consult.el +++ b/consult.el @@ -1066,8 +1066,7 @@ FACE is the cursor face." "Normalize PREVIEW-KEY, return alist of keys and debounce times." (let ((keys) (debounce 0)) - (unless (listp preview-key) - (setq preview-key (list preview-key))) + (setq preview-key (consult--to-list preview-key)) (while preview-key (if (eq (car preview-key) :debounce) (setq debounce (cadr preview-key) @@ -1595,6 +1594,10 @@ The refresh happens after a DELAY, defaulting to `consult-async-refresh-delay'." "Filter candidates of ASYNC by FUN." (consult--async-transform async seq-filter fun)) +(defun consult--to-list (list) + "Ensure that LIST is a list." + (if (listp list) list (list list))) + (defun consult--command-args (cmd) "Split command arguments and append to CMD." (setq cmd (split-string-and-unquote cmd)) @@ -1660,13 +1663,9 @@ ASYNC must be non-nil for async completion functions." (delete-dups (append ;; the defaults are at the beginning of the future history - (if (listp minibuffer-default) - minibuffer-default - (list minibuffer-default)) + (consult--to-list minibuffer-default) ;; then our custom items - (remove "" (remq nil (if (listp items) - items - (list items)))) + (remove "" (remq nil (consult--to-list items))) ;; Add all the completions for non-async commands. For async commands this feature ;; is not useful, since if one selects a completion candidate, the async search is ;; restarted using that candidate string. This usually does not yield a desired @@ -1915,7 +1914,7 @@ INHERIT-INPUT-METHOD, if non-nil the minibuffer inherits the input method." (let ((key (if (plist-member src :preview-key) (plist-get src :preview-key) consult-preview-key))) - (if (listp key) key (list key)))) + (consult--to-list key))) sources)))) (defun consult--multi-lookup (sources _ candidates cand) @@ -3638,7 +3637,7 @@ AS is a conversion function." (when sort (setq buffers (funcall (intern (format "consult--buffer-sort-%s" sort)) buffers))) (when (or filter mode as (stringp root)) - (let ((mode (if (listp mode) mode (list mode))) + (let ((mode (consult--to-list mode)) (exclude-re (consult--regexp-filter exclude)) (include-re (consult--regexp-filter include))) (consult--keep! buffers