unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>,
	schwab@linux-m68k.org, drew.adams@oracle.com,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: Dired: Improve symmetry in mark/unmark commands bound to keys
Date: Mon, 3 Oct 2016 18:21:51 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1610031820240.16224@calancha-pc> (raw)
In-Reply-To: <83bmzacwmk.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5012 bytes --]



On Mon, 26 Sep 2016, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha@gmail.com>
>> 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 <tino.calancha@gmail.com>
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

  reply	other threads:[~2016-10-03  9:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-24 17:31 Dired: Improve symmetry in mark/unmark commands bound to keys Tino Calancha
2016-09-24 18:12 ` Eli Zaretskii
2016-09-24 18:25   ` Tino Calancha
2016-09-24 19:31 ` Andreas Schwab
2016-09-24 19:39   ` Eli Zaretskii
2016-09-24 19:46     ` Andreas Schwab
2016-09-24 19:58       ` Eli Zaretskii
2016-09-24 20:07         ` Andreas Schwab
2016-09-24 23:49           ` Drew Adams
2016-09-25  9:06             ` Tino Calancha
2016-09-25 18:55           ` John Wiegley
2016-09-26  9:23             ` Tino Calancha
2016-09-26 11:05               ` Tino Calancha
2016-09-26 15:02               ` Eli Zaretskii
2016-09-26 15:06               ` Eli Zaretskii
2016-09-26 15:47               ` John Wiegley
2016-09-26 16:30                 ` Tino Calancha
2016-09-26 19:02                   ` Eli Zaretskii
2016-10-03  9:21                     ` Tino Calancha [this message]
2016-10-03  9:54                       ` Eli Zaretskii
2016-10-03 11:15                         ` Tino Calancha
2016-09-26 21:52                   ` John Wiegley
2016-09-25 19:14           ` Eli Zaretskii
2016-09-25 22:43             ` Andreas Schwab
2016-09-25 22:58             ` Andreas Schwab
2016-09-25 23:00             ` Andreas Schwab
2016-09-26  2:38               ` Eli Zaretskii
2016-09-26  8:33                 ` Andreas Schwab
2016-09-26 14:59                   ` Eli Zaretskii
2016-09-24 19:49     ` Tino Calancha
     [not found] <<alpine.DEB.2.20.1609250230400.4103@calancha-pc>
     [not found] ` <<83oa3db20a.fsf@gnu.org>
2016-09-24 18:53   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1610031820240.16224@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).