emacs-devel
[Top][All Lists]
Advanced

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

Re: trunk r116285: * lisp/emacs-lisp/lisp.el (lisp-completion-at-point):


From: Dmitry Gutov
Subject: Re: trunk r116285: * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Symbols don't start
Date: Tue, 11 Feb 2014 05:43:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 07.02.2014 00:00, Stefan Monnier wrote:
Yes, except that "a quote before BEG" is not sufficient.
We could/should also check if one of the parent open-parens is prefixed
with a quote or a backquote, and only allow boundp if not.

Ok to install?

This doesn't handle macros, but most of them don't try to obfuscate whether a given form is evaluated or not, at least well-behaving ones.

`defadvice', ideally, would have to be handled specially anyway, to limit completions to functions.


=== modified file 'lisp/emacs-lisp/lisp.el'
--- lisp/emacs-lisp/lisp.el     2014-02-10 01:34:22 +0000
+++ lisp/emacs-lisp/lisp.el     2014-02-11 03:36:20 +0000
@@ -752,6 +752,20 @@
                      (mapcar #'symbol-name (lisp--local-variables))))))
          lastvars)))))

+(defun lisp--form-quoted-p ()
+  "Return non-nil if the form after point is not evaluated.
+It can be quoted, or be inside a quoted form.
+This function moves point."
+  ;; FIXME: Do some macro expansion maybe.
+  (or (eq (char-after) ?\[)
+      (progn
+        (skip-chars-backward " ")
+        (memq (char-before) '(?' ?`)))
+      (and (not (eq (char-before) ?,))
+           (ignore-errors
+             (up-list -1)
+             (lisp--form-quoted-p)))))
+
 ;; FIXME: Support for Company brings in features which straddle eldoc.
 ;; We should consolidate this, so that major modes can provide all that
 ;; data all at once:
@@ -835,12 +849,16 @@
                            lisp--local-variables-completion-table
(apply-partially #'completion-table-with-predicate
                                             obarray
-                                            ;; Don't include all symbols
-                                            ;; (bug#16646).
-                                            (lambda (sym)
-                                              (or (boundp sym)
-                                                  (fboundp sym)
-                                                  (symbol-plist sym)))
+                                            (if (save-excursion
+                                                  (goto-char beg)
+                                                  (lisp--form-quoted-p))
+ ;; Don't include all symbols
+                                                ;; (bug#16646).
+                                                (lambda (sym)
+                                                  (or (boundp sym)
+                                                      (fboundp sym)
+                                                      (symbol-plist sym)))
+                                              #'boundp)
                                             'strict))
                       :annotation-function
(lambda (str) (if (fboundp (intern-soft str)) " <f>"))





reply via email to

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