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: Michael Heerdegen
Subject: Re: trunk r116285: * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Symbols don't start
Date: Tue, 11 Feb 2014 13:55:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Dmitry Gutov <address@hidden> writes:

> 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.

Whether a macro evaluates arguments isn't a question of obfuscation.
Depending on circumstances, it's a necessity.

> `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>"))

I really don't think this is a good idea.  This would break completion
inside macros.  In any case, there are symbols I want to complete that
are not boundp, like keywords, tags, faces etc, also when they appear in
quoted structures.  Generally it's impossible to say how a symbol will
be used in LISP.  `lisp--form-quoted-p' does only work inside balanced
parentheses.  IMHO, having some false positives is less problematic than
breaking completion in some cases.

Maybe consider making the behavior customizable, so everybody can get
what he wants.

Michael.




reply via email to

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