(move-to-column col)))))))
\f
- (defun occur--parse-occur-buffer()
- "Retrieve a list of the form (BEG END ORIG-LINE BUFFER).
- BEG and END define the region.
- 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) '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."
- (apply #'occur-1 (append occur-revert-arguments (list (buffer-name)))))
+ (if (cdr (nth 2 occur-revert-arguments)) ; multi-occur
+ (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))
+ (pcase-let ((`(,region-start ,region-end ,orig-line ,buffer)
+ (occur--parse-occur-buffer))
+ (regexp (car occur-revert-arguments)))
+ (if (not (or region-start region-end))
+ (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))
+ (with-current-buffer buffer
+ (when (wholenump orig-line)
+ (goto-char (point-min))
+ (forward-line (1- orig-line)))
+ (save-excursion
+ (occur regexp nil (list (cons region-start region-end)))))))))
(defun occur-mode-find-occurrence ()
(let ((pos (get-text-property (point) 'occur-target)))