From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#7131: 24.0.50; `dired' with cons arg should not ignore arg if buffer exists Date: Tue, 18 Jul 2017 20:39:07 +0900 Message-ID: <871spe0yas.fsf@calancha-pc> References: <9165B8BF5E624AAA8F9551E7A82022AF@us.oracle.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500378017 14492 195.159.176.226 (18 Jul 2017 11:40:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 18 Jul 2017 11:40:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 7131@debbugs.gnu.org To: "Drew Adams" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 18 13:40:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXQrJ-0003Fn-PK for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jul 2017 13:40:09 +0200 Original-Received: from localhost ([::1]:55678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXQrN-0004ku-Th for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jul 2017 07:40:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXQrG-0004jQ-Bi for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 07:40:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXQrC-0004N5-1x for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 07:40:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dXQrB-0004Mz-Ui for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 07:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dXQrB-0007ty-No for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2017 07:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jul 2017 11:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7131 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: easy Original-Received: via spool by 7131-submit@debbugs.gnu.org id=B7131.150037796530327 (code B ref 7131); Tue, 18 Jul 2017 11:40:01 +0000 Original-Received: (at 7131) by debbugs.gnu.org; 18 Jul 2017 11:39:25 +0000 Original-Received: from localhost ([127.0.0.1]:45405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXQqZ-0007t3-4e for submit@debbugs.gnu.org; Tue, 18 Jul 2017 07:39:24 -0400 Original-Received: from mail-pf0-f172.google.com ([209.85.192.172]:35595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXQqV-0007so-05 for 7131@debbugs.gnu.org; Tue, 18 Jul 2017 07:39:19 -0400 Original-Received: by mail-pf0-f172.google.com with SMTP id e199so10236836pfh.2 for <7131@debbugs.gnu.org>; Tue, 18 Jul 2017 04:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=KKNvSb4GnzoXr31O2GL6MwQROe4RiCea5QNbpx132rQ=; b=iSSeANDolkClsdga7Pbmr7wAVbCOI+4puyScmR8tKy3GT4c+dkJthJC0821jv2pytB Hw0S+djqDPbx8aDCwIkMqC2jCdPRPcHXcsHw1tu+qYxZjUwV7XtKV5C+ZbCP+NQ62L8l cI2HaTDu0NcFk+VCgTw1/fKG5uRovGo7uJlz+XWWw27QVsAHOl1d3/UjYrytwuxhuK98 GR+yRI5U4unanYM4DGzOrr4ToRMExaJ5hAjTMq1cyZf104vaJKnrEq4xOck9EBZJHDRa MGaYO1lrBSzE3M1AVW/kujNipUHooxjkRvyMvhs+50F6eq2JmmZ7bkzzP7npfrWiIb0n mXkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=KKNvSb4GnzoXr31O2GL6MwQROe4RiCea5QNbpx132rQ=; b=ULGfYkvFji41CzVhdU4u6f1XaXhX99Ly85Msl0UBajXLhKCAbhalTKfiBBS93QTZK7 /9LrFa3Mqw+l7R17nV5wLmo51s7OnflRutShyh4+cxM++0hAvk8gWu7uwCgrkHe7gbvi 27aVfAdCc3cIxJC7pXoR6aBxAEJ972II7WMj+6qb7s5fFSPKCoKrjBCyuBYn7UcEgKJy JEuk7/nnBTc5H0hrRRc1/Hn4tcWY47zac/20n3oakdQXxz/YTCSZGablsGxmzeiIb+Ma WvVeApo69LpwoLK7Qh6X5zBf951VShPL4bFHa8Ra1gOQF0xrm13FtAK/vhrwpRR0kYah o8yw== X-Gm-Message-State: AIVw111aYj7kHRhU5TZH4pyYcct1Bd2rOFqve4qTzJVnk43aC8nsrbOU 8Jo4Pl0eJmiawBay X-Received: by 10.98.5.70 with SMTP id 67mr1237457pff.188.1500377952826; Tue, 18 Jul 2017 04:39:12 -0700 (PDT) Original-Received: from calancha-pc (170.224.128.101.dy.bbexcite.jp. [101.128.224.170]) by smtp.gmail.com with ESMTPSA id u62sm5125509pfa.18.2017.07.18.04.39.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Jul 2017 04:39:11 -0700 (PDT) In-Reply-To: <9165B8BF5E624AAA8F9551E7A82022AF@us.oracle.com> (Drew Adams's message of "Wed, 29 Sep 2010 08:34:17 -0700") 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134711 Archived-At: "Drew Adams" writes: > (dired '("foo" "file1.c" "file2.c")) opens a Dired buffer named `foo' > with only files file1.c and file2.c. This is a useful feature. The doc > says only that if the arg is a cons then its first element is taken as > the directory name and the rest are the files to list. > > But if "foo" is already the name of an existing Dired buffer then that > existing buffer `foo' is simply displayed as it was. The explicit > file-list argument is completely ignored. > > Buffer `foo' should instead be updated (its contents replaced) to list > only the files to be included (files in the file-list arg). Agreed. > The code in question is `dired-internal-noselect'. This code comment > gives the behavior rationale for the case where the Dired buffer > already exists: > > ;; If there is an existing dired buffer for DIRNAME, just leave > ;; buffer as it is (don't even call dired-revert). > ;; This saves time especially for deep trees or with ange-ftp. > ;; The user can type `g' easily, and it is more consistent with find-file. > ;; But if SWITCHES are given they are probably different from the > ;; buffer's old value, so call dired-sort-other, which does > ;; revert the buffer. A pity we can't possibly do "Directory has > ;; changed - refresh? " like find-file does. > > (DIRNAME is a typo here BTW - the argument is actually called DIR-OR-LIST, > and if it is a cons then the name is just its car.) > > Note the rationale: If SWITCHES are not given, that is, if there was no > expressed intention to change the content of the listing, then just > reuse an existing buffer. But if such an intention was expressed, then > respect it. > > Following that rationale, the behavior for a cons arg should be to > respect the explicit file list passed, not to simply ignore it and reuse > an existing buffer. > > And since it would be problematic to test the file list for differences > from the existing listing (whether or not it came from a cons arg > previously), we should always just update the buffer to reflect the > file-list that is passed. IOW, with an explicit file list, never reuse > an existing Dired buffer of the same name. IMO, if `dired-directory' is a cons and DIR-OR-LIST is a string then we must update the buffer as well: in this case, the user want to see the full listing of that directory. I propose the following patch: --8<-----------------------------cut here---------------start------------->8--- commit a77e2a01ad3f903d877f2c71c31ed33b7bf9540c Author: Tino Calancha Date: Tue Jul 18 20:33:36 2017 +0900 dired: Revert buffer when DIRNAME is a cons * lisp/dired.el (dired-internal-noselect): Revert buffer if DIR-OR-LIST is a cons, or dired-directory is a cons and DIR-OR-LIST a string (Bug#7131). Update the comments. diff --git a/lisp/dired.el b/lisp/dired.el index 4fb4fe78f8..9d500a9f52 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -872,13 +872,15 @@ dired-auto-revert-buffer :version "23.2") (defun dired-internal-noselect (dir-or-list &optional switches mode) - ;; If there is an existing dired buffer for DIRNAME, just leave - ;; buffer as it is (don't even call dired-revert). + ;; If DIR-OR-LIST is a string and there is an existing dired buffer + ;; for it, just leave buffer as it is (don't even call dired-revert). ;; This saves time especially for deep trees or with ange-ftp. ;; The user can type `g' easily, and it is more consistent with find-file. ;; But if SWITCHES are given they are probably different from the ;; buffer's old value, so call dired-sort-other, which does ;; revert the buffer. + ;; Revert the buffer if DIR-OR-LIST is a cons or `dired-directory' + ;; is a cons and DIR-OR-LIST is a string. ;; A pity we can't possibly do "Directory has changed - refresh? " ;; like find-file does. ;; Optional argument MODE is passed to dired-find-buffer-nocreate, @@ -898,6 +900,11 @@ dired-internal-noselect (setq dired-directory dir-or-list) ;; this calls dired-revert (dired-sort-other switches)) + ;; Always revert when `dir-or-list' is a cons. Also revert + ;; if `dired-directory' is a cons but `dir-or-list' is not. + ((or (consp dir-or-list) (consp dired-directory)) + (setq dired-directory dir-or-list) + (revert-buffer)) ;; Always revert regardless of whether it has changed or not. ((eq dired-auto-revert-buffer t) (revert-buffer)) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-07-18 Repository revision: a2ee81911bdf0f37b992989a9d36bb4d2ba14052