emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/helm 920a916cf1: Stay at nearest pos with next-error after


From: ELPA Syncer
Subject: [nongnu] elpa/helm 920a916cf1: Stay at nearest pos with next-error after a revert-buffer
Date: Fri, 11 Feb 2022 06:58:13 -0500 (EST)

branch: elpa/helm
commit 920a916cf1dbd312bbacb93a5b4ffe62e70e49a6
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Stay at nearest pos with next-error after a revert-buffer
---
 helm-grep.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/helm-grep.el b/helm-grep.el
index acc6f1178f..306c08745e 100644
--- a/helm-grep.el
+++ b/helm-grep.el
@@ -955,8 +955,22 @@ Special commands:
                                'helm-realvalue line)
                               "\n"))))
       (when (fboundp 'wgrep-cleanup-overlays)
-        (wgrep-cleanup-overlays (point-min) (point-max)))
-      (message "Reverting buffer done"))))
+        (wgrep-cleanup-overlays (point-min) (point-max))))
+    (unless (eq major-mode 'helm-grep-mode)
+      (let ((bufname (buffer-name))
+            (linum (line-number-at-pos)))
+        (with-current-buffer (next-error-find-buffer)
+          (helm-grep-goto-closest-from-linum linum bufname))))
+    (message "Reverting buffer done")))
+
+(defun helm-grep-goto-closest-from-linum (linum bufname)
+  (goto-char (point-min))
+  (catch 'break
+    (while (re-search-forward (format "^%s:\\([0-9]+\\):" (regexp-quote 
bufname)) nil t)
+      (let ((numline (string-to-number (match-string 1))))
+        (when (<= (- linum numline) 0)
+          (forward-line -1)
+          (throw 'break nil))))))
 
 (defun helm-gm-next-file ()
   (interactive)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]