mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 02:51:31 -08:00
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
This commit is contained in:
parent
06c2ec4946
commit
a333e4d297
5 changed files with 46 additions and 4 deletions
|
|
@ -889,6 +889,7 @@ Here is an example:
|
||||||
@c FIXME? completion-table-with-context?
|
@c FIXME? completion-table-with-context?
|
||||||
@findex completion-table-case-fold
|
@findex completion-table-case-fold
|
||||||
@findex completion-table-in-turn
|
@findex completion-table-in-turn
|
||||||
|
@findex completion-table-merge
|
||||||
@findex completion-table-subvert
|
@findex completion-table-subvert
|
||||||
@findex completion-table-with-quoting
|
@findex completion-table-with-quoting
|
||||||
@findex completion-table-with-predicate
|
@findex completion-table-with-predicate
|
||||||
|
|
@ -897,9 +898,10 @@ Here is an example:
|
||||||
@cindex completion tables, combining
|
@cindex completion tables, combining
|
||||||
There are several functions that take an existing completion table and
|
There are several functions that take an existing completion table and
|
||||||
return a modified version. @code{completion-table-case-fold} returns
|
return a modified version. @code{completion-table-case-fold} returns
|
||||||
a case-insensitive table. @code{completion-table-in-turn} combines
|
a case-insensitive table. @code{completion-table-in-turn} and
|
||||||
multiple input tables. @code{completion-table-subvert} alters a table
|
@code{completion-table-merge} combine multiple input tables in
|
||||||
to use a different initial prefix. @code{completion-table-with-quoting}
|
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.
|
returns a table suitable for operating on quoted text.
|
||||||
@code{completion-table-with-predicate} filters a table with a
|
@code{completion-table-with-predicate} filters a table with a
|
||||||
predicate function. @code{completion-table-with-terminator} adds a
|
predicate function. @code{completion-table-with-terminator} adds a
|
||||||
|
|
|
||||||
6
etc/NEWS
6
etc/NEWS
|
|
@ -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
|
*** New function `completion-table-subvert' to use an existing completion
|
||||||
table, but with a different prefix.
|
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
|
** Debugger
|
||||||
|
|
||||||
*** New error type and new function `user-error'.
|
*** New error type and new function `user-error'.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
2014-02-06 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
|
* emacs-lisp/lisp.el (lisp-completion-at-point): Use
|
||||||
|
`completion-table-merge' instead of `completion-table-in-turn'
|
||||||
|
(bug#16604).
|
||||||
|
|
||||||
|
* minibuffer.el (completion-table-merge): New function.
|
||||||
|
|
||||||
2014-02-05 Michael Albinus <michael.albinus@gmx.de>
|
2014-02-05 Michael Albinus <michael.albinus@gmx.de>
|
||||||
|
|
||||||
* net/tramp-sh.el (tramp-end-of-heredoc): New defconst.
|
* 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
|
;; use it to provide a more specific completion table in some
|
||||||
;; cases. E.g. filter out keywords that are not understood by
|
;; cases. E.g. filter out keywords that are not understood by
|
||||||
;; the macro/function being called.
|
;; the macro/function being called.
|
||||||
(list nil (completion-table-in-turn
|
(list nil (completion-table-merge
|
||||||
lisp--local-variables-completion-table
|
lisp--local-variables-completion-table
|
||||||
obarray) ;Could be anything.
|
obarray) ;Could be anything.
|
||||||
:annotation-function
|
:annotation-function
|
||||||
|
|
|
||||||
|
|
@ -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."
|
"Create a completion table that tries each table in TABLES in turn."
|
||||||
;; FIXME: the boundaries may come from TABLE1 even when the completion list
|
;; FIXME: the boundaries may come from TABLE1 even when the completion list
|
||||||
;; is returned by TABLE2 (because TABLE1 returned an empty 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)
|
(lambda (string pred action)
|
||||||
(completion--some (lambda (table)
|
(completion--some (lambda (table)
|
||||||
(complete-with-action action table string pred))
|
(complete-with-action action table string pred))
|
||||||
tables)))
|
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)
|
(defun completion-table-with-quoting (table unquote requote)
|
||||||
;; A difficult part of completion-with-quoting is to map positions in the
|
;; A difficult part of completion-with-quoting is to map positions in the
|
||||||
;; quoted string to equivalent positions in the unquoted string and
|
;; quoted string to equivalent positions in the unquoted string and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue