GNU bug report logs - #25578
[PATCH] Prompt default extension in dired-mark-extension

Previous Next

Package: emacs;

Reported by: Chunyang Xu <mail <at> xuchunyang.me>

Date: Mon, 30 Jan 2017 13:45:02 UTC

Severity: wishlist

Tags: patch

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25578 in the body.
You can then email your comments to 25578 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25578; Package emacs. (Mon, 30 Jan 2017 13:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Chunyang Xu <mail <at> xuchunyang.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 30 Jan 2017 13:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Chunyang Xu <mail <at> xuchunyang.me>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Prompt default extension in dired-mark-extension
Date: Mon, 30 Jan 2017 21:44:24 +0800
[Message part 1 (text/plain, inline)]
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.

[0001-Prompt-default-extension-in-dired-mark-extension.patch (text/plain, inline)]
From 21769fb5b92d19fbc428f8022d2aa3cc81a55db2 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail <at> xuchunyang.me>
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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25578; Package emacs. (Sun, 05 Feb 2017 23:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 25578 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Chunyang Xu <mail <at> xuchunyang.me>
Cc: 25578 <at> debbugs.gnu.org
Subject: Re: bug#25578: [PATCH] Prompt default extension in
 dired-mark-extension
Date: Mon, 06 Feb 2017 01:20:23 +0200
> 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.

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:

diff --git a/lisp/dired.el b/lisp/dired.el
index 2733372..7d7af0b 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3361,7 +3361,12 @@ (defun dired-mark-files-regexp (regexp &optional marker-char)
   (interactive
    (list (read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
                               " files (regexp): ")
-                      nil 'dired-regexp-history)
+                      (delq nil (list (dired-get-filename t t)
+                                      (and (dired-get-filename nil t)
+                                           (concat (regexp-quote (file-name-extension
+                                                                  (dired-get-filename nil t) t))
+                                                   "\\'"))))
+                      'dired-regexp-history)
 	 (if current-prefix-arg ?\040)))
   (let ((dired-marker-char (or marker-char dired-marker-char)))
     (dired-mark-if




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25578; Package emacs. (Mon, 06 Feb 2017 13:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 25578 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 25578 <at> debbugs.gnu.org
Cc: tino.calancha <at> gmail.com, Chunyang Xu <mail <at> xuchunyang.me>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#25578: [PATCH] Prompt default extension in
 dired-mark-extension
Date: Mon, 06 Feb 2017 22:58:39 +0900
Juri Linkov <juri <at> linkov.net> writes:

>> 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.




Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Mon, 27 Feb 2017 22:47:01 GMT) Full text and rfc822 format available.

Notification sent to Chunyang Xu <mail <at> xuchunyang.me>:
bug acknowledged by developer. (Mon, 27 Feb 2017 22:47:02 GMT) Full text and rfc822 format available.

Message #16 received at 25578-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Chunyang Xu <mail <at> xuchunyang.me>, 25578-done <at> debbugs.gnu.org
Subject: Re: bug#25578: [PATCH] Prompt default extension in
 dired-mark-extension
Date: Tue, 28 Feb 2017 00:45:35 +0200
>>> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 28 Mar 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 143 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.