summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2014-02-06 03:22:38 +0200
committerDmitry Gutov <dgutov@yandex.ru>2014-02-06 03:22:38 +0200
commita333e4d29764e8f086a9fdeeb17c060a5d06d6dc (patch)
tree1322123c2999c0ca969dd68ce6f6155b3e51bfd3 /lisp/minibuffer.el
parent06c2ec49462474205dbd79a5dbd96bf73367d949 (diff)
downloademacs-a333e4d29764e8f086a9fdeeb17c060a5d06d6dc.tar.gz
Define and use `completion-table-merge'
* lisp/minibuffer.el (completion-table-merge): New function. * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Use `completion-table-merge' instead of `completion-table-in-turn'. Fixes: debbugs:16604
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c87fcc1c3ea..105075524bf 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -388,11 +388,37 @@ Note: TABLE needs to be a proper completion table which obeys predicates."
"Create a completion table that tries each table in TABLES in turn."
;; FIXME: the boundaries may come from TABLE1 even when the completion list
;; is returned by TABLE2 (because TABLE1 returned an empty list).
+ ;; Same potential problem if any of the tables use quoting.
(lambda (string pred action)
(completion--some (lambda (table)
(complete-with-action action table string pred))
tables)))
+(defun completion-table-merge (&rest tables)
+ "Create a completion table that collects completions from all TABLES."
+ ;; FIXME: same caveats as in `completion-table-in-turn'.
+ (lambda (string pred action)
+ (cond
+ ((null action)
+ (let ((retvals (mapcar (lambda (table)
+ (try-completion string table pred))
+ tables)))
+ (if (member string retvals)
+ string
+ (try-completion string
+ (mapcar (lambda (value)
+ (if (eq value t) string value))
+ (delq nil retvals))
+ pred))))
+ ((eq action t)
+ (apply #'append (mapcar (lambda (table)
+ (all-completions string table pred))
+ tables)))
+ (t
+ (completion--some (lambda (table)
+ (complete-with-action action table string pred))
+ tables)))))
+
(defun completion-table-with-quoting (table unquote requote)
;; A difficult part of completion-with-quoting is to map positions in the
;; quoted string to equivalent positions in the unquoted string and