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

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

[nongnu] elpa/helm 7e9383e249 4/5: Ensure next-error jump to first candi


From: ELPA Syncer
Subject: [nongnu] elpa/helm 7e9383e249 4/5: Ensure next-error jump to first candidate on first use
Date: Wed, 20 Jul 2022 13:58:34 -0400 (EDT)

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

    Ensure next-error jump to first candidate on first use
    
    when occur/grep buffer haven't been used.
---
 helm-grep.el  | 16 +++++++++++-----
 helm-lib.el   |  2 ++
 helm-occur.el | 12 +++++++++---
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/helm-grep.el b/helm-grep.el
index 8d45542959..bf356145a4 100644
--- a/helm-grep.el
+++ b/helm-grep.el
@@ -41,7 +41,7 @@
 (defvar helm-grep-git-grep-command)
 (defvar helm-source-grep-git)
 (defvar tramp-verbose)
-
+(defvar helm-current-error)
 
 ;;; Internals vars
 ;;
@@ -933,14 +933,19 @@ RESET non-nil means rewind to the first match.
 This is the `next-error-function' for `helm-grep-mode'."
   (interactive "p")
   (goto-char (cond (reset (point-min))
-                  ((< argp 0) (line-beginning-position))
-                  ((> argp 0) (line-end-position))
+                  ((and (< argp 0) helm-current-error)
+                    (line-beginning-position))
+                  ((and (> argp 0) helm-current-error)
+                    (line-end-position))
                   ((point))))
   (let ((fun (if (> argp 0)
                  #'next-single-property-change
                #'previous-single-property-change)))
     (helm-aif (funcall fun (point) 'helm-grep-fname)
-        (progn (goto-char it) (helm-grep-mode-jump))
+        (progn
+          (goto-char it)
+          (setq helm-current-error (point-marker))
+          (helm-grep-mode-jump))
       (user-error "No more matches"))))
 (put 'helm-grep-next-error 'helm-only t)
 
@@ -978,7 +983,8 @@ Special commands:
     (set (make-local-variable 'revert-buffer-function)
          #'helm-grep-mode--revert-buffer-function)
     (set (make-local-variable 'next-error-function)
-         #'helm-grep-next-error))
+         #'helm-grep-next-error)
+    (set (make-local-variable 'helm-current-error) nil))
 (put 'helm-grep-mode 'helm-only t)
 
 (defun helm-grep-mode--revert-buffer-function (&optional _ignore-auto 
_noconfirm)
diff --git a/helm-lib.el b/helm-lib.el
index d8844338ad..50d87e6bdf 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -178,6 +178,8 @@ the customize functions e.g. `customize-set-variable' and 
NOT
   "Buffer showing actions.")
 (defvar helm-current-prefix-arg nil
   "Record `current-prefix-arg' when exiting minibuffer.")
+(defvar helm-current-error nil
+  "Same as `compilation-current-error' but for helm-occur and helm-grep.")
 
 ;;; Compatibility
 ;;
diff --git a/helm-occur.el b/helm-occur.el
index f3dc5acb76..1cef1a6f45 100644
--- a/helm-occur.el
+++ b/helm-occur.el
@@ -29,6 +29,8 @@
 (declare-function helm-grep-highlight-match "helm-grep")
 (declare-function helm-comp-read "helm-mode")
 
+(defvar helm-current-error)
+
 ;;; Internals
 ;;
 (defvar helm-source-occur nil
@@ -691,7 +693,8 @@ Special commands:
     (set (make-local-variable 'helm-occur-mode--last-pattern)
          helm-input)
     (set (make-local-variable 'next-error-function)
-         #'helm-occur-next-error))
+         #'helm-occur-next-error)
+    (set (make-local-variable 'helm-current-error) nil))
 (put 'helm-moccur-mode 'helm-only t)
 
 (defun helm-occur-next-error (&optional argp reset)
@@ -700,8 +703,10 @@ RESET non-nil means rewind to the first match.
 This is the `next-error-function' for `helm-occur-mode'."
   (interactive "p")
   (goto-char (cond (reset (point-min))
-                  ((< argp 0) (line-beginning-position))
-                  ((> argp 0) (line-end-position))
+                  ((and (< argp 0) helm-current-error)
+                    (line-beginning-position))
+                  ((and (> argp 0) helm-current-error)
+                    (line-end-position))
                   ((point))))
   (let ((fun (if (> argp 0)
                  #'next-single-property-change
@@ -710,6 +715,7 @@ This is the `next-error-function' for `helm-occur-mode'."
         (progn
           (goto-char it)
           (forward-line 0)
+          (setq helm-current-error (point-marker))
           (helm-occur-mode-goto-line))
       (user-error "No more matches"))))
 



reply via email to

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