From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#2544: 23.0.60; Could etags please try find a local tag first? Date: Tue, 27 Jul 2021 02:15:30 +0300 Message-ID: References: <7f9b11c90903021336o775a3f75i8bd89f3ae4540cb7@mail.gmail.com> <878s22nyuj.fsf@gnus.org> <8335sa70wp.fsf@gnu.org> <417d5d01-c3a9-a75e-b134-7f1847749842@yandex.ru> <83lf615hfk.fsf@gnu.org> <838s206i0a.fsf@gnu.org> <4a8bb24b-51cd-f82b-c8ff-f57d3576eff1@yandex.ru> <87mtqglzlu.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------0D69128AB50EFEA28DEFFABC" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34270"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Cc: matzikratzi@gmail.com, 2544@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 27 01:16:09 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m89pR-0008p5-Mk for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Jul 2021 01:16:09 +0200 Original-Received: from localhost ([::1]:53368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m89pQ-0001hJ-OS for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Jul 2021 19:16:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m89pK-0001h2-Nc for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2021 19:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m89pK-0005X6-FE for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2021 19:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m89pK-0003I0-BN for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2021 19:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Jul 2021 23:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 2544 X-GNU-PR-Package: emacs Original-Received: via spool by 2544-submit@debbugs.gnu.org id=B2544.162734134412617 (code B ref 2544); Mon, 26 Jul 2021 23:16:02 +0000 Original-Received: (at 2544) by debbugs.gnu.org; 26 Jul 2021 23:15:44 +0000 Original-Received: from localhost ([127.0.0.1]:51724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m89p2-0003HR-0p for submit@debbugs.gnu.org; Mon, 26 Jul 2021 19:15:44 -0400 Original-Received: from mail-ej1-f48.google.com ([209.85.218.48]:35540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m89ow-0003HA-P7 for 2544@debbugs.gnu.org; Mon, 26 Jul 2021 19:15:42 -0400 Original-Received: by mail-ej1-f48.google.com with SMTP id o5so19128419ejy.2 for <2544@debbugs.gnu.org>; Mon, 26 Jul 2021 16:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=RcKgwxLgnj68gY1XtIpf4tc1OA4DOItbOM8FQZYpSa0=; b=E27aQ5OKpBF4HQy+suoWm7Wnc4uEE2CWX+ugX+hiwiNgC1jJE5+tOH8/LBBAyMe1fP VFvNF3WNwf6mGOS1hab1XWapFpX4G1tL7BeRO2n6msEYWzIRq1PIEFOb12ctJpM/XtEq Rc9C1hzqpTZ+mcNLwVCuX45iQbZFWhVC+2mvZzkT7G5ozrL8V7kalB53gWUf+k+bQPNE kL/jC3C6KR7+OHTvZf8HdtfuL880O9Hz4mN6m3MT2fHBG8hmkiekD+rEby+3gamTzEqd qVQNpyZPdgnSz9pOb3YikIcxktvVaZGmkItjztQHAehHExeg8rbMP0z8zEtzfe8N5Jz1 YslQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=RcKgwxLgnj68gY1XtIpf4tc1OA4DOItbOM8FQZYpSa0=; b=Z5H6wm5aRvcpmOGcHsirjk9pSbN1LdR7Z/fW7XdC0SvLxYqp3Mgz10gUKDu4V+qkz+ elD+r4V+TJDVUE+Ib+dcAonaBN74Y3mBHBqyVEe3IveQRVM1fypLXhpp9ORlauKSK+7I WRYyER78RGvXKmHHAMz8xb0XTKHSzQDeSTit7EFo2jyZ9hMRFiu4IZNKtnV5anckrOFa c6988tcsemrA0wIEjickmtxnAmAfa1fCAz/WYC9wikwylJm5PlQiZK1jtaNS2K0hyFea pQuXr3VC5fVfTnz9v25nYVHkBL95riJSHIgGWYxoTXQSQ95c5rDlb5zdrnfnghCX0Ee0 5KZA== X-Gm-Message-State: AOAM5300dUSJ6z73yjRojDSNjau8WddXerBY2eL4lO3ge7mPaZsSiQM0 WcRJPzY3d2fbbhWUoCQcifIGPh48jts= X-Google-Smtp-Source: ABdhPJwYLU2XNz1v6qtuoyKeNfvSwZOWaTlyQXv//dFeDwhI8a4iHI1GdEXW+Wo8PNhBI69t7xxq5A== X-Received: by 2002:a17:906:b1d3:: with SMTP id bv19mr19169518ejb.47.1627341332925; Mon, 26 Jul 2021 16:15:32 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id i6sm487859edt.28.2021.07.26.16.15.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jul 2021 16:15:32 -0700 (PDT) In-Reply-To: <87mtqglzlu.fsf@gnus.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210772 Archived-At: This is a multi-part message in MIME format. --------------0D69128AB50EFEA28DEFFABC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 21.07.2021 13:39, Lars Ingebrigtsen wrote: > The problem is definitely much more noticeable in the etags backend, so > if your judgement is that that's where the option (and sorting) should > go, then please go ahead.:-) Here's a rough patch. Please test and send feedback (how well it works, variable naming, docstring, etc). --------------0D69128AB50EFEA28DEFFABC Content-Type: text/x-patch; charset=UTF-8; name="etags-xref-prioritize-same-file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="etags-xref-prioritize-same-file.diff" diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index f0180ceeec..2af160be74 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -2059,6 +2059,10 @@ etags-xref-find-definitions-tag-order If you want `xref-find-definitions' to find the tagged files by their file name, add `tag-partial-file-name-match-p' to the list value.") +(defcustom etags-xref-prioritize-same-file nil + "Non-nil to show the matches in the same file first." + :type 'boolean) + ;;;###autoload (defun etags--xref-backend () 'etags) @@ -2072,7 +2076,21 @@ xref-backend-identifier-completion-ignore-case (find-tag--completion-ignore-case)) (cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol) - (etags--xref-find-definitions symbol)) + (let ((file (and buffer-file-name (expand-file-name buffer-file-name))) + (definitions (etags--xref-find-definitions symbol)) + same-file-definitions) + (when (and etags-xref-prioritize-same-file file) + (cl-delete-if + (lambda (definition) + (when (equal file + (xref-location-group + (xref-item-location definition))) + (push definition same-file-definitions) + t)) + definitions) + (setq definitions (nconc (nreverse same-file-definitions) + definitions))) + definitions)) (cl-defmethod xref-backend-apropos ((_backend (eql etags)) pattern) (etags--xref-find-definitions (xref-apropos-regexp pattern) t)) --------------0D69128AB50EFEA28DEFFABC--