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: Generalizing find-definition Date: Fri, 12 Dec 2014 07:05:00 +0200 Message-ID: <548A777C.7000409@yandex.ru> References: <20141102151524.0d9c665c@forcix> <877fymghgb.fsf@bredband.net> <85ppc0qf9a.fsf@stephe-leake.org> <85zjb3o09d.fsf@stephe-leake.org> <85tx1amnyg.fsf@stephe-leake.org> <85egsem1u2.fsf@stephe-leake.org> <867fy0or7p.fsf@yandex.ru> <86ppbqn841.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1418360753 4417 80.91.229.3 (12 Dec 2014 05:05:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Dec 2014 05:05:53 +0000 (UTC) Cc: Helmut Eller , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 12 06:05:46 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 1XzIQD-0002Lv-Jr for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 06:05:45 +0100 Original-Received: from localhost ([::1]:55529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzIQD-00086A-1z for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 00:05:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzIPh-00085p-3F for emacs-devel@gnu.org; Fri, 12 Dec 2014 00:05:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzIPY-0000iP-1n for emacs-devel@gnu.org; Fri, 12 Dec 2014 00:05:13 -0500 Original-Received: from mail-wg0-x22c.google.com ([2a00:1450:400c:c00::22c]:60626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzIPX-0000i3-Qf for emacs-devel@gnu.org; Fri, 12 Dec 2014 00:05:03 -0500 Original-Received: by mail-wg0-f44.google.com with SMTP id b13so8134469wgh.17 for ; Thu, 11 Dec 2014 21:05:03 -0800 (PST) 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=9k2GLLrb7GTJesDu7ApCkmtjW6XapZhXffA4cNMagqo=; b=urSI2b6L7ntp/pL/TR/KJBqq8Ob0/MC43CaR/Gu/yOOeohvkBzOoIlnjH9n5pAwySW tY8gSYOE99gnXnuVZX/qa8lL8fb2JlnFcgxLdfumyJU2nv3w1ZQB2burwaOVjwNPLbNA i68ty9UXxg8GggaXDq7GMYLxW0HJjTbyOtFfVFSBsbN2TYUqCxQH3B9naBXQcuuwAjla gc7w4EP6LtHlAv+M36Q0GF5fU0CmboiVhEQsLzRM2xodOR/IEvjuWp53uPPphmsE/gQk YcLaSB+acu8IAH2PRzJ7Fyy9kaH/n0MKQjgDv2tz22osMZ/NJVHmQlq0j+dPk8hkTbW7 1z+w== X-Received: by 10.194.121.167 with SMTP id ll7mr22765474wjb.26.1418360703221; Thu, 11 Dec 2014 21:05:03 -0800 (PST) Original-Received: from [192.168.1.2] ([82.102.93.58]) by mx.google.com with ESMTPSA id hn2sm349119wjc.5.2014.12.11.21.05.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Dec 2014 21:05:02 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.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:c00::22c 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:179863 Archived-At: On 12/11/2014 05:07 PM, Stefan Monnier wrote: > (add-function :around (local xref-backend) #'elisp-xref-backend) Okay, thanks for the reminder about nadvice. I guess with this approach to function inheritance, there would be a different, bare-bones default value of xref-find-function, because I don't think I want to delegate to etags-xref-find from elisp-xref-find (and all other backends). Anyway, having a separate xref-identifier-at-point-function should solve this problem in a different way. > This should be called `xref-backend-function', to follow usual practice. Right, thanks. > Rename xref--xref to xref-xref, since it's clearly part of the API. Or we can keep the class name private, and document that the function should return a list of xref values, using `xref-make'. > A few comments: > - As discussed earlier, `read-identifier' is probably a bad idea. > Replace it with a `completion-table' method, so the completing-read is > not in the backend but in xref.el. Ok, apparently I missed some things in the older thread. > - identifier-at-point should document more clearly that the return value > may be something else than a string. AFAIK the only interesting > non-string non-nil case is to return a special value (e.g. a marker > or just `t' to stand to (point)) which stands for "let the > find-definitions code figure out the identifier at that place". > - If we restrict identifier to "a string or nil or t", then we can get > rid of identifier-to-string. All right, let's go with this, until a better idea comes up. But note that AFAIK 99% of the time the identifier at point and prefix+suffix used by completion-at-point will be one and the same. Maybe it will make sense to unify these: for example, by naming the function identifier-bounds, and requiring it to return the beginning and the end of the identifier. This pair of numbers (or maybe markers) would be useful to both find-definition functions that expect a string (just call buffer-substring beforehand), as well as those that need a buffer position. > a single backend function, but adding the other methods makes it > scream "I want to use OO", just like completion-tables do. I wasn't aware they're considered a bad design already. :) That API is complicated, but not just because a function has many calling conventions. > then we need to split `xref-backend' into several variables: > - xref-find-function (can be used both for the `definitions' and for > the `references'). > - xref-identifier-at-point-function. > - xref-identifier-completion-table. Ok. (I should send the updated patch tonight).