[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33476: [PATCH] Fix occur revert with list-matching-lines-jump-to-cur
From: |
Juri Linkov |
Subject: |
bug#33476: [PATCH] Fix occur revert with list-matching-lines-jump-to-current-line |
Date: |
Sat, 24 Nov 2018 23:54:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
> I reproduced this bug with Emacs 26.1 and 26.1.90 using -Q option.
>
> When pressing 'g' (revert-buffer) in an *Occur* buffer, in the case of
> having `list-matching-lines-jump-to-current-line' set to non-nil, the
> function errors as it can't find orig-line.
>
> I'm attaching a patch that adds a guard to the list of guards before
> inserting the current line.
Eli, is it ok to install this submitted patch to the release branch emacs-26?
At least, it prevents the error signal.
I see that for Emacs 27 in master this feature is completely rewritten.
But still I found a bug in master that can be fixed with another patch.
The following patch is for Emacs 27:
diff --git a/lisp/replace.el b/lisp/replace.el
index ecb47936e7..1e64514c1c 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1657,7 +1657,10 @@ occur-engine
(lines 0) ; count of matching lines
(matches 0) ; count of matches
(headerpt (with-current-buffer out-buf (point)))
- )
+ (orig-line (if (not (overlayp boo))
+ (line-number-at-pos)
+ (line-number-at-pos
+ (overlay-get boo 'occur--orig-point)))))
(save-excursion
;; begin searching in the buffer
(goto-char (if (overlayp boo) (overlay-start boo) (point-min)))
@@ -1665,9 +1668,6 @@ occur-engine
(let* ((limit (if (overlayp boo) (overlay-end boo) (point-max)))
(start-line (line-number-at-pos))
(curr-line start-line) ; line count
- (orig-line (if (not (overlayp boo)) 1
- (line-number-at-pos
- (overlay-get boo 'occur--orig-point))))
(orig-line-shown-p)
(prev-line nil) ; line number of prev match endpt
(prev-after-lines nil) ; context lines of prev match
@@ -1796,7 +1796,7 @@ occur-engine
(setq orig-line-shown-p t)
(save-excursion
(goto-char (point-min))
- (forward-line (- orig-line start-line 1))
+ (forward-line (1- orig-line))
(occur-engine-line (line-beginning-position)
(line-end-position)
keep-props)))))
;; Actually insert the match display data
@@ -1834,7 +1834,7 @@ occur-engine
(let ((orig-line-str
(save-excursion
(goto-char (point-min))
- (forward-line (- orig-line start-line 1))
+ (forward-line (1- orig-line))
(occur-engine-line (line-beginning-position)
(line-end-position)
keep-props))))
(add-face-text-property