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

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

[nongnu] elpa/helm e39db6bbf2 2/2: Merge pull request #2535 from renatof


From: ELPA Syncer
Subject: [nongnu] elpa/helm e39db6bbf2 2/2: Merge pull request #2535 from renatofdds/master
Date: Wed, 27 Jul 2022 16:58:37 -0400 (EDT)

branch: elpa/helm
commit e39db6bbf26d6a4b4b4d14140d98b4a254c7e153
Merge: f5159e17b8 de07b116fe
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: GitHub <noreply@github.com>

    Merge pull request #2535 from renatofdds/master
    
    Fix helm-occur when previous mark is outside active region
---
 helm-occur.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/helm-occur.el b/helm-occur.el
index 14a831b645..ad269ded43 100644
--- a/helm-occur.el
+++ b/helm-occur.el
@@ -211,11 +211,15 @@ engine beeing completely different and also much faster."
         ;; When user mark defun with `mark-defun' with intention of
         ;; using helm-occur on this region, it is relevant to use the
         ;; thing-at-point located at previous position which have been
-        ;; pushed to `mark-ring'.
-        (setq def (save-excursion
-                    (goto-char (setq pos (car mark-ring)))
-                    (helm-aif (thing-at-point 'symbol) (regexp-quote it))))
-        (narrow-to-region (region-beginning) (region-end)))
+        ;; pushed to `mark-ring', if it's within the active region.
+        (let ((beg (region-beginning))
+              (end (region-end))
+              (prev-pos (car mark-ring)))
+          (when (and prev-pos (>= prev-pos beg) (< prev-pos end))
+            (setq def (save-excursion
+                        (goto-char (setq pos prev-pos))
+                        (helm-aif (thing-at-point 'symbol) (regexp-quote 
it)))))
+          (narrow-to-region beg end)))
       (unwind-protect
            (helm :sources 'helm-source-occur
                  :buffer "*helm occur*"



reply via email to

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