* bug#39608: defun occur does not use a coherent value for default-directory (fix included)
@ 2020-02-14 19:26 Stéphane Boucher
2020-03-02 22:16 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Boucher @ 2020-02-14 19:26 UTC (permalink / raw)
To: 39608
[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]
When occur creates an *Occur* buffer, the default-directory variable is implicitly set to the default-directory of the buffer the occurences came from.
When occur REUSES an existing *Occur* buffer, it does not update the default-directory variable.
Following is a patch for emacs 26.3:
--- replace.el.orig 2020-02-14 14:13:34.201656900 -0500
+++ replace.el 2020-02-14 14:17:35.330856900 -0500
@@ -1532,7 +1532,8 @@ (defun occur-1 (regexp nlines bufs &opti
(let (occur-buf
(active-bufs (delq nil (mapcar #'(lambda (buf)
(when (buffer-live-p buf) buf))
- bufs))))
+ bufs)))
+ (source-buffer-default-directory default-directory))
;; Handle the case where one of the buffers we're searching is the
;; output buffer. Just rename it.
(when (member buf-name (mapcar 'buffer-name active-bufs))
@@ -1544,6 +1545,8 @@ (defun occur-1 (regexp nlines bufs &opti
(setq occur-buf (get-buffer-create buf-name))
(with-current-buffer occur-buf
+ ;; make the default-directory of the *Occur* buffer match that of the buffer where the occurences come from
+ (setq default-directory source-buffer-default-directory)
(if (stringp nlines)
(fundamental-mode) ;; This is for collect operation.
(occur-mode))
[-- Attachment #2: Type: text/html, Size: 6567 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#39608: defun occur does not use a coherent value for default-directory (fix included)
2020-02-14 19:26 bug#39608: defun occur does not use a coherent value for default-directory (fix included) Stéphane Boucher
@ 2020-03-02 22:16 ` Juri Linkov
2020-03-03 17:03 ` Stéphane Boucher
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2020-03-02 22:16 UTC (permalink / raw)
To: Stéphane Boucher; +Cc: 39608
> When occur creates an *Occur* buffer, the default-directory variable is
> implicitly set to the default-directory of the buffer the occurences came
> from.
>
> When occur REUSES an existing *Occur* buffer, it does not update the
> default-directory variable.
What default-directory do you expect in case of multi-occur
that displays occurrences from multiple buffers that might be
located in multiple directories?
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#39608: defun occur does not use a coherent value for default-directory (fix included)
2020-03-02 22:16 ` Juri Linkov
@ 2020-03-03 17:03 ` Stéphane Boucher
2020-03-04 0:06 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Boucher @ 2020-03-03 17:03 UTC (permalink / raw)
To: Juri Linkov; +Cc: 39608@debbugs.gnu.org
Defun occur only works with the current buffer. I even provided a patch on how to fix it.
-----Original Message-----
From: Juri Linkov [mailto:juri@linkov.net]
Sent: March 2, 2020 5:16 PM
To: Stéphane Boucher <Stephane.Boucher@acceo.com>
Cc: 39608@debbugs.gnu.org
Subject: Re: bug#39608: defun occur does not use a coherent value for default-directory (fix included)
> When occur creates an *Occur* buffer, the default-directory variable
> is implicitly set to the default-directory of the buffer the
> occurences came from.
>
> When occur REUSES an existing *Occur* buffer, it does not update the
> default-directory variable.
What default-directory do you expect in case of multi-occur that displays occurrences from multiple buffers that might be located in multiple directories?
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#39608: defun occur does not use a coherent value for default-directory (fix included)
2020-03-03 17:03 ` Stéphane Boucher
@ 2020-03-04 0:06 ` Juri Linkov
0 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2020-03-04 0:06 UTC (permalink / raw)
To: Stéphane Boucher; +Cc: 39608@debbugs.gnu.org
tags 39608 fixed
close 39608 28.0.50
thanks
> Defun occur only works with the current buffer. I even provided a patch on how to fix it.
Thanks for the patch, now pushed to master.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-04 0:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-14 19:26 bug#39608: defun occur does not use a coherent value for default-directory (fix included) Stéphane Boucher
2020-03-02 22:16 ` Juri Linkov
2020-03-03 17:03 ` Stéphane Boucher
2020-03-04 0:06 ` Juri Linkov
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).