all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <871tz995bl.fsf@web.de> (raw)
In-Reply-To: 52F99C65.5010007@yandex.ru

Dmitry Gutov <dgutov@yandex.ru> 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	other threads:[~2014-02-11 12:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1WBHeS-0000wr-6k@vcs.savannah.gnu.org>
2014-02-06 13:41 ` trunk r116285: * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Symbols don't start Dmitry Gutov
2014-02-06 22:00   ` Stefan Monnier
2014-02-07  3:16     ` Michael Heerdegen
2014-02-07 13:22       ` Stefan Monnier
2014-02-11  3:43     ` Dmitry Gutov
2014-02-11 12:55       ` Michael Heerdegen [this message]
2014-02-11 14:47         ` Dmitry Gutov
2014-02-12 11:14           ` Michael Heerdegen
2014-02-13  5:13             ` Dmitry Gutov
2014-02-13  7:36               ` Michael Heerdegen
2014-02-13 13:33               ` Stefan Monnier
2014-02-14  3:48                 ` Dmitry Gutov
2014-02-12  1:42       ` Stefan Monnier
2014-02-13  5:21         ` Dmitry Gutov
2014-02-13 12:56           ` Michael Heerdegen
2014-02-13 14:32             ` 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=871tz995bl.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=emacs-devel@gnu.org \
    /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.