aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDmitry Gutov2014-02-06 03:22:38 +0200
committerDmitry Gutov2014-02-06 03:22:38 +0200
commita333e4d29764e8f086a9fdeeb17c060a5d06d6dc (patch)
tree1322123c2999c0ca969dd68ce6f6155b3e51bfd3 /lisp
parent06c2ec49462474205dbd79a5dbd96bf73367d949 (diff)
downloademacs-a333e4d29764e8f086a9fdeeb17c060a5d06d6dc.tar.gz
emacs-a333e4d29764e8f086a9fdeeb17c060a5d06d6dc.zip
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')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/lisp.el2
-rw-r--r--lisp/minibuffer.el26
3 files changed, 35 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5ce9ab4913c..571f9547279 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12014-02-06 Dmitry Gutov <dgutov@yandex.ru>
2
3 * emacs-lisp/lisp.el (lisp-completion-at-point): Use
4 `completion-table-merge' instead of `completion-table-in-turn'
5 (bug#16604).
6
7 * minibuffer.el (completion-table-merge): New function.
8
12014-02-05 Michael Albinus <michael.albinus@gmx.de> 92014-02-05 Michael Albinus <michael.albinus@gmx.de>
2 10
3 * net/tramp-sh.el (tramp-end-of-heredoc): New defconst. 11 * net/tramp-sh.el (tramp-end-of-heredoc): New defconst.
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 3ff4f64d24c..716df8a4cca 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -830,7 +830,7 @@ considered."
830 ;; use it to provide a more specific completion table in some 830 ;; use it to provide a more specific completion table in some
831 ;; cases. E.g. filter out keywords that are not understood by 831 ;; cases. E.g. filter out keywords that are not understood by
832 ;; the macro/function being called. 832 ;; the macro/function being called.
833 (list nil (completion-table-in-turn 833 (list nil (completion-table-merge
834 lisp--local-variables-completion-table 834 lisp--local-variables-completion-table
835 obarray) ;Could be anything. 835 obarray) ;Could be anything.
836 :annotation-function 836 :annotation-function
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."
388 "Create a completion table that tries each table in TABLES in turn." 388 "Create a completion table that tries each table in TABLES in turn."
389 ;; FIXME: the boundaries may come from TABLE1 even when the completion list 389 ;; FIXME: the boundaries may come from TABLE1 even when the completion list
390 ;; is returned by TABLE2 (because TABLE1 returned an empty list). 390 ;; is returned by TABLE2 (because TABLE1 returned an empty list).
391 ;; Same potential problem if any of the tables use quoting.
391 (lambda (string pred action) 392 (lambda (string pred action)
392 (completion--some (lambda (table) 393 (completion--some (lambda (table)
393 (complete-with-action action table string pred)) 394 (complete-with-action action table string pred))
394 tables))) 395 tables)))
395 396
397(defun completion-table-merge (&rest tables)
398 "Create a completion table that collects completions from all TABLES."
399 ;; FIXME: same caveats as in `completion-table-in-turn'.
400 (lambda (string pred action)
401 (cond
402 ((null action)
403 (let ((retvals (mapcar (lambda (table)
404 (try-completion string table pred))
405 tables)))
406 (if (member string retvals)
407 string
408 (try-completion string
409 (mapcar (lambda (value)
410 (if (eq value t) string value))
411 (delq nil retvals))
412 pred))))
413 ((eq action t)
414 (apply #'append (mapcar (lambda (table)
415 (all-completions string table pred))
416 tables)))
417 (t
418 (completion--some (lambda (table)
419 (complete-with-action action table string pred))
420 tables)))))
421
396(defun completion-table-with-quoting (table unquote requote) 422(defun completion-table-with-quoting (table unquote requote)
397 ;; A difficult part of completion-with-quoting is to map positions in the 423 ;; A difficult part of completion-with-quoting is to map positions in the
398 ;; quoted string to equivalent positions in the unquoted string and 424 ;; quoted string to equivalent positions in the unquoted string and