bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#16604: 24.3.50; False negatives in lisp-completion-at-point


From: Dmitry Gutov
Subject: bug#16604: 24.3.50; False negatives in lisp-completion-at-point
Date: Sun, 02 Feb 2014 03:52:30 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Is it okay to install the following patch?

On a related note, company-capf returns nil to `duplicates', but with the patch below, for example, I do receive duplicates from it. And with another, functional completion table I wrote in a third-party package. Should I change `duplicates' to t?

=== modified file 'lisp/emacs-lisp/lisp.el'
--- lisp/emacs-lisp/lisp.el     2014-01-01 07:43:34 +0000
+++ lisp/emacs-lisp/lisp.el     2014-02-02 01:42:32 +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'
--- lisp/minibuffer.el  2014-01-07 23:36:29 +0000
+++ lisp/minibuffer.el  2014-02-02 01:46:41 +0000
@@ -393,6 +393,27 @@
                         (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 caveat as in `completion-table-in-turn', only harder
+  ;; to fix.
+  (lambda (string pred action)
+    (cond
+     ((null action)
+      (try-completion string
+                      (mapcar (lambda (table)
+                                (try-completion string table pred))
+                              tables)
+                      pred))
+     ((eq action t)
+      (apply #'append (mapcar (lambda (table)
+                                (all-completions string table pred))
+                              tables)))
+     ((not (or (eq (car-safe action) 'boundaries)
+               (eq action 'metadata)))
+ (completion--some (lambda (table) (test-completion string table 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]