GNU bug report logs - #46992
xref-after-update-hook

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 7 Mar 2021 18:52:02 UTC

Severity: wishlist

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46992 in the body.
You can then email your comments to 46992 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46992; Package emacs. (Sun, 07 Mar 2021 18:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 07 Mar 2021 18:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: xref-after-update-hook
Date: Sun, 07 Mar 2021 20:50:25 +0200
[Message part 1 (text/plain, inline)]
Version: 28.0.50
Severity: wishlist
Tags: patch

As suggested in https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00161.html
here is a patch that adds such hook:

[xref-after-update-hook.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..ba4e48faf8 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -415,6 +415,10 @@ xref-after-return-hook
   "Functions called after returning to a pre-jump location."
   :type 'hook)
 
+(defcustom xref-after-update-hook nil
+  "Functions called after the xref buffer is updated."
+  :type 'hook)
+
 (defvar xref--marker-ring (make-ring xref-marker-ring-length)
   "Ring of markers to implement the marker stack.")
 
@@ -919,7 +933,8 @@ xref--insert-xrefs
                                        "RET or mouse-1: follow reference"))
                          prefix new-summary)
                         (setq prev-line-key line-key)))
-                    (insert "\n"))))
+                    (insert "\n")))
+  (run-hooks 'xref-after-update-hook))
 
 (defun xref--analyze (xrefs)
   "Find common filenames in XREFS.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46992; Package emacs. (Sun, 07 Mar 2021 19:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 46992 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, 46992 <at> debbugs.gnu.org
Subject: Re: bug#46992: xref-after-update-hook
Date: Sun, 7 Mar 2021 21:29:58 +0200
Hi!

On 07.03.2021 20:50, Juri Linkov wrote:
> As suggested inhttps://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00161.html
> here is a patch that adds such hook:

The patch LGTM, but have you tried using xref--xref-buffer-mode-hook?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46992; Package emacs. (Sun, 07 Mar 2021 20:46:01 GMT) Full text and rfc822 format available.

Message #11 received at 46992 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 46992 <at> debbugs.gnu.org
Subject: Re: bug#46992: xref-after-update-hook
Date: Sun, 07 Mar 2021 22:43:40 +0200
>> As suggested inhttps://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00161.html
>> here is a patch that adds such hook:
>
> The patch LGTM, but have you tried using xref--xref-buffer-mode-hook?

This is the first thing that I tried, but the problem is that
it's called before the xref buffer is filled with results
where I need to put overlays on output lines.

Also the hook needs to be called after reverting xref buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46992; Package emacs. (Mon, 08 Mar 2021 00:10:01 GMT) Full text and rfc822 format available.

Message #14 received at 46992 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: 46992 <at> debbugs.gnu.org
Subject: Re: bug#46992: xref-after-update-hook
Date: Mon, 8 Mar 2021 02:09:26 +0200
On 07.03.2021 22:43, Juri Linkov wrote:
> This is the first thing that I tried, but the problem is that
> it's called before the xref buffer is filled with results
> where I need to put overlays on output lines.
> 
> Also the hook needs to be called after reverting xref buffer.

I figured if all you are doing is some setup and turning on a minor 
mode, it should be enough to only do once. A minor mode would generally 
track all subsequent modifications to the buffer with 
after-change-functions or the like (we don't bind 
(inhibit-modification-hooks t) while rendering the output, although it 
looks like we might, for a small extra speed boost).

But if that doesn't work for some reason, or doesn't cover all your 
goals, please feel free to install the patch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46992; Package emacs. (Mon, 08 Mar 2021 17:50:02 GMT) Full text and rfc822 format available.

Message #17 received at 46992 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 46992 <at> debbugs.gnu.org
Subject: Re: bug#46992: xref-after-update-hook
Date: Mon, 08 Mar 2021 19:48:48 +0200
tags 46992 fixed
close 46992 28.0.50
thanks

>> This is the first thing that I tried, but the problem is that
>> it's called before the xref buffer is filled with results
>> where I need to put overlays on output lines.
>> Also the hook needs to be called after reverting xref buffer.
>
> I figured if all you are doing is some setup and turning on a minor mode,
> it should be enough to only do once. A minor mode would generally track all
> subsequent modifications to the buffer with after-change-functions or the
> like (we don't bind (inhibit-modification-hooks t) while rendering the
> output, although it looks like we might, for a small extra speed boost).

We can't overburden minor modes with such complexity that is not used
most of the time.

> But if that doesn't work for some reason, or doesn't cover all your goals,
> please feel free to install the patch.

Ok, pushed to master, and closed.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 08 Mar 2021 17:50:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 46992 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 08 Mar 2021 17:50:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 06 Apr 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 133 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.