From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?St=C3=A9phane?= Boucher Newsgroups: gmane.emacs.bugs 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 Message-ID: <60D05FE57203B748B1062BE52304C40CF015AA@cpt-exch05w-p.magrit.int> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_60D05FE57203B748B1062BE52304C40CF015AAcptexch05wpmagrit_" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="123044"; mail-complaints-to="usenet@ciao.gmane.io" To: 39608@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 14 21:06:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j2hE6-000Vqv-7U for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Feb 2020 21:06:14 +0100 Original-Received: from localhost ([::1]:45048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hE5-0006ZU-6L for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Feb 2020 15:06:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51435) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hDx-0006ZG-MS for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 15:06:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hDu-0000zN-Sr for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 15:06:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2hDt-0000xc-SF for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 15:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j2hDt-0003FA-NJ for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 15:06:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?St=C3=A9phane?= Boucher Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Feb 2020 20:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39608 X-GNU-PR-Package: emacs X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.158171075212452 (code B ref -1); Fri, 14 Feb 2020 20:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Feb 2020 20:05:52 +0000 Original-Received: from localhost ([127.0.0.1]:34756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2hDj-0003Ek-Lo for submit@debbugs.gnu.org; Fri, 14 Feb 2020 15:05:52 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2gc9-0000Gp-Pf for submit@debbugs.gnu.org; Fri, 14 Feb 2020 14:27:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46066) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2gc8-0008If-GZ for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 14:27:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2gc5-0004m5-P4 for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 14:26:59 -0500 Original-Received: from cpt-smtp03l-p.acceo.com ([204.19.176.234]:38968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j2gc5-0004eb-K7 for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 14:26:57 -0500 Original-Received: from CPT-EXCH01W-P.magrit.int (cpt-exch01w-p.acceo.com [172.30.165.16]) by cpt-smtp03l-p.acceo.com (Postfix) with ESMTP id 793036209E for ; Fri, 14 Feb 2020 14:26:53 -0500 (EST) Original-Received: from cpt-exch05w-p.magrit.int ([169.254.3.205]) by CPT-EXCH01W-P.magrit.int ([172.30.165.16]) with mapi id 14.03.0468.000; Fri, 14 Feb 2020 14:26:53 -0500 Thread-Topic: defun occur does not use a coherent value for default-directory (fix included) Thread-Index: AdXjbLWmfQan/hPOR+Kfiz5foFQMdA== Accept-Language: en-CA, en-US Content-Language: en-US x-originating-ip: [172.30.42.23] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Mailman-Approved-At: Fri, 14 Feb 2020 15:05:50 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:176065 Archived-At: --_000_60D05FE57203B748B1062BE52304C40CF015AAcptexch05wpmagrit_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable When occur creates an *Occur* buffer, the default-directory variable is imp= licitly set to the default-directory of the buffer the occurences came from= . When occur REUSES an existing *Occur* buffer, it does not update the defaul= t-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 th= e 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)) --_000_60D05FE57203B748B1062BE52304C40CF015AAcptexch05wpmagrit_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

When occur creates an *Occur= * buffer, the default-directory variable is implicitly set to the defau= lt-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 @@ (defu= n occur-1 (regexp nlines bufs &opti

   (let (occur-buf

     &= nbsp;         (active-bufs (delq ni= l (mapcar #'(lambda (buf)

     &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            (when = (buffer-live-p buf) buf))

-     =             &nb= sp;            =             &nb= sp;            =              bufs)))= )

+    &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;            bufs)))

+    &n= bsp;        (source-buffer-default-direc= tory default-directory))

     ;; Han= dle the case where one of the buffers we're searching is the

     ;; out= put buffer.  Just rename it.

     (when = (member buf-name (mapcar 'buffer-name active-bufs))

@@ -1544,6 +1545,8 @@ (defu= n occur-1 (regexp nlines bufs &opti

     (setq = occur-buf (get-buffer-create buf-name))

     (= with-current-buffer occur-buf

+    &n= bsp; ;; make the default-directory of the *Occur* buffer match that of the = buffer where the occurences come from

+    &n= bsp; (setq default-directory source-buffer-default-directory)

     &= nbsp; (if (stringp nlines)

     &= nbsp;           (fundamen= tal-mode) ;; This is for collect operation.

     &= nbsp;         (occur-mode))

--_000_60D05FE57203B748B1062BE52304C40CF015AAcptexch05wpmagrit_--