all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present
@ 2017-03-03  3:40 Tino Calancha
  2017-03-26 22:40 ` Juri Linkov
  0 siblings, 1 reply; 11+ messages in thread
From: Tino Calancha @ 2017-03-03  3:40 UTC (permalink / raw)
  To: 25942


emacs -Q /tmp

(require 'dired-x)
(require 'ert)
;; Evaluate following sexp:
(let ((dirs '("Public" "Music"))
      (files '(".bashrc" "bar.c" "foo.c"))
      (dir (make-temp-file "Bug25942" 'dir)))
  (unwind-protect
      (progn
        (dolist (d dirs)
          (make-directory (expand-file-name d dir)))
        (dolist (f files)
          (write-region nil nil (expand-file-name f dir)))
        (dired dir)
        (dired-mark-extension "c")
        (should (= 2 (length (dired-get-marked-files)))))
    (delete-directory dir 'recursive)))
  
IMO, in this example looks better if just those files ending with
'.c' are marked i.e., to not mark 'Public' or 'Music'.
If the user really wish to mark all files ending with 'c', then would
be easy to do:
% M c \ ' RET




--8<-----------------------------cut here---------------start------------->8---
From a91a7ccdb98eff3ad520092944e6b23042d42e8f Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Fri, 3 Mar 2017 12:12:53 +0900
Subject: [PATCH] Automaticaly prepend a '.' to extension if not present

* lisp/dired-x.el (dired-mark-extension): Bug#25942.
---
 lisp/dired-x.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 6c8fb0e7da..eb228ce541 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -335,7 +335,7 @@ dired-extra-startup
 ;; Mark files with some extension.
 (defun dired-mark-extension (extension &optional marker-char)
   "Mark all files with a certain EXTENSION for use in later commands.
-A `.' is *not* automatically prepended to the string entered.
+A `.' before EXTENSION is automatically prepended when not present.
 EXTENSION may also be a list of extensions instead of a single one.
 Optional MARKER-CHAR is marker to use.
 Interactively, ask for EXTENSION.
@@ -371,7 +371,10 @@ dired-mark-extension
   (dired-mark-files-regexp
    (concat ".";; don't match names with nothing but an extension
            "\\("
-           (mapconcat 'regexp-quote extension "\\|")
+           (mapconcat (lambda (x)
+                        (regexp-quote
+                         (if (string-prefix-p "." x) x (concat "." x))))
+                      extension "\\|")
            "\\)$")
    marker-char))
 
-- 
2.11.0

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.22.8)
 of 2017-03-03
Repository revision: 55c0c3e31bc3dff83753cdba6288228bd025ac84





^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-03-31  8:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-03  3:40 bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Tino Calancha
2017-03-26 22:40 ` Juri Linkov
2017-03-27  1:30   ` Tino Calancha
2017-03-27  1:32     ` Tino Calancha
2017-03-27  2:35     ` Eli Zaretskii
2017-03-27  5:34       ` Tino Calancha
2017-03-27 14:28         ` Eli Zaretskii
2017-03-27 15:32           ` Tino Calancha
2017-03-27 22:44         ` Juri Linkov
2017-03-28  1:23           ` Tino Calancha
2017-03-31  8:34             ` Tino Calancha

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.