emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master d6f3c2c: Fix a previous commit


From: Tino Calancha
Subject: [Emacs-diffs] master d6f3c2c: Fix a previous commit
Date: Thu, 20 Sep 2018 16:28:26 -0400 (EDT)

branch: master
commit d6f3c2cf0628afaefe428140d8c6615e925044ad
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>

    Fix a previous commit
    
    Suggested by Stefan Monnier here:
    https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00783.html
    * lisp/replace.el (occur--parse-occur-buffer): Since point is at the
    beginning of the buffer, use `point'.
    
    (occur-revert-function): Prefer `pcase-let' and `point-min'.
    Check whether `region-start' or `region-end' are non-nil.
---
 lisp/replace.el | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index eb65c7a..00b2cee 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1213,29 +1213,25 @@ ORIG-LINE and BUFFER are the line and the buffer from 
which
 the user called `occur'."
   (save-excursion
     (goto-char (point-min))
-    (let ((buffer (get-text-property (point-at-bol) 'occur-title))
-          (beg-pos (get-text-property (point-at-bol) 'region-start))
-          (end-pos (get-text-property (point-at-bol) 'region-end))
-          (orig-line (get-text-property (point-at-bol) 'current-line))
-          beg-line end-line)
+    (let ((buffer (get-text-property (point) 'occur-title))
+          (beg-pos (get-text-property (point) 'region-start))
+          (end-pos (get-text-property (point) 'region-end))
+          (orig-line (get-text-property (point) 'current-line)))
       (list beg-pos end-pos orig-line buffer))))
 
 (defun occur-revert-function (_ignore1 _ignore2)
   "Handle `revert-buffer' for Occur mode buffers."
   (if (cdr (nth 2 occur-revert-arguments)) ; multi-occur
       (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))
-    (let* ((region (occur--parse-occur-buffer))
-           (region-start (nth 0 region))
-           (region-end (nth 1 region))
-           (orig-line (nth 2 region))
-           (buffer (nth 3 region))
-           (regexp (car occur-revert-arguments)))
+    (pcase-let ((`(,region-start ,region-end ,orig-line ,buffer)
+                 (occur--parse-occur-buffer))
+                (regexp (car occur-revert-arguments)))
       (with-current-buffer buffer
         (when (wholenump orig-line)
-          (goto-char 1)
+          (goto-char (point-min))
           (forward-line (1- orig-line)))
         (save-excursion
-          (if region
+          (if (or region-start region-end)
               (occur regexp nil (list (cons region-start region-end)))
             (apply 'occur-1 (append occur-revert-arguments (list 
(buffer-name))))))))))
 



reply via email to

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