unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46992: xref-after-update-hook
@ 2021-03-07 18:50 Juri Linkov
  2021-03-07 19:29 ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2021-03-07 18:50 UTC (permalink / raw)
  To: 46992

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xref-after-update-hook.patch --]
[-- Type: text/x-diff, Size: 912 bytes --]

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.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#46992: xref-after-update-hook
  2021-03-07 18:50 bug#46992: xref-after-update-hook Juri Linkov
@ 2021-03-07 19:29 ` Dmitry Gutov
  2021-03-07 20:43   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2021-03-07 19:29 UTC (permalink / raw)
  To: Juri Linkov, 46992

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?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46992: xref-after-update-hook
  2021-03-07 19:29 ` Dmitry Gutov
@ 2021-03-07 20:43   ` Juri Linkov
  2021-03-08  0:09     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2021-03-07 20:43 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 46992

>> 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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46992: xref-after-update-hook
  2021-03-07 20:43   ` Juri Linkov
@ 2021-03-08  0:09     ` Dmitry Gutov
  2021-03-08 17:48       ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2021-03-08  0:09 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 46992

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46992: xref-after-update-hook
  2021-03-08  0:09     ` Dmitry Gutov
@ 2021-03-08 17:48       ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2021-03-08 17:48 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 46992

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-08 17:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-07 18:50 bug#46992: xref-after-update-hook Juri Linkov
2021-03-07 19:29 ` Dmitry Gutov
2021-03-07 20:43   ` Juri Linkov
2021-03-08  0:09     ` Dmitry Gutov
2021-03-08 17:48       ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).