From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#35385: 27.0.50; Make dired-dwim-target aware of other frames Date: Mon, 22 Apr 2019 23:11:28 +0100 Message-ID: <87ef5t3d2n.fsf@tcd.ie> References: <87k1fl3e6z.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="107962"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 35385@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 23 00:12:16 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIhAc-000Rtt-19 for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Apr 2019 00:12:14 +0200 Original-Received: from localhost ([127.0.0.1]:44933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIhAa-0002i3-UD for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 18:12:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIhAS-0002hX-9u for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 18:12:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIhAQ-0004SW-JH for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 18:12:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIhAQ-0004SF-4O for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 18:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIhAP-00084T-PD for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 18:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 22:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35385 X-GNU-PR-Package: emacs Original-Received: via spool by 35385-submit@debbugs.gnu.org id=B35385.155597110030990 (code B ref 35385); Mon, 22 Apr 2019 22:12:01 +0000 Original-Received: (at 35385) by debbugs.gnu.org; 22 Apr 2019 22:11:40 +0000 Original-Received: from localhost ([127.0.0.1]:51806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIhA3-00083k-Ip for submit@debbugs.gnu.org; Mon, 22 Apr 2019 18:11:40 -0400 Original-Received: from mail-ed1-f54.google.com ([209.85.208.54]:38404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIhA1-00083S-Bi for 35385@debbugs.gnu.org; Mon, 22 Apr 2019 18:11:38 -0400 Original-Received: by mail-ed1-f54.google.com with SMTP id c1so4810905edk.5 for <35385@debbugs.gnu.org>; Mon, 22 Apr 2019 15:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=rEDNKQDpcGy7u8oK/vfcEe6th27fPFR2lMfBxjYn8Vw=; b=xNE5sPXz+JwNfWamca5glKAtOeQKwIUEkb6KpCtI//4VSj7ykRMpkR/r7hQ7DbcK6l Qbous+BRfJkMxeKvjJ4meWizhoNDNoHeIGYjTNmkbutsMxROrgzp4U22CFXsAwYHAVnw d0rm0AL2sur9v0QCNKMkojXSS1cvvc+qR+0OYSoAtwBwuM5ySe8yaIOptsXdUFk+kow1 f7Hl2Ui2KLmIl1HV48ENpCd3ZU4p2LrqW5XnfhtQUrp9qul+0rib4j5BNR/z0OcZOKL+ xrcA0yd0IsIK73MM2qcaIGPtHuX8Xz7LCUKr1DAQAOt40zNSlbvlC4n12ODtQ1jdpoIi 6jbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=rEDNKQDpcGy7u8oK/vfcEe6th27fPFR2lMfBxjYn8Vw=; b=RlHNJ5SgHhq012NqZHSgpyJFTp6ri4Fpo8Ri0IdyNbILJKtpab60FMjrEY3BaAvme/ rqhn07MZ29e55jNDj3rq/tLmgXgo9m/X2i/CQsu7kLw4thU2upX4GmiKCyDgRqJWW5ri vWGxSXDdZcwrIc/HvlVC1RT5pErRwA1jZrWIyHJETV8Wnm/fX9c6po3RxqjCwP6OBlOk DBN+LDpaVUkeb3JtBG8mb9KfF+OTBzUQ1Gaw6Gqqk3sNUooGZ3o6K3h2TfU20q9qNe6V YBy+LZsA/pJuRsMOjxcsCLoLwQFQ+q1QSEcAzCjSX+X9zN7DsJ3WRLSdCf3UzPhj1c5r LP+w== X-Gm-Message-State: APjAAAVYi+CUUzLngefqug8X2hFYcyDIZ3H8tyeu03S06cK8Pxswi+fO ILqV6FVI3xcATBrrEBmsUg37CvFzaqpogw== X-Google-Smtp-Source: APXvYqwYXM/QUlsae4U7vqCsIqNyR2WFfMfVauOFUl26RytcNALUwt14LUHy5TqrqiBLt4t4eY4fdg== X-Received: by 2002:a17:907:1009:: with SMTP id ox9mr10885967ejb.292.1555971090254; Mon, 22 Apr 2019 15:11:30 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:8f5:8e00:4345:7c72]) by smtp.gmail.com with ESMTPSA id d6sm3880731edq.65.2019.04.22.15.11.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Apr 2019 15:11:29 -0700 (PDT) In-Reply-To: <87k1fl3e6z.fsf@tcd.ie> (Basil L. Contovounesios's message of "Mon, 22 Apr 2019 22:47:16 +0100") 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158086 Archived-At: --=-=-= Content-Type: text/plain tags 35385 patch quit --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-dired-dwim-target-aware-of-other-frames.patch >From 463ccbe8ba96aee0a2cdfd49342270a33e161db2 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Mon, 22 Apr 2019 14:33:38 +0100 Subject: [PATCH] Make dired-dwim-target aware of other frames * lisp/dired.el (dired-dwim-target-frames): New user option. (bug#35385) (dired-dwim-target): Mention it in docstring. * lisp/dired-aux.el (dired-dwim-target-directory): Use it. * doc/emacs/dired.texi (Operating on Files): Document it. * etc/NEWS: Announce it. Merge duplicate Dired outlines. * test/lisp/dired-tests.el: Remove unnecessary require and pacify byte-compiler. --- doc/emacs/dired.texi | 23 ++++++++++++++++++++--- etc/NEWS | 16 +++++++++------- lisp/dired-aux.el | 34 +++++++++++++++++----------------- lisp/dired.el | 20 +++++++++++++++++--- test/lisp/dired-tests.el | 3 +-- 5 files changed, 64 insertions(+), 32 deletions(-) diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index 9f454ea2ad..b8b1d73d8f 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi @@ -644,13 +644,30 @@ Operating on Files commands, use the same conventions to decide which files to work on. @vindex dired-dwim-target +@vindex dired-dwim-target-frames @cindex two directories (in Dired) Commands which ask for a destination directory, such as those which copy and rename files or create links for them, try to guess the default target directory for the operation. Normally, they suggest the Dired -buffer's default directory, but if the variable @code{dired-dwim-target} -is non-@code{nil}, and if there is another Dired buffer displayed in the -next window, that other buffer's directory is suggested instead. +buffer's default directory, but if the option @code{dired-dwim-target} +is non-@code{nil}, and if there is another Dired buffer displayed in +another window, that other buffer's directory is suggested instead. The +option @code{dired-dwim-target-frames} controls which windows to +consider: + +@itemize @bullet +@item @code{nil} +means to consider windows on the selected frame. + +@item @code{t} +means to consider windows on all existing frames. + +@item @code{visible} +means to consider windows on all visible frames. + +@item 0 +means to consider windows on all frames on the current terminal. +@end itemize Here are the file-manipulating Dired commands that operate on files. diff --git a/etc/NEWS b/etc/NEWS index b13ab47768..d1761c6415 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -507,6 +507,15 @@ remapped to these, respectively. +++ *** New command 'dired-create-empty-file'. ++++ +*** The new user option 'dired-create-destination-dirs' controls whether +'dired-do-copy' and 'dired-rename-file' should create non-existent +directories in the destination. + ++++ +*** New user option 'dired-dwim-target-frames'. +This option controls which frames 'dired-dwim-target' applies to. + ** Change Logs and VC *** Recording ChangeLog entries doesn't require an actual file. @@ -857,13 +866,6 @@ unescaping text. The maximum level is used by default; customize 'font-lock-maximum-decoration' to tone down the decoration. -** Dired - -+++ -*** The new user option 'dired-create-destination-dirs' controls whether -'dired-do-copy' and 'dired-rename-file' should create non-existent -directories in the destination. - ** Help --- diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index b81c0d1a4f..c3df5c982b 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1937,23 +1937,21 @@ dired-mark-read-file-name (format prompt (dired-mark-prompt arg files)) dir default)) (defun dired-dwim-target-directory () - ;; Try to guess which target directory the user may want. - ;; If there is a dired buffer displayed in one of the next windows, - ;; use its current subdir, else use current subdir of this dired buffer. - (let ((this-dir (and (eq major-mode 'dired-mode) - (dired-current-directory)))) - ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode - (if dired-dwim-target - (let* ((other-win (get-window-with-predicate - (lambda (window) - (with-current-buffer (window-buffer window) - (eq major-mode 'dired-mode))))) - (other-dir (and other-win - (with-current-buffer (window-buffer other-win) - (and (eq major-mode 'dired-mode) - (dired-current-directory)))))) - (or other-dir this-dir)) - this-dir))) + "Try to guess which target directory the user may want. +If there is a Dired buffer displayed in another window (subject +to `dired-dwim-target' and `dired-dwim-target-frames'), return +its current subdirectory, otherwise return that of the current +Dired buffer." + (let ((win (if dired-dwim-target + (get-window-with-predicate + (lambda (window) + (with-current-buffer (window-buffer window) + (eq major-mode 'dired-mode))) + nil dired-dwim-target-frames (selected-window)) + (selected-window)))) + (with-current-buffer (window-buffer win) + (and (eq major-mode 'dired-mode) + (dired-current-directory))))) (defun dired-dwim-target-defaults (fn-list target-dir) ;; Return a list of default values for file-reading functions in Dired. @@ -2839,6 +2837,8 @@ dired-do-isearch-regexp (multi-isearch-files-regexp (dired-get-marked-files nil nil 'dired-nondirectory-p nil t))) +(declare-function fileloop-continue "fileloop" ()) + ;;;###autoload (defun dired-do-search (regexp) "Search through all marked files for a match for REGEXP. diff --git a/lisp/dired.el b/lisp/dired.el index 63082fe392..710fcfc0f4 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -185,14 +185,28 @@ dired-keep-marker-symlink (defcustom dired-dwim-target nil "If non-nil, Dired tries to guess a default target directory. -This means: if there is a Dired buffer displayed in the next -window, use its current directory, instead of this Dired buffer's -current directory. +This means: if there is a Dired buffer displayed in some window, +use its current directory, instead of this Dired buffer's current +directory. See `dired-dwim-target-frames' for which frames to +consider when looking for a target window. The target is used in the prompt for file copy, rename etc." :type 'boolean :group 'dired) +(defcustom dired-dwim-target-frames nil + "Determines which frames to consider for `dired-dwim-target'. +It has a similar meaning to the ALL-FRAMES argument of +`next-window'. nil means consider windows on only the selected +frame; t on all existing frames; `visible' on all visible frames; +and 0 on all frames on the current terminal." + :type '(choice (const :tag "Selected frame only" nil) + (const :tag "All existing frames" t) + (const :tag "All visible frames" visible) + (const :tag "All frames on current terminal" 0)) + :version "27.1" + :group 'dired) + (defcustom dired-copy-preserve-time t "If non-nil, Dired preserves the last-modified time in a file copy. \(This works on only some systems.)" diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el index 71ffcdd545..c4728e7a06 100644 --- a/test/lisp/dired-tests.el +++ b/test/lisp/dired-tests.el @@ -20,7 +20,6 @@ ;;; Code: (require 'ert) (require 'dired) -(require 'nadvice) (ert-deftest dired-autoload () "Tests to see whether dired-x has been autoloaded" @@ -54,7 +53,7 @@ (when (buffer-live-p buf) (kill-buffer buf))) (delete-directory dir 'recursive)))) -(defvar dired-dwim-target) +(defvar dired-query) (ert-deftest dired-test-bug25609 () "Test for https://debbugs.gnu.org/25609 ." (let* ((from (make-temp-file "foo" 'dir)) -- 2.20.1 --=-=-= Content-Type: text/plain "Basil L. Contovounesios" writes: > Patch implementing this to follow. Now attached. WDYT? Thanks, -- Basil --=-=-=--