Commit a333e4d2 authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

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
parent 06c2ec49
......@@ -889,6 +889,7 @@ Here is an example:
@c FIXME? completion-table-with-context?
@findex completion-table-case-fold
@findex completion-table-in-turn
@findex completion-table-merge
@findex completion-table-subvert
@findex completion-table-with-quoting
@findex completion-table-with-predicate
......@@ -897,9 +898,10 @@ Here is an example:
@cindex completion tables, combining
There are several functions that take an existing completion table and
return a modified version. @code{completion-table-case-fold} returns
a case-insensitive table. @code{completion-table-in-turn} combines
multiple input tables. @code{completion-table-subvert} alters a table
to use a different initial prefix. @code{completion-table-with-quoting}
a case-insensitive table. @code{completion-table-in-turn} and
@code{completion-table-merge} combine multiple input tables in
different ways. @code{completion-table-subvert} alters a table to use
a different initial prefix. @code{completion-table-with-quoting}
returns a table suitable for operating on quoted text.
@code{completion-table-with-predicate} filters a table with a
predicate function. @code{completion-table-with-terminator} adds a
......@@ -2200,6 +2200,12 @@ in the presence of quoting, such as file completion in shell buffers.
*** New function `completion-table-subvert' to use an existing completion
table, but with a different prefix.
*** New function `completion-table-with-cache' is a wrapper for
`completion-table-dynamic' that caches the result of the last lookup.
*** New function `completion-table-merge' to combine several
completion tables by merging their completions.
** Debugger
*** New error type and new function `user-error'.
2014-02-06 Dmitry Gutov <>
* emacs-lisp/lisp.el (lisp-completion-at-point): Use
`completion-table-merge' instead of `completion-table-in-turn'
* minibuffer.el (completion-table-merge): New function.
2014-02-05 Michael Albinus <>
* net/tramp-sh.el (tramp-end-of-heredoc): New defconst.
......@@ -830,7 +830,7 @@ considered."
;; use it to provide a more specific completion table in some
;; cases. E.g. filter out keywords that are not understood by
;; the macro/function being called.
(list nil (completion-table-in-turn
(list nil (completion-table-merge
obarray) ;Could be anything.
......@@ -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))
(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)
((null action)
(let ((retvals (mapcar (lambda (table)
(try-completion string table pred))
(if (member string retvals)
(try-completion string
(mapcar (lambda (value)
(if (eq value t) string value))
(delq nil retvals))
((eq action t)
(apply #'append (mapcar (lambda (table)
(all-completions string table pred))
(completion--some (lambda (table)
(complete-with-action action table string pred))
(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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment