branch: elpa/flycheck
commit 3df4440f19bd19bd10a0c52e40b0c9349d608c9e
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Add flycheck-error-list-after-jump-hook
    
    Run this hook after jumping from the error list to an error location,
    allowing users to customize post-jump behavior (e.g., recentering).
    
    Fixes #1874
---
 flycheck.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/flycheck.el b/flycheck.el
index 02cbddc5a6..fcdab71907 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -5389,13 +5389,26 @@ Interactively, or with non-nil REFRESH, refresh the 
error list."
                   errors)
     errors))
 
+(defcustom flycheck-error-list-after-jump-hook nil
+  "Functions to run after jumping to an error from the error list.
+
+This hook is run in the source buffer after
+`flycheck-error-list-goto-error' jumps to the error location.
+Useful for post-jump actions like recentering:
+
+  (add-hook \\='flycheck-error-list-after-jump-hook #\\='recenter)"
+  :group 'flycheck
+  :type 'hook
+  :package-version '(flycheck . "36"))
+
 (defun flycheck-error-list-goto-error (&optional pos)
   "Go to the location of the error at POS in the error list.
 
 POS defaults to `point'."
   (interactive)
   (when-let* ((error (tabulated-list-get-id pos)))
-    (flycheck-jump-to-error error)))
+    (flycheck-jump-to-error error)
+    (run-hooks 'flycheck-error-list-after-jump-hook)))
 
 (defun flycheck-jump-to-error (error)
   "Go to the location of ERROR."

Reply via email to