emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116279: Define and use `completion-table-merge'


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r116279: Define and use `completion-table-merge'
Date: Thu, 06 Feb 2014 01:22:46 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116279
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/16604
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Thu 2014-02-06 03:22:38 +0200
message:
  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'.
modified:
  doc/lispref/minibuf.texi       
minibuf.texi-20091113204419-o5vbwnq5f7feedwu-6199
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/lisp.el        lisp.el-20091113204419-o5vbwnq5f7feedwu-131
  lisp/minibuffer.el             
minibuffer.el-20091113204419-o5vbwnq5f7feedwu-8622
=== modified file 'doc/lispref/minibuf.texi'
--- a/doc/lispref/minibuf.texi  2014-01-05 23:36:13 +0000
+++ b/doc/lispref/minibuf.texi  2014-02-06 01:22:38 +0000
@@ -889,6 +889,7 @@
 @c FIXME?  completion-table-with-context?
 @findex completion-table-case-fold
 @findex completion-table-in-turn
address@hidden completion-table-merge
 @findex completion-table-subvert
 @findex completion-table-with-quoting
 @findex completion-table-with-predicate
@@ -897,9 +898,10 @@
 @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
address@hidden 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

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2014-02-05 11:45:01 +0000
+++ b/etc/NEWS  2014-02-06 01:22:38 +0000
@@ -2200,6 +2200,12 @@
 *** 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'.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-02-05 14:11:50 +0000
+++ b/lisp/ChangeLog    2014-02-06 01:22:38 +0000
@@ -1,3 +1,11 @@
+2014-02-06  Dmitry Gutov  <address@hidden>
+
+       * 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  <address@hidden>
 
        * net/tramp-sh.el (tramp-end-of-heredoc): New defconst.

=== modified file 'lisp/emacs-lisp/lisp.el'
--- a/lisp/emacs-lisp/lisp.el   2014-01-01 07:43:34 +0000
+++ b/lisp/emacs-lisp/lisp.el   2014-02-06 01:22:38 +0000
@@ -830,7 +830,7 @@
                 ;; 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
                            lisp--local-variables-completion-table
                            obarray)       ;Could be anything.
                       :annotation-function

=== modified file 'lisp/minibuffer.el'
--- a/lisp/minibuffer.el        2014-01-07 23:36:29 +0000
+++ b/lisp/minibuffer.el        2014-02-06 01:22:38 +0000
@@ -388,11 +388,37 @@
   "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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]