Subject: bug#25578: closed (Re: bug#25578: [PATCH] Prompt default extension in dired-mark-extension)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 27 Feb 2017 22:47:02 +0000

Your bug report

#25578: [PATCH] Prompt default extension in dired-mark-extension

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
25578: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25578
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#25578: [PATCH] Prompt default extension in dired-mark-extension
From: Juri Linkov <[email-masked]>
To: Tino Calancha <[email-masked]>
Cc: Chunyang Xu <[email-masked]>, [email-masked]
Date: Tue, 28 Feb 2017 00:45:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>>> I want 'M-x dired-mark-extension' (from dired-x) in Dired to use the
>>> extension of the file at point as default extension, when it is
>>> possible. Because, in this way, I usually no longer need to type the
>>> extension manually, which saves some time for me–someone can't type
>>> English words quickly and accurately.
>>
>> Thanks, I think your patch is a useful addition.
> I agree, it's a good default value.
>>
>> Also I'm using a similar feature for another Dired command
>> ‘dired-mark-files-regexp’ that could provide similar defaults
>> based on the current file and its extension:
> That's also fine.

Thanks for your support.  Done and done.

Subject: [PATCH] Prompt default extension in dired-mark-extension
From: Chunyang Xu <[email-masked]>
To: [email-masked]
Date: Mon, 30 Jan 2017 21:44:24 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi.

I want 'M-x dired-mark-extension' (from dired-x) in Dired to use the
extension of the file at point as default extension, when it is
possible. Because, in this way, I usually no longer need to type the
extension manually, which saves some time for me–someone can't type
English words quickly and accurately.

>From 21769fb5b92d19fbc428f8022d2aa3cc81a55db2 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <[email-masked]>
Date: Mon, 30 Jan 2017 21:10:37 +0800
Subject: [PATCH] Prompt default extension in dired-mark-extension

* lisp/dired-x.el (dired-mark-extension): Prompt default extension
base on extension of file at point.

Copyright-paperwork-exempt: yes
---
 lisp/dired-x.el | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 86c95372c2..6c8fb0e7da 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -342,22 +342,29 @@ dired-mark-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
-   (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))))
+   (let* ((default
+            (let ((file (dired-get-filename nil t)))
+              (when file
+                (file-name-extension file))))
+          (suffix
+           (read-string (format "%s extension%s: "
+                                (if (equal current-prefix-arg '(4))
+                                    "UNmarking"
+                                  "Marking")
+                                (if default
+                                    (format " (default %s)" default)
+                                  "")) nil nil default))
+          (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)))
-- 
2.11.0