From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Date: Tue, 28 Mar 2017 00:32:25 +0900 Message-ID: <871stid9bq.fsf@calancha-pc> References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> <83poh294lq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1490628824 27621 195.159.176.226 (27 Mar 2017 15:33:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 27 Mar 2017 15:33:44 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25942@debbugs.gnu.org, juri@linkov.net, tino.calancha@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 27 17:33:39 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1csWeF-0006Nx-PI for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Mar 2017 17:33:35 +0200 Original-Received: from localhost ([::1]:47591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csWeL-0002IV-RI for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Mar 2017 11:33:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csWdo-00024b-EN for bug-gnu-emacs@gnu.org; Mon, 27 Mar 2017 11:33:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csWdi-0008Ox-33 for bug-gnu-emacs@gnu.org; Mon, 27 Mar 2017 11:33:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csWdh-0008Ob-Qr for bug-gnu-emacs@gnu.org; Mon, 27 Mar 2017 11:33:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1csWdh-0003au-J4 for bug-gnu-emacs@gnu.org; Mon, 27 Mar 2017 11:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Mar 2017 15:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25942 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 25942-submit@debbugs.gnu.org id=B25942.149062875713749 (code B ref 25942); Mon, 27 Mar 2017 15:33:01 +0000 Original-Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 15:32:37 +0000 Original-Received: from localhost ([127.0.0.1]:47588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csWdJ-0003Zg-0u for submit@debbugs.gnu.org; Mon, 27 Mar 2017 11:32:37 -0400 Original-Received: from mail-pg0-f52.google.com ([74.125.83.52]:36028) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csWdH-0003ZP-52 for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 11:32:35 -0400 Original-Received: by mail-pg0-f52.google.com with SMTP id g2so43197646pge.3 for <25942@debbugs.gnu.org>; Mon, 27 Mar 2017 08:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=RiCUiMNzt5EX/bQa+Qim1t/8GcPmpynSLpRSwMIphcI=; b=pFcuzIr85h4bitsI5dEt03wYg23ht6VqDUbOk9HhDX1i0UnUMTh5BuXN8csdop6KkR 6nPJ9pWsKpgJJMrfyjm8NJ2u7kYHEjmqxytMhUIfgbOUGvm7NKh4gxlc1nBelAKce24i jUvi4Bjw8tu7vLKdhx3fQppwhIuM1tMpWV69JUQ0Xvm1vPMRtCXo5pSzbu2ZJ5cJxfBW rW5iOYvCxRnzXvpw4C6zXTH78TmypOz0gJ2gWhMdTkIUAQZVoMWaD3SqZRX2R2pT2S6T 5Sk0UWh7rU6E1NhSQP0VExQQm6MOPgIsjs9DsVVBZE+irbrIYJ2tTxFGv7bpSQXJ3Ig0 jE2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=RiCUiMNzt5EX/bQa+Qim1t/8GcPmpynSLpRSwMIphcI=; b=eUP7E7gGUAgnZFGqWXhtwIdcnSdzCvfwF7p8Vn7wJrw4NIPRCAsw8U210twsTAUQIU uVMeuwARSD7bl458lpn10Odv8Dv8XmzeT6BbXQFzlqQtQiytImiz06R6LVOLTHiPHjEp T8Ryw5TtJ1VIalcqHWnn/tIt0T+kinowfEhLWK7Nsz1opNl87jOhJLsCyboCX2MxOf/w HbxAK0UDROrcZxcR57xpcwepUvthQ6iqJ9SAGXijAZ5wwSLcjGYea4u5OqZqUkLBZE7v RNzq5ThTcFkrcpzhW9/3w8ODwmFfOPwXoa7Mhy5izThXdCO4Sk8SZIegP+ynmeo6j7Ba WIeQ== X-Gm-Message-State: AFeK/H1YP+HptB+ii8CI6oZnIU1kijJdptNg1VmTQnFPfTB8VthNtfOZ2qFvPfPRlXd7Iw== X-Received: by 10.99.121.78 with SMTP id u75mr24628363pgc.202.1490628749263; Mon, 27 Mar 2017 08:32:29 -0700 (PDT) Original-Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id 198sm1925920pgb.51.2017.03.27.08.32.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Mar 2017 08:32:28 -0700 (PDT) In-Reply-To: <83poh294lq.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Mar 2017 17:28:01 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131014 Archived-At: Eli Zaretskii writes: >> From: Tino Calancha >> Cc: 25942@debbugs.gnu.org, juri@linkov.net, tino.calancha@gmail.com >> Date: Mon, 27 Mar 2017 14:34:30 +0900 >> >> +@item dired-mark-suffix >> +@findex dired-mark-suffix >> +Mark all files with a certain suffix for use in later commands. A @samp{.} >> +is not automatically prepended to the string entered, you must type it >> +explicitly. This is different than @var{dired-mark-extension} which prepends > ^^^^^^^^^^^^^^ > "different from" or "in contrast to". > >> +If invoked with prefix argument @kbd{C-u}, this command unmark files instead. > ^^^^^^ > "unmarks" > >> +When called from Lisp, @var{suffix} may also be a list of suffices > ^^^^^^^^ > "suffixes" > >> ;; 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. > > "A `.' is automatically prepended to EXTENSION when not present." Thank you very much for the comments. Below is the updated patch: --8<-----------------------------cut here---------------start------------->8--- >From de5dc41fa83b32ee81fad16a13f4192115bcd970 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 28 Mar 2017 00:27:34 +0900 Subject: [PATCH] dired-mark-suffix: New command Now dired-mark-extension prepends '.' to extension when not present. Add command dired-mark-suffix to preserve the previous behaviour (Bug#25942). * lisp/dired-x.el (dired-mark-suffix): New command; mark files ending in a given suffix. (dired--mark-suffix-interactive-spec): New defun. (dired-mark-extension, dired-mark-suffix): Use it. * doc/misc/dired-x.texi (Advanced Mark Commands): Update manual. ; * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 26.1): ; Mention these changes. --- doc/misc/dired-x.texi | 18 ++++++++++-- etc/NEWS | 5 ++++ lisp/dired-x.el | 81 ++++++++++++++++++++++++++++++++++----------------- 3 files changed, 74 insertions(+), 30 deletions(-) diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 1e6f4b03bb..bf103256f2 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -721,15 +721,27 @@ Advanced Mark Commands @item dired-mark-extension @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 prefix argument @kbd{C-u}, this command unmark files instead. +is automatically prepended to the string entered when not present. +If invoked with prefix argument @kbd{C-u}, this command unmarks files instead. If called with the @kbd{C-u C-u} prefix, asks for a character to use as the marker, and marks 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. +@item dired-mark-suffix +@findex dired-mark-suffix +Mark all files with a certain suffix for use in later commands. A @samp{.} +is not automatically prepended to the string entered, you must type it +explicitly. This is different from @var{dired-mark-extension} which prepends +a @samp{.} if not present. +If invoked with prefix argument @kbd{C-u}, this command unmarks files instead. +If called with the @kbd{C-u C-u} prefix, asks for a character to use +as the marker, and marks files with it. + +When called from Lisp, @var{suffix} may also be a list of suffixes +and an optional argument @var{marker-char} specifies the marker used. + @item dired-flag-extension @findex dired-flag-extension Flag all files with a certain extension for deletion. A @samp{.} is diff --git a/etc/NEWS b/etc/NEWS index cd98f53399..3839439a32 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -474,6 +474,11 @@ where to place point after C-c M-r and C-c M-s. ** Dired +++ +*** Command 'dired-mark-extension' now automatically prepends a '.' to the +extension when not present. The new command 'dired-mark-suffix' behaves +similarly but it doesn't prepend a '.'. + ++++ *** A new option 'dired-always-read-filesystem' default to nil. If non-nil, buffers visiting files are reverted before search them; for instance, in 'dired-mark-files-containing-regexp' a non-nil value diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 6c8fb0e7da..a2c7e41cc2 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -332,46 +332,73 @@ dired-extra-startup ;;; EXTENSION MARKING FUNCTIONS. +(defun dired--mark-suffix-interactive-spec () + (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))) + ;; 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 `.' is automatically prepended to EXTENSION 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. 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* ((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))) + (interactive (dired--mark-suffix-interactive-spec)) (or (listp extension) (setq extension (list 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)) + +;; Mark files ending with some suffix. +(defun dired-mark-suffix (suffix &optional marker-char) + "Mark all files with a certain SUFFIX for use in later commands. +A `.' is *not* automatically prepended to the string entered; see +also `dired-mark-extension', which is similar but automatically +prepends `.' when not present. +SUFFIX may also be a list of suffixes instead of a single one. +Optional MARKER-CHAR is marker to use. +Interactively, ask for SUFFIX. +Prefixed with one C-u, unmark files instead. +Prefixed with two C-u's, prompt for MARKER-CHAR and mark files with it." + (interactive + (dired--mark-suffix-interactive-spec)) + (or (listp suffix) + (setq suffix (list suffix))) + (dired-mark-files-regexp + (concat ".";; don't match names with nothing but an extension + "\\(" + (mapconcat 'regexp-quote suffix "\\|") "\\)$") marker-char)) -- 2.11.0 --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.9) of 2017-03-27 Repository revision: 8ce827426e5400f2be80ae5d7394b74d8dd90373