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#68958: [PATCH] Support bookmarking Xref results buffers Date: Tue, 13 Feb 2024 05:18:28 +0200 Message-ID: <653af486-3b3b-4270-8385-ee3af6639eb5@gutov.dev> References: <86le7wzcjj.fsf@gnu.org> <0b3f4669-180e-466f-96f3-7eeae994581f@gutov.dev> <1bea3fe4-51aa-418b-a55f-f09d0a4c558e@gutov.dev> 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="21391"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Eli Zaretskii , 68958@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 13 04:19:08 2024 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 1rZjK7-0005H5-Db for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Feb 2024 04:19:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZjJo-0002IH-9c; Mon, 12 Feb 2024 22:18:48 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZjJl-0002I6-M3 for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 22:18:45 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZjJl-0000je-E1 for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 22:18:45 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZjK2-00065V-4W for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 22:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Feb 2024 03:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68958 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68958-submit@debbugs.gnu.org id=B68958.170779433523383 (code B ref 68958); Tue, 13 Feb 2024 03:19:02 +0000 Original-Received: (at 68958) by debbugs.gnu.org; 13 Feb 2024 03:18:55 +0000 Original-Received: from localhost ([127.0.0.1]:38990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZjJu-000655-O3 for submit@debbugs.gnu.org; Mon, 12 Feb 2024 22:18:55 -0500 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:32935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZjJt-00064j-1U for 68958@debbugs.gnu.org; Mon, 12 Feb 2024 22:18:53 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id A78795C0109; Mon, 12 Feb 2024 22:18:30 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 12 Feb 2024 22:18:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1707794310; x=1707880710; bh=44/cVQPgC06FYU+giG1E/r4PGbUEq5Hpokk+JMHvXG4=; b= j4r+XPyvb5QSdYUCDeWFGgZEw8LVQLiWWxXZRvzZD1Pd8xJwkPCnU+fFRx7f59/4 dnGDWM7OJi4JBPv17zH1S98/qZPzy24/wXGfEAU+qlGCOLrslovbDfGacotTfpfU Clki94Gu0Qo5yertHKut07XSJXWQb//xWsqIjTAAomwZnv8AbT49moYqQt8W8k0g gd/lDD3dccFSmgNvEUmHWeNwsEOn9uOgaIvokqbSdJg1pHIBE3La1EDg2rlDMVBV UrC6+shfLIikH5lEaiZbqMgfUzzXVNUpb7G9AuIZtiMMRFLPJZ6za0Osy3ZVjtKG SP6VxgoGf+4COb4ANYmbXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707794310; x= 1707880710; bh=44/cVQPgC06FYU+giG1E/r4PGbUEq5Hpokk+JMHvXG4=; b=L p5CZALirlhBz3izwMXzhOIwveKPYcV3l+00tykuedjT/U4wtDZI83BoU4oTCW4KG IRow6dRwyAQTmItUJ0T09H3kDlzEOF3r4mnJ5XbKgPKJV+nD5AcMQhfHtuvZiRUd 299zvi8k7tLB2HKFuZ2nE4j9W0thMND4k6dtcMnF+2h2yE8c33cA+QhuBeW2npoZ rZFgSzLqSK7mfgmkRZknCAdaAuIsSVNAXyLzLDMFWQfKQVn+9YCkj6nKSk61z/57 pfMD9olHyIDAM+ykSgUHFxSfHg10KEpkyvtOey1iDxfc7A6Ox7mUevttjVaM797F B+l2JEemiEzzvOnQsNHgw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeggdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedtvddtveefhfdvveegudej heenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 22:18:29 -0500 (EST) Content-Language: en-US In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279939 Archived-At: On 12/02/2024 13:45, Eshel Yaron wrote: >> With that, the simple API "patch FETCHER and DISPLAY-ACTION (probably >> nil)" would turn into something at least twice (or 3x) as complex. > > Well, ISTM that one could also say that the API is as simple as it was: > you pass the same stuff, and get the same result. It's just that, > optionally, you can also do a bit more (set a variable inside FETCHER) > and get a bit more (bookmarking). A fair amount more: to fill out an alist, and have a new generic function implemented. > I agree that redundant complexity is > better avoided, but this is the simplest compatible extension to the API > I came up with to implement this feature. If we're going to recommend the callers use the new capability, I'd rather they didn't have to be redundant every time. >> I'm not quite convinced that being able to bookmark Xref buffers is >> worth this cost. > > Fair enough, it's your call. IMO this is a rather useful capability, > and I don't think it's that important to keep the API maximally simple > if it doesn't facilitate everything we want it to. In other words, as > long as we maintain compatibility, what's wrong with extending the API > to support more features? A more concise yet backward-compatible approach could also look like the below. Though I'm not sure whether the fetcher should reach xref-show-xrefs-function intact (simpler code, but a breakage in the interface, which could be mended with catching wrong-number-of-arguments), or like in this example, both the original fetcher and the arguments should be passed through alist. Otherwise, the requirements on the arguments are the same (fetcher -- named function, args -- printability). Also, I'm not sure how we're supposed to guarantee that xref--original-buffer is live. Is that for use with desktop-mode only? And it seems like as soon as the buffer has some new changes, the bookmark is likely to become invalid (the same value of point will point to a different identifier). Anyway, regarding that partial patch: diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 717b837a2e5..cfdb9cd72de 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1476,13 +1476,13 @@ xref--read-identifier-history (defvar xref--read-pattern-history nil) ;;;###autoload -(defun xref-show-xrefs (fetcher display-action) +(defun xref-show-xrefs (fetcher display-action &optional args) "Display some Xref values produced by FETCHER using DISPLAY-ACTION. The meanings of both arguments are the same as documented in `xref-show-xrefs-function'." - (xref--show-xrefs fetcher display-action)) + (xref--show-xrefs fetcher display-action args)) -(defun xref--show-xrefs (fetcher display-action &optional _always-show-list) +(defun xref--show-xrefs (fetcher display-action &optional _always-show-list args) (unless (functionp fetcher) ;; Old convention. (let ((xrefs fetcher)) @@ -1494,12 +1494,16 @@ xref--show-xrefs xrefs (setq xrefs 'called-already))))))) (let ((cb (current-buffer)) - (pt (point))) - (prog1 + (pt (point)) + (orig-fetcher fetcher)) + (when args (setq fetcher (lambda () (apply fetcher args)))) + (prog1 (funcall xref-show-xrefs-function fetcher `((window . ,(selected-window)) (display-action . ,display-action) - (auto-jump . ,xref-auto-jump-to-first-xref))) + (auto-jump . ,xref-auto-jump-to-first-xref) + (orig-fetcher . ,orig-fetcher) + (fetcher-args . ,args))) (xref--push-markers cb pt)))) (defun xref--show-defs (xrefs display-action)