From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: xref backends for elisp-related modes Was: Re: Bad moves with xref-find-definitions Date: Sun, 26 Apr 2015 16:56:43 +0300 Message-ID: <553CEE9B.9000702@yandex.ru> References: <87h9s6c27z.fsf@gmail.com> <87zj5wnlyt.fsf@gmail.com> <553C285B.4070400@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1430056632 14435 80.91.229.3 (26 Apr 2015 13:57:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Apr 2015 13:57:12 +0000 (UTC) Cc: Vitalie Spinu , Stefan Monnier , emacs-devel@gnu.org To: joaotavora@gmail.com (João Távora) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 26 15:57:07 2015 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 1YmN3R-0004Dw-N8 for ged-emacs-devel@m.gmane.org; Sun, 26 Apr 2015 15:57:05 +0200 Original-Received: from localhost ([::1]:50918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmN3R-0002sf-14 for ged-emacs-devel@m.gmane.org; Sun, 26 Apr 2015 09:57:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmN3N-0002ps-6r for emacs-devel@gnu.org; Sun, 26 Apr 2015 09:57:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmN3J-0000Fu-WE for emacs-devel@gnu.org; Sun, 26 Apr 2015 09:57:01 -0400 Original-Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:36145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmN3J-0000Aw-PW for emacs-devel@gnu.org; Sun, 26 Apr 2015 09:56:57 -0400 Original-Received: by wizk4 with SMTP id k4so71147458wiz.1 for ; Sun, 26 Apr 2015 06:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=T+Er4jw/+TSkSDresK/mIJ4Xp7+X5lC7V5cicoclRhk=; b=vlqLTLu00hOB9FGmNkpXF42/P2S9FQETRetIHr9swCUWkdwslRbxDxHdJ4VxahEYWo RLC+o7IU3cmHt4V0OzR2b2waznNqDkuauiTjHyGU8aWGAjHuENAVOtjqhbV2VPgxVq5N 9aNjeVTeGRbU8fIfZrN8vuWn13wZX/SbdTFkU/Q7NcwyFZIL3kIGi7z+OB9bzwoLaJpX gs4OBHa9f3p42KDmHx4o15sZ1/IK0D+q6N/ABrv5P+LM2wr2d9YtgIRZjS6BRf7pscsc otJUVNeZcFjJxavqRDWLrKhRkRRUIInzoKVkamVqnjzLHqUY03kjwxIJjc5V5bS9Iw2o p6Hw== X-Received: by 10.194.223.66 with SMTP id qs2mr14668988wjc.6.1430056607750; Sun, 26 Apr 2015 06:56:47 -0700 (PDT) Original-Received: from [192.168.1.2] ([82.102.93.54]) by mx.google.com with ESMTPSA id ln8sm25218360wjc.18.2015.04.26.06.56.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Apr 2015 06:56:47 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::229 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:185908 Archived-At: On 04/26/2015 02:51 PM, joaotavora@gmail.com (João Távora) wrote: > BTW the necessary level of indirection is already present with > `advice-add': we needn't necessarily add more variables. I mean: > > (advice-add 'elisp-xref-find :override #'etags-xref-find) Looks good enough to me. Indeed, maybe xref-etags-mode should be replaced by a function that applies these advices. > Should be enough and quite readable. Conversely, I wouldn't be very > annoyed if etags were the default method of finding elisp xrefs. Then I > would use advice-add to set my behaviour, perhaps by doing I think elisp-xref-find is a better default. > (advice-add 'elisp-xref-find :override > #'elisp-compiled-identifier-locations) ; better name pending This cannot be done globally (or it'll affect all buffers). > Additionally, if `add-function' allowed `:append' for its WHERE arg, > like Common Lisp's method combinations, it would be even cleaner to get > the behaviour desired by Eli (and Vitalie, I think), of multiple > backends. > > (advice-add 'elisp-xref-find :append #'etags-xref-find) a: If we want it to do appending, that could be implemented in `elisp-xref-find'. Or there could be a variant of it doing that. b: This doesn't deal with duplicates, which I think is the main problem if we were to go that way. > It does, I know, but it would be a lot simpler, especially for functions > spawning *Help* buffers, to just assume we're in an elisp-related > context. Packages like SLIME or SLY or CIDER that make use of these > major modes should be the ones overriding the backend. Can we be sure that languages using the default backend (etags) and expecting it to work in their help buffers, will be a negligible minority? > +(defun elisp--setup-xref-backend () > + (setq-local xref-find-function #'elisp-xref-find) > + (setq-local xref-identifier-completion-table-function > + #'elisp--xref-identifier-completion-table)) Shouldn't this also include the dynamic declarations removed from `emacs-lisp-mode'?