From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#35385: 27.0.50; Make dired-dwim-target aware of other frames Date: Sun, 10 Nov 2019 22:38:38 +0200 Organization: LINKOV.NET Message-ID: <87zhh31u55.fsf@mail.linkov.net> References: <87k1fl3e6z.fsf@tcd.ie> <87zhj4osjw.fsf@gnus.org> <877e67x6ny.fsf@mail.linkov.net> <87impp1djl.fsf@mail.linkov.net> <138859c1-a7e0-f40d-4623-635826decd90@gmx.at> <87y2yknhja.fsf@mail.linkov.net> <875zkbrt4j.fsf@mail.linkov.net> <87zhhb1n52.fsf@web.de> <8736f29dsv.fsf@mail.linkov.net> <87y2wqrxju.fsf@web.de> 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="147476"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: "Basil L. Contovounesios" , Lars Ingebrigtsen , 35385@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 10 21:57:43 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iTuHG-000cEL-B2 for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Nov 2019 21:57:42 +0100 Original-Received: from localhost ([::1]:46018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iTuHF-0003Gp-5P for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Nov 2019 15:57:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50114) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iTuGd-0002OD-Tk for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2019 15:57:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iTuGc-0002oY-Nt for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2019 15:57:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iTuGc-0002oI-Ia for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2019 15:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iTuGc-0003Nh-GN for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2019 15:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Nov 2019 20:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35385-submit@debbugs.gnu.org id=B35385.157341937212906 (code B ref 35385); Sun, 10 Nov 2019 20:57:02 +0000 Original-Received: (at 35385) by debbugs.gnu.org; 10 Nov 2019 20:56:12 +0000 Original-Received: from localhost ([127.0.0.1]:52604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iTuFn-0003M5-Nn for submit@debbugs.gnu.org; Sun, 10 Nov 2019 15:56:12 -0500 Original-Received: from caracal.birch.relay.mailchannels.net ([23.83.209.30]:51777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iTuFl-0003Lx-Hj for 35385@debbugs.gnu.org; Sun, 10 Nov 2019 15:56:10 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 79A1374090B; Sun, 10 Nov 2019 20:56:08 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a14.g.dreamhost.com (100-96-45-192.trex.outbound.svc.cluster.local [100.96.45.192]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0F3B37405A1; Sun, 10 Nov 2019 20:56:08 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a14.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Sun, 10 Nov 2019 20:56:08 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Lettuce-Inform: 5bd9471d57501367_1573419368316_685084837 X-MC-Loop-Signature: 1573419368316:1670965401 X-MC-Ingress-Time: 1573419368316 Original-Received: from pdx1-sub0-mail-a14.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a14.g.dreamhost.com (Postfix) with ESMTP id AC6DF98266; Sun, 10 Nov 2019 12:56:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=TT6XAwmeCCDj+UfH4QNFLXCF+wA=; b= c1EFmmsRRHPZsb3C6nZoUGShSyro30ovpGDaLXkbxrdZBLq8/AKmL0knZgFMuhST qVAmzSKs+r0N0No2S94cf+gfjZ4e1tQUoWox51CP7MmpBoOnhwqvooW01t/nYM0u 0KE2103G90jjMrwCiMx6DziZIyX8kp+PAsbEeL4RYes= Original-Received: from mail.jurta.org (m91-129-102-1.cust.tele2.ee [91.129.102.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a14.g.dreamhost.com (Postfix) with ESMTPSA id CB84C9872B; Sun, 10 Nov 2019 12:55:59 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a14 In-Reply-To: <87y2wqrxju.fsf@web.de> (Michael Heerdegen's message of "Fri, 08 Nov 2019 20:13:41 +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:171391 Archived-At: --=-=-= Content-Type: text/plain >> So dired-dwim-target could have a similar defcustom >> with choices for recent/next window. > > There are lots of imaginable user preferences, so I would prefer a > solution where one can specify a function. Would you want to use > `dired-dwim-target' for that? This would be a natural choice, indeed. Please try this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-dwim-target-function.patch diff --git a/lisp/dired.el b/lisp/dired.el index 05789a3516..cfee990a74 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -190,8 +190,16 @@ dired-dwim-target Dired buffer's current directory. The target is used in the prompt for file copy, rename etc." - :type 'boolean - :group 'dired) + :type '(choice + (const :tag "No guess" nil) + (function-item :tag "Prefer most recently used windows" + dired-dwim-target-recent) + (function-item :tag "Prefer next windows" + dired-dwim-target-next) + (function :tag "Your function") + (other :tag "Try to guess" t)) + :group 'dired + :version "27.1") (defcustom dired-copy-preserve-time t "If non-nil, Dired preserves the last-modified time in a file copy. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 722d036e3f..a3d0ad61dd 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1993,6 +1993,12 @@ dired-mark-read-file-name (format prompt (dired-mark-prompt arg files)) dir default)) (defun dired-dwim-target-directories () + (cond ((functionp dired-dwim-target) + (funcall dired-dwim-target)) + (dired-dwim-target + (dired-dwim-target-recent)))) + +(defun dired-dwim-target-recent () ;; Return directories from all visible windows with dired-mode buffers ;; ordered by most-recently-used. (mapcar #'cdr (sort (mapcan (lambda (w) @@ -2004,6 +2010,15 @@ dired-dwim-target-directories (window-list-1 nil 'nomini 'visible))) (lambda (a b) (> (car a) (car b)))))) +(defun dired-dwim-target-next () + (mapcan (lambda (w) + (with-current-buffer (window-buffer w) + (when (eq major-mode 'dired-mode) + (list (dired-current-directory))))) + (delq (selected-window) (window-list-1 + (next-window nil 'nomini 'visible) + 'nomini 'visible)))) + (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, --=-=-=--