From: Juri Linkov <juri@linkov.net>
To: 33476@debbugs.gnu.org
Subject: bug#33476: [PATCH] Fix occur revert with list-matching-lines-jump-to-current-line
Date: Sat, 24 Nov 2018 23:54:24 +0200 [thread overview]
Message-ID: <87efbagn6n.fsf@mail.linkov.net> (raw)
In-Reply-To: <874lc7sdok.fsf@konghq.com> (Raimon Grau's message of "Fri, 23 Nov 2018 21:10:19 +0000")
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: occur-orig-line.patch --]
[-- Type: text/x-diff, Size: 1901 bytes --]
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
next prev parent reply other threads:[~2018-11-24 21:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-23 21:10 bug#33476: [PATCH] Fix occur revert with list-matching-lines-jump-to-current-line Raimon Grau
2018-11-24 21:54 ` Juri Linkov [this message]
2018-11-26 17:54 ` Eli Zaretskii
2018-12-08 9:25 ` Eli Zaretskii
2018-12-08 23:16 ` Juri Linkov
2018-12-09 7:55 ` Eli Zaretskii
2018-12-09 23:54 ` Juri Linkov
2018-12-10 6:27 ` Eli Zaretskii
2018-12-11 4:40 ` Richard Stallman
2018-12-11 23:07 ` Glenn Morris
2018-12-12 17:07 ` Eli Zaretskii
2018-12-13 0:12 ` Richard Stallman
2018-12-13 8:57 ` Robert Pluim
2018-12-13 21:14 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efbagn6n.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=33476@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.