GNU bug report logs - #39608
defun occur does not use a coherent value for default-directory (fix included)

Previous Next

Package: emacs;

Reported by: Stéphane Boucher <Stephane.Boucher <at> acceo.com>

Date: Fri, 14 Feb 2020 20:06:01 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39608 in the body.
You can then email your comments to 39608 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#39608; Package emacs. (Fri, 14 Feb 2020 20:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stéphane Boucher <Stephane.Boucher <at> acceo.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 14 Feb 2020 20:06:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stéphane Boucher <Stephane.Boucher <at> acceo.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: defun occur does not use a coherent value for default-directory
 (fix included)
Date: Fri, 14 Feb 2020 19:26:52 +0000
[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)]

Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 24 Feb 2020 18:13:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 24 Feb 2020 18:13:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39608; Package emacs. (Mon, 02 Mar 2020 22:21:03 GMT) Full text and rfc822 format available.

Message #12 received at 39608 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stéphane Boucher <Stephane.Boucher <at> acceo.com>
Cc: 39608 <at> debbugs.gnu.org
Subject: Re: bug#39608: defun occur does not use a coherent value for
 default-directory (fix included)
Date: Tue, 03 Mar 2020 00:16:01 +0200
> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39608; Package emacs. (Tue, 03 Mar 2020 17:21:01 GMT) Full text and rfc822 format available.

Message #15 received at 39608 <at> debbugs.gnu.org (full text, mbox):

From: Stéphane Boucher <Stephane.Boucher <at> acceo.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: "39608 <at> debbugs.gnu.org" <39608 <at> debbugs.gnu.org>
Subject: RE: bug#39608: defun occur does not use a coherent value for
 default-directory (fix included)
Date: Tue, 3 Mar 2020 17:03:49 +0000
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 <at> linkov.net] 
Sent: March 2, 2020 5:16 PM
To: Stéphane Boucher <Stephane.Boucher <at> acceo.com>
Cc: 39608 <at> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39608; Package emacs. (Wed, 04 Mar 2020 00:12:02 GMT) Full text and rfc822 format available.

Message #18 received at 39608 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stéphane Boucher <Stephane.Boucher <at> acceo.com>
Cc: "39608 <at> debbugs.gnu.org" <39608 <at> debbugs.gnu.org>
Subject: Re: bug#39608: defun occur does not use a coherent value for
 default-directory (fix included)
Date: Wed, 04 Mar 2020 02:06:24 +0200
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.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 04 Mar 2020 00:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 39608 <at> debbugs.gnu.org and Stéphane Boucher <Stephane.Boucher <at> acceo.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 04 Mar 2020 00:12:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 01 Apr 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.