From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Re: Dired: Improve symmetry in mark/unmark commands bound to keys Date: Mon, 3 Oct 2016 18:21:51 +0900 (JST) Message-ID: References: <877fa12iyq.fsf@linux-m68k.org> <83h995ay04.fsf@gnu.org> <87y42h13pi.fsf@linux-m68k.org> <83fuopax4g.fsf@gnu.org> <87twd512pk.fsf@linux-m68k.org> <83bmzacwmk.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1485055817-1475486514=:16224" X-Trace: blaine.gmane.org 1475486548 13301 195.159.176.226 (3 Oct 2016 09:22:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 3 Oct 2016 09:22:28 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Emacs developers , schwab@linux-m68k.org, drew.adams@oracle.com, Tino Calancha To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 03 11:22:23 2016 Return-path: Envelope-to: ged-emacs-devel@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 1bqzRx-00029a-Cn for ged-emacs-devel@m.gmane.org; Mon, 03 Oct 2016 11:22:17 +0200 Original-Received: from localhost ([::1]:35505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqzRv-000378-C0 for ged-emacs-devel@m.gmane.org; Mon, 03 Oct 2016 05:22:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqzRl-00034a-8N for emacs-devel@gnu.org; Mon, 03 Oct 2016 05:22:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bqzRj-0004vQ-Dx for emacs-devel@gnu.org; Mon, 03 Oct 2016 05:22:05 -0400 Original-Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:36332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bqzRd-0004oy-At; Mon, 03 Oct 2016 05:21:57 -0400 Original-Received: by mail-pf0-x229.google.com with SMTP id i85so10729161pfa.3; Mon, 03 Oct 2016 02:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=7jjCwa9w0w4si2Zw3AALYB4QrRCHjipZrMQt7hTnwys=; b=foTjEiDC1hjebA6gPH21eysCxcI91dWCAy3AQKAIbD7quoWdCtQ/qcva2zRzEP/6h0 Yw56Ff+7ZG5MnFuFJ8YWCUtq1Z3rDTgpvynS0FmoZykdfpNBsQKnBiTBxpuQIgFCpczK heWVDm2jw5SDLjoPyv6pZDneUJ9semutOo4kHf4yQIf9uBhcdDp2974SyaLkxyptx+jn zWmqud92FXu0lVTFApF122ctzoFcw5BRp80yCtgVgoSNRVYosVl4GNoUiDaS/YEg71si zbkl/F6jNW0Qfne/X7jsa7OuzAlr97szp1Tb6sSVuwQy64fDMo0NQRUSmxf3xbK/x2e4 nH1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=7jjCwa9w0w4si2Zw3AALYB4QrRCHjipZrMQt7hTnwys=; b=Wo6UYoD+0dd9zE+k4pGKm+mBuGWqjCj8z6ZVj/rhWrj5IWEcQWSC6KDov0G9ZyJ04q 2qqosNwBT6IiX71fedXNjcmXvNaovYLBQMsHdRwOUuImwDR2phdJ+l47zMNkns3H62XF gI6RpIonfaCk2V7XS6KIdIMzYRH6Z8/4eYgsjJxuQtnz/Vr9M5TxqgpISeYXMTRmIAFb RD93e6aU4IYhfU5ROvrZu+H2SD46AYln5bSdHcALXwMsEP6NdnpPVe1Ns3aQjPWNo0ek o03CJ8tnnt9dbAfQ6U2iao1yl8nYT48BNwA8yjYLXQNEZBmCA/iBK2Iw8kOCLa4V5Tji ra5A== X-Gm-Message-State: AA6/9RkA9N1iHIWHcaqjtqhCnrLV1r4YaGxG/oZ13fdnEJ82DCItf5GrLeDviJwwRrXw/A== X-Received: by 10.98.82.200 with SMTP id g191mr35638097pfb.84.1475486515654; Mon, 03 Oct 2016 02:21:55 -0700 (PDT) Original-Received: from calancha-pc ([103.5.140.133]) by smtp.gmail.com with ESMTPSA id x66sm45566299pfb.86.2016.10.03.02.21.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2016 02:21:54 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83bmzacwmk.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207951 Archived-At: --8323329-1485055817-1475486514=:16224 Content-Type: text/plain; format=flowed; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT On Mon, 26 Sep 2016, Eli Zaretskii wrote: >> From: Tino Calancha >> Date: Tue, 27 Sep 2016 01:30:35 +0900 (JST) >> >>> I believe Eli has proposed a solution that offers a middle ground. Can we move >>> to discussing that? >> Yes, we can talk about that. >> Eli suggestion would be consistent with Dired if, for instance: >> I) C-u * . el RET >> ;; unmark >> II) C-u C-u * . el RET >> ;; prompt for the marker char. > > FWIW, I'm okay with this. > >> I mean, we should not invert the number of C-u's in I) II) > > Indeed, no need. > > Thanks. Thank you Eli. I propose following patch: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 53e519484ea22e47f12ac761e2684e38cdf55d0e Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Mon, 3 Oct 2016 18:15:27 +0900 Subject: [PATCH] dired-mark-extension: Unmark if called with C-u prefix See discussion in #Bug2518 and: https://lists.gnu.org/archive/html/emacs-devel/2016-09/msg00711.html * lisp/dired-x.el (dired-mark-extension): Update interactive calls: a prefix arg C-u unmark files; a prefix C-u C-u prompt for MARKER-CHAR and mark files with it. (dired-mark-sexp): Show in the prompt that we are unmarking if called with a prefix argument. * doc/misc/dired-x.texi: Update documentation for 'dired-mark-extension'. --- doc/misc/dired-x.texi | 6 ++++-- lisp/dired-x.el | 38 +++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 2391852..0b03486 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -710,8 +710,10 @@ Advanced Mark Commands @findex dired-mark-extension Mark all files with a certain extension for use in later commands. A @samp{.} is not automatically prepended to the string entered, you must type it -explicitly. If invoked with a prefix argument, this command asks for -a character to use as the marker. +explicitly. +If invoked with prefix argument @kbd{C-u}, this command unmark files instead. +Calling it with the @kbd{C-u C-u} prefix, asks for a character to use +as the marker, and mark files with it. When called from Lisp, @var{extension} may also be a list of extensions and an optional argument @var{marker-char} specifies the marker used. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 7d73c42..7f0ab95 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -334,17 +334,27 @@ dired-mark-extension A `.' is *not* automatically prepended to the string entered. EXTENSION may also be a list of extensions instead of a single one. Optional MARKER-CHAR is marker to use. -Interactively, ask for EXTENSION, and if invoked with a prefix -argument, for MARKER-CHAR as well." +Interactively, ask for EXTENSION. +Prefixed with one C-u, unmark files instead. +Prefixed with two C-u¢s, prompt for MARKER-CHAR and mark files with it." (interactive - (list (read-string "Marking extension: ") - (and current-prefix-arg - (let* ((dflt (char-to-string dired-marker-char)) - (input (read-string - (format - "Marker character to use (default %s): " dflt) - nil nil dflt))) - (aref input 0))))) + (let ((suffix + (read-string (format "%s extension: " + (if (equal current-prefix-arg '(4)) + "UNmarking" + "Marking")))) + (marker + (pcase current-prefix-arg + ('(4) ?\s) + ('(16) + (let* ((dflt (char-to-string dired-marker-char)) + (input (read-string + (format + "Marker character to use (default %s): " dflt) + nil nil dflt))) + (aref input 0))) + (_ dired-marker-char)))) + (list suffix marker))) (or (listp extension) (setq extension (list extension))) (dired-mark-files-regexp @@ -1470,7 +1480,13 @@ dired-mark-sexp ;; (string-match "foo" sym) into which a user would soon fall. ;; Give `equal' instead of `=' in the example, as this works on ;; integers and strings. - (interactive "xMark if (lisp expr): \nP") + (interactive + (list (read--expression + (format "%s if (lisp expr): " + (if current-prefix-arg + "UNmark" + "Mark"))) + current-prefix-arg)) (message "%s" predicate) (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)) inode s mode nlink uid gid size time name sym) -- 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.3 (x86_64-pc-linux-gnu, GTK+ Version 3.22.0) of 2016-10-03 built on calancha-pc Repository revision: 8cd975cebd588d5435fa2b333dba6c526e602933 --8323329-1485055817-1475486514=:16224--