GNU bug report logs -
#39608
defun occur does not use a coherent value for default-directory (fix included)
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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))
[Message part 2 (text/html, inline)]
This bug report was last modified 5 years and 80 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.