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#44294: No widen by xref-find-definitions Date: Thu, 29 Oct 2020 23:33:44 +0200 Message-ID: References: <87mu06p1aw.fsf_-_@mail.linkov.net> <5cfcbbf0-beef-3c0a-9641-a010925dbda4@yandex.ru> <87r1pgivdz.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28184"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 44294@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 29 22:34:16 2020 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 1kYFYm-0007E0-0Z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 22:34:16 +0100 Original-Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYFYl-0003B6-2Y for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 17:34:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYFYY-00039M-Ku for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYFYY-0002lY-BI for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kYFYY-0004Dt-94 for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:34: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: Thu, 29 Oct 2020 21:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44294 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed patch Original-Received: via spool by 44294-submit@debbugs.gnu.org id=B44294.160400723416219 (code B ref 44294); Thu, 29 Oct 2020 21:34:02 +0000 Original-Received: (at 44294) by debbugs.gnu.org; 29 Oct 2020 21:33:54 +0000 Original-Received: from localhost ([127.0.0.1]:55135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFYQ-0004DX-Fu for submit@debbugs.gnu.org; Thu, 29 Oct 2020 17:33:54 -0400 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:37065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFYP-0004DL-Et for 44294@debbugs.gnu.org; Thu, 29 Oct 2020 17:33:53 -0400 Original-Received: by mail-ed1-f48.google.com with SMTP id o18so4573268edq.4 for <44294@debbugs.gnu.org>; Thu, 29 Oct 2020 14:33:53 -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:content-transfer-encoding; bh=Z/ht5Z3+22S0tVBhPFVi/uxEbx4SdXeo4wZAElhuqDo=; b=X+xLcxW8E89oVbliICAFVtybvdYYpinGO5GOnj7XMuD/Omc3wEEELEDRz9BnkjlRS1 Uyab30HKoO2biOY0shR9niExIHuhYqyMD7DiYupMGljyLIYjcNMJ5ISDCZlhipfkMaOV hHLZZuoRUn6XkLoeWYvvt2UgE0GhBLzqKeENt52ykbrLvCPly3JVgA7P9mDpv3syGHuo FRYo9Ouzxm4zpfKverZw9kB74xJP+inpldJPwvcv+Za4Fcu9HY2HU3lxPn1QcRZYUw6P Z+XrWr9X7zukoZ/38ICmeuLQ6+yaeI1zzZ4Wt2C25EPQbPevz1TIgFBN/gywcqGD104+ 3c2A== 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 :content-transfer-encoding; bh=Z/ht5Z3+22S0tVBhPFVi/uxEbx4SdXeo4wZAElhuqDo=; b=BqJffXopRr+vVyKNrV8uEdV56KRvWW9Y85KQDdhnJL0vPthqmaT29Ytwoho9z5XcRW 8/4YtT8pa6LKZ3oqKm04qtstgAbOGGvssKV8QJMb0pLKizv2UA0LTC+J/6JT6rdEG2oI D5M9Qz26bj+kLuzc4nP7cMM6xjG65PjAc8JUPZbYohEN8TRY6MWWa4hQB81x95XK1J+2 nAC3+yqh71BS5Tl1y63VkSZBS9yJIFtkc2H9KWliSv+JA2txhuUl1GQEabVFL46TT6LF B0Vh8hocuF76IubJ7Oes4mFoqsoQ1e7puT/GgcCG38u/xLetXuFO8Ul+sEwwjxZ13we/ +oFg== X-Gm-Message-State: AOAM533zF+bN5DcBZCaw58Hx/ObZV4MLldByDyn3DnE83PbG5m4lyiqM t24TgmBbyLuf1MXSGeDKbDUExlad/CNEYw== X-Google-Smtp-Source: ABdhPJwcaqd/KqngU3xoxLcF9Sx3ctyzF8IwGoRvtAqXMpIBEH4OOHs+oy7xX9pKHNzHxrV0WLvyNg== X-Received: by 2002:a05:6402:17e4:: with SMTP id t4mr6342782edy.118.1604007227265; Thu, 29 Oct 2020 14:33:47 -0700 (PDT) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id p18sm2242334edt.23.2020.10.29.14.33.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 14:33:46 -0700 (PDT) In-Reply-To: <87r1pgivdz.fsf@mail.linkov.net> 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:192005 Archived-At: On 29.10.2020 23:18, Juri Linkov wrote: > reopen 44294 > stop > >>> - (user-error "Rerun etags: `%s' not found in %s" >>> - pat buffer-file-name))) >>> + (if (or (= (point-min) 1) (not widen-automatically)) >>> + (user-error "Rerun etags: `%s' not found in %s" >>> + pat buffer-file-name) >>> + ;; Rerun after removing narrowing >>> + (widen) >>> + (etags-goto-tag-location tag-info)))) >> >> By the way... have you tried to use the same method here as in elisp-mode? >> Meaning, widen unconditionally inside 'save-restriction'. >> >> There should be no reason for backends to do it differently. And this way, >> you don't have to always search twice for a missing tag when inside >> a narrowing. > > It should not widen unnecessarily when the found position is within the > narrowed region. Hence the use of save-restriction in elisp-mode which you added. etags can use the exact same approach. > In this regard, xref--goto-char does the right thing: Yes. > (defun xref--goto-char (pos) > (cond > ((and (<= (point-min) pos) (<= pos (point-max)))) > (widen-automatically (widen)) > (t (user-error "Position is outside accessible part of buffer"))) > (goto-char pos)) > > It widens only when position is outside accessible part of buffer > (and widen-automatically is non-nil). And this code runs whether the backend is elisp, etags, or whatever else.