From: Juri Linkov <juri@linkov.net>
To: 46268@debbugs.gnu.org
Cc: stefan monnier <monnier@iro.umontreal.ca>
Subject: bug#46268: 27.1.91; Error in occur-rename-buffer
Date: Wed, 03 Feb 2021 10:54:24 +0200 [thread overview]
Message-ID: <874kitttd3.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]
Tags: patch
X-Debbugs-Cc: Stefan Monnier <monnier@iro.umontreal.ca>
After evaluating (add-hook 'occur-hook 'occur-rename-buffer)
then selecting a region, and running 'M-x occur' with any string
in the active region, signals the error:
(wrong-type-argument bufferp #<overlay from 1 to 72 in *scratch*>)
It seems the attached patch is the right way to fix this.
Also Cc:ing Stefan with a question about occur--garbage-collect-revert-args:
trying to revert the Occur buffer created from an active region
removes the source buffer name from the Occur buffer name.
For example, (after applying the attached patch) 'M-x occur'
on the active region in *scratch* creates the buffer *Occur: *scratch**.
But reverting the Occur buffer with 'g' removes the *scratch* buffer name,
and renames the Occur buffer to *Occur: *.
This is because of two lines in occur-1:
(occur--garbage-collect-revert-args)
(setq occur-revert-arguments (list regexp nlines bufs))
where occur--garbage-collect-revert-args deletes the overlay
with the buffer name *scratch*, and later occur-rename-buffer
can't get the original buffer name from occur-revert-arguments.
And I don't know how to fix this.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: occur-rename-buffer-overlay.patch --]
[-- Type: text/x-diff, Size: 1167 bytes --]
diff --git a/lisp/replace.el b/lisp/replace.el
index f13d27aff8..c4c80118b4 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1544,11 +1544,17 @@ occur-rename-buffer
(interactive "P\np")
(with-current-buffer
(if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
- (rename-buffer (concat "*Occur: "
- (mapconcat #'buffer-name
- (car (cddr occur-revert-arguments)) "/")
- "*")
- (or unique-p (not interactive-p)))))
+ (rename-buffer
+ (concat "*Occur: "
+ (mapconcat (lambda (boo)
+ (or (and (buffer-live-p boo)
+ (buffer-name boo))
+ (and (overlayp boo)
+ (buffer-live-p (overlay-buffer boo))
+ (buffer-name (overlay-buffer boo)))))
+ (car (cddr occur-revert-arguments)) "/")
+ "*")
+ (or unique-p (not interactive-p)))))
;; Region limits when `occur' applies on a region.
(defvar occur--final-pos nil)
next reply other threads:[~2021-02-03 8:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 8:54 Juri Linkov [this message]
2021-02-03 15:05 ` bug#46268: 27.1.91; Error in occur-rename-buffer Stefan Monnier
2021-02-03 15:38 ` Stefan Monnier
2021-02-03 17:34 ` Juri Linkov
2021-02-03 15:22 ` Stefan Monnier
2021-02-03 17:36 ` Juri Linkov
2021-02-03 19:41 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874kitttd3.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=46268@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 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).