aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorTino Calancha2018-09-21 05:13:54 +0900
committerTino Calancha2018-09-21 05:27:01 +0900
commitd6f3c2cf0628afaefe428140d8c6615e925044ad (patch)
treea01a781e435bfedba411eb6eced8b83e35f7b47a /lisp/replace.el
parent44c1ce3a370ed94199751d1429a65f40880b9234 (diff)
downloademacs-d6f3c2cf0628afaefe428140d8c6615e925044ad.tar.gz
emacs-d6f3c2cf0628afaefe428140d8c6615e925044ad.zip
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.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el22
1 files changed, 9 insertions, 13 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index eb65c7a82d4..00b2ceee356 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
1213the user called `occur'." 1213the user called `occur'."
1214 (save-excursion 1214 (save-excursion
1215 (goto-char (point-min)) 1215 (goto-char (point-min))
1216 (let ((buffer (get-text-property (point-at-bol) 'occur-title)) 1216 (let ((buffer (get-text-property (point) 'occur-title))
1217 (beg-pos (get-text-property (point-at-bol) 'region-start)) 1217 (beg-pos (get-text-property (point) 'region-start))
1218 (end-pos (get-text-property (point-at-bol) 'region-end)) 1218 (end-pos (get-text-property (point) 'region-end))
1219 (orig-line (get-text-property (point-at-bol) 'current-line)) 1219 (orig-line (get-text-property (point) 'current-line)))
1220 beg-line end-line)
1221 (list beg-pos end-pos orig-line buffer)))) 1220 (list beg-pos end-pos orig-line buffer))))
1222 1221
1223(defun occur-revert-function (_ignore1 _ignore2) 1222(defun occur-revert-function (_ignore1 _ignore2)
1224 "Handle `revert-buffer' for Occur mode buffers." 1223 "Handle `revert-buffer' for Occur mode buffers."
1225 (if (cdr (nth 2 occur-revert-arguments)) ; multi-occur 1224 (if (cdr (nth 2 occur-revert-arguments)) ; multi-occur
1226 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name)))) 1225 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))
1227 (let* ((region (occur--parse-occur-buffer)) 1226 (pcase-let ((`(,region-start ,region-end ,orig-line ,buffer)
1228 (region-start (nth 0 region)) 1227 (occur--parse-occur-buffer))
1229 (region-end (nth 1 region)) 1228 (regexp (car occur-revert-arguments)))
1230 (orig-line (nth 2 region))
1231 (buffer (nth 3 region))
1232 (regexp (car occur-revert-arguments)))
1233 (with-current-buffer buffer 1229 (with-current-buffer buffer
1234 (when (wholenump orig-line) 1230 (when (wholenump orig-line)
1235 (goto-char 1) 1231 (goto-char (point-min))
1236 (forward-line (1- orig-line))) 1232 (forward-line (1- orig-line)))
1237 (save-excursion 1233 (save-excursion
1238 (if region 1234 (if (or region-start region-end)
1239 (occur regexp nil (list (cons region-start region-end))) 1235 (occur regexp nil (list (cons region-start region-end)))
1240 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name)))))))))) 1236 (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))))))))
1241 1237