all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stéphane Boucher" <Stephane.Boucher@acceo.com>
To: 39608@debbugs.gnu.org
Subject: bug#39608: defun occur does not use a coherent value for default-directory (fix included)
Date: Fri, 14 Feb 2020 19:26:52 +0000	[thread overview]
Message-ID: <60D05FE57203B748B1062BE52304C40CF015AA@cpt-exch05w-p.magrit.int> (raw)

[-- 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 --]

             reply	other threads:[~2020-02-14 19:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 19:26 Stéphane Boucher [this message]
2020-03-02 22:16 ` bug#39608: defun occur does not use a coherent value for default-directory (fix included) Juri Linkov
2020-03-03 17:03   ` Stéphane Boucher
2020-03-04  0:06     ` Juri Linkov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60D05FE57203B748B1062BE52304C40CF015AA@cpt-exch05w-p.magrit.int \
    --to=stephane.boucher@acceo.com \
    --cc=39608@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.