From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel 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 Message-ID: <871tz995bl.fsf@web.de> References: <87zjm4tl2b.fsf@yandex.ru> <52F99C65.5010007@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392123373 12950 80.91.229.3 (11 Feb 2014 12:56:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Feb 2014 12:56:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 11 13:56:21 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WDCsr-00051Z-L0 for ged-emacs-devel@m.gmane.org; Tue, 11 Feb 2014 13:56:17 +0100 Original-Received: from localhost ([::1]:33204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDCsr-0000ub-9v for ged-emacs-devel@m.gmane.org; Tue, 11 Feb 2014 07:56:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDCsi-0000uL-Jn for emacs-devel@gnu.org; Tue, 11 Feb 2014 07:56:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDCsc-00053t-Ds for emacs-devel@gnu.org; Tue, 11 Feb 2014 07:56:08 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:60164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDCsc-00053Z-6u for emacs-devel@gnu.org; Tue, 11 Feb 2014 07:56:02 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WDCsZ-0004uk-9F for emacs-devel@gnu.org; Tue, 11 Feb 2014 13:55:59 +0100 Original-Received: from ip-90-186-26-4.web.vodafone.de ([90.186.26.4]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Feb 2014 13:55:59 +0100 Original-Received: from michael_heerdegen by ip-90-186-26-4.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Feb 2014 13:55:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 75 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-26-4.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:KBPlD0TCavMQEEkUNMG55vVDbF4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169524 Archived-At: Dmitry Gutov 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)) " > ")) 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.