all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 16604@debbugs.gnu.org
Subject: bug#16604: 24.3.50; False negatives in lisp-completion-at-point
Date: Tue, 04 Feb 2014 07:37:06 +0200	[thread overview]
Message-ID: <52F07C82.4080707@yandex.ru> (raw)
In-Reply-To: <jwvha8htlyf.fsf-monnier+emacsbugs@gnu.org>

On 02.02.2014 20:24, Stefan Monnier wrote:
> The behavior I'm looking for in completion-at-point should probably be
> obtained more along the lines of what is done in file-name completion
> where completion-ignored-extensions is used before calling
> try-completion.

I'm not sure I understand. Would there be a variable defining a regexp 
or glob for variable and function names that will be ignored unless they 
are the only candidates?

 > Also, we should try and check that the sub-tables all have "trivial"
boundaries, and no quoting.

Do we do that at "runtime" (after the lambda has been returned)? And 
just blow up calls with action `metadata' or `boundaries . ...' with 
error whenever that's not true?

I figured just documenting problematic cases might be enough (like 
`completion-table-in-turn' does, I suppose it has a similar problem with 
quoting).

 > Also, the outer try-completion could end up returning t if one of the
inner ones returns the string we're trying to complete.
We might be better off always going through "(apply #'append (mapcar
#'all-completions ...))", e.g. via completion-table-dynamic.

Sounds not very efficient. See the updated patch, does this look right 
to you?

I have a hard time testing it, though. lisp-completion-at-point seems to 
suggest any symbols that I've ever typed anyway, so there's no way to 
check that lisp--local-variables-completion-table is even used.


=== 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-04 05:25:30 +0000
@@ -393,6 +393,36 @@
                          (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)
+      (let ((retvals (mapcar (lambda (table)
+                               (try-completion string table pred))
+                             tables))
+            (prelim (try-completion string retvals pred)))
+        (cond
+         ((and (stringp prelim) (not (memq t retvals))) prelim)
+         ((null prelim) (and (memq t retvals) t))
+         ;; Here `prelim' is either t, and that means there's at least
+         ;; one string in `retvals', and all of them are equal to
+         ;; STRING.
+         ;; Or `prelim' is a string, but there's a `t' in `retvals',
+         ;; which means those matches won't all match `prelim'.
+         (t string))))
+     ((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







  parent reply	other threads:[~2014-02-04  5:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31  4:46 bug#16604: 24.3.50; False negatives in lisp-completion-at-point Dmitry Gutov
2014-01-31 14:34 ` Stefan Monnier
2014-01-31 14:37   ` Dmitry Gutov
2014-01-31 15:05   ` Thierry Volpiatto
2014-02-02  1:52   ` Dmitry Gutov
2014-02-02  2:39     ` Stefan Monnier
2014-02-02  3:00       ` Dmitry Gutov
2014-02-02 14:12         ` Stefan Monnier
2014-02-02 18:24           ` Stefan Monnier
2014-02-03  2:03             ` Stefan Monnier
2014-02-03  3:48               ` Stefan Monnier
2014-02-04  5:37             ` Dmitry Gutov [this message]
2014-02-04 17:54               ` Stefan Monnier
2014-02-05  4:41                 ` Dmitry Gutov
2014-02-05 13:53                   ` Stefan Monnier
2014-02-06  1:38                     ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F07C82.4080707@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=16604@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.