unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33476: [PATCH] Fix occur revert with list-matching-lines-jump-to-current-line
@ 2018-11-23 21:10 Raimon Grau
  2018-11-24 21:54 ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: Raimon Grau @ 2018-11-23 21:10 UTC (permalink / raw)
  To: 33476

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

Hello,

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.

Cheers,

Raimon Grau


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Guard-occur-against-an-undefined-orig-line.patch --]
[-- Type: text/x-diff, Size: 1530 bytes --]

From 2f874d70b6d69debd7370da562e768fc3b9b8198 Mon Sep 17 00:00:00 2001
From: Raimon Grau <raimonster@gmail.com>
Date: Fri, 23 Nov 2018 20:37:12 +0000
Subject: [PATCH] Guard occur against an undefined orig-line

* lisp/replace.el (occur-engine): Avoid inserting the current line if
orig-line is nil. This happens, for example, when reverting an occur
buffer with `list-matching-lines-jump-to-current-line' set to t.
---
 lisp/replace.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 940bf56..4f0cbf4 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1748,6 +1748,7 @@ occur-engine
                           (when (and list-matching-lines-jump-to-current-line
                                      (not multi-occur-p)
                                      (not orig-line-shown-p)
+                                     orig-line
                                      (>= curr-line orig-line))
                             (insert
                              (concat
@@ -1774,7 +1775,8 @@ occur-engine
                   ;; Insert original line if haven't done yet.
                   (when (and list-matching-lines-jump-to-current-line
                              (not multi-occur-p)
-                             (not orig-line-shown-p))
+                             (not orig-line-shown-p)
+                             orig-line)
                     (with-current-buffer out-buf
                       (insert
                        (concat
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-12-13 21:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).