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: Fri, 31 Mar 2017 17:34:26 +0900 Message-ID: <87r31dq1yl.fsf@calancha-pc> References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> <87h92e9w77.fsf@localhost> <87vaqu42jv.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1490949324 26362 195.159.176.226 (31 Mar 2017 08:35:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 31 Mar 2017 08:35:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: 25942-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 31 10:35:18 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 1cts1d-0006E4-Jh for geb-bug-gnu-emacs@m.gmane.org; Fri, 31 Mar 2017 10:35:17 +0200 Original-Received: from localhost ([::1]:39534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cts1j-0004y9-65 for geb-bug-gnu-emacs@m.gmane.org; Fri, 31 Mar 2017 04:35:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cts1U-0004vX-ST for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2017 04:35:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cts1O-0006aX-Dl for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2017 04:35:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cts1O-0006a5-9q for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2017 04:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cts1O-00047s-1R for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2017 04:35:02 -0400 Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Mar 2017 08:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 25942 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 25942@debbugs.gnu.org, tino.calancha@gmail.com, tino.calancha@gmail.com Original-Received: via spool by 25942-done@debbugs.gnu.org id=D25942.149094927915820 (code D ref 25942); Fri, 31 Mar 2017 08:35:01 +0000 Original-Received: (at 25942-done) by debbugs.gnu.org; 31 Mar 2017 08:34:39 +0000 Original-Received: from localhost ([127.0.0.1]:53565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cts10-000475-Fv for submit@debbugs.gnu.org; Fri, 31 Mar 2017 04:34:38 -0400 Original-Received: from mail-pg0-f46.google.com ([74.125.83.46]:35237) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cts0y-00046s-6d for 25942-done@debbugs.gnu.org; Fri, 31 Mar 2017 04:34:36 -0400 Original-Received: by mail-pg0-f46.google.com with SMTP id 81so64660283pgh.2 for <25942-done@debbugs.gnu.org>; Fri, 31 Mar 2017 01:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=SbZD/ERnnshQndHVn0gcgvXedl18804w4ZEX7AnpgIY=; b=oKjE0Ym25YTZXTR4kAzhnjWPM0Y4L0F+VzMe/dGAemdWjE7uDU/Iq93hwHRIS/UCaq ZQk1DQ28Tkg97gLOcITNoMVPGrHURt1xXbwdg0Rmb5MIVe4roseeeyQrN0XbM5yCAZGo E1nVyVrmx+ziXBVjuehD64yBxccqomYn8Js+plQR8c/85hXCJi1PBsKRgHNdOf1IHuDR wv9u3BvzFi8HHCDepiap0OM2RnSAlXq1VbPn4bPcY5/mCZwdfdocZvzKHfdsXUOr2WZF n/stu/vSmXBA8R29vEsvG27b0YpX/hWr/OpGIWcBCKt5+3IEZUin4qjgqCqDtNLY0wN4 b9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=SbZD/ERnnshQndHVn0gcgvXedl18804w4ZEX7AnpgIY=; b=kKLrQRtnysRGzOTA6hMW/2PaOaiQrLIohsaa4kXeolphSUkL95Qlkm0MneKIhGyB9O Fdq1movDbMOrPXMouKLMFqgnqziw/DvDv8Zeokj9vAqxHjxP2fKUOtN5I6VLfB2MtLuN 0xkki5s+FHMlA7YiJRKTcuGGPJwoL/o+ZgHMgkk2fqD2gsDjq2dhPxpEyKoRc6oUtsSb 9GRazP3M4GG0AzykyxSFhn48XYcM6JYmCasLUy1kFE5VH6FpJ1QkoMep3QrVLyCR0FJZ JJG/4Xxpb+aCBArgMvWI7e02ceGC+i2UJ+Cza8r1/rZXimzfCg6xtY9QUvm3c0t9LKF/ WSBQ== X-Gm-Message-State: AFeK/H3HNNEQh3OgTpW3ospB2LxTtKslGh4tUmcMXE4czMAJ5NnF8ObknTZRMKPLaVgLUA== X-Received: by 10.84.137.165 with SMTP id 34mr2034745pln.125.1490949270068; Fri, 31 Mar 2017 01:34:30 -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 i124sm8863588pgd.66.2017.03.31.01.34.28 for <25942-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Mar 2017 01:34:29 -0700 (PDT) In-Reply-To: <87vaqu42jv.fsf@calancha-pc> (Tino Calancha's message of "Tue, 28 Mar 2017 10:23:32 +0900") 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:131129 Archived-At: Tino Calancha writes: Pushed patch into master branch as commit: 1da9a207669a3cf5d27ac1dd61543c1492e05360 > Juri Linkov writes: >> There is a special section in etc/NEWS for Incompatible Changes >> that would be a more likely place to find this change. > That's right. Thanks. > Here is the updated patch: > >>>From 268eae94cdaf43bfd44c3b8d5cb74a32d26556c3 Mon Sep 17 00:00:00 2001 > From: Tino Calancha > Date: Tue, 28 Mar 2017 10:18:59 +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. > * test/lisp/dired-x-tests.el: New test suite; add test for these features. > ; * etc/NEWS (Incompatible Lisp Changes in Emacs 26.1): > ; Mention these changes. > --- > doc/misc/dired-x.texi | 18 ++++++++-- > etc/NEWS | 7 ++-- > lisp/dired-x.el | 85 ++++++++++++++++++++++++++++++---------------- > test/lisp/dired-x-tests.el | 48 ++++++++++++++++++++++++++ > 4 files changed, 124 insertions(+), 34 deletions(-) > create mode 100644 test/lisp/dired-x-tests.el > > 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..bfd7d2bd32 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -471,8 +471,6 @@ where to place point after C-c M-r and C-c M-s. > --- > *** Messages from CMake are now recognized. > > -** Dired > - > +++ > *** A new option 'dired-always-read-filesystem' default to nil. > If non-nil, buffers visiting files are reverted before search them; > @@ -759,6 +757,11 @@ processes on exit. > * Incompatible Lisp Changes in Emacs 26.1 > > +++ > +*** 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 '.'. > + > ++++ > ** Certain cond/pcase/cl-case forms are now compiled using a faster jump > table implementation. This uses a new bytecode op `switch', which isn't > compatible with previous Emacs versions. This functionality can be disabled > diff --git a/lisp/dired-x.el b/lisp/dired-x.el > index 6c8fb0e7da..527685acf3 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))) > - (or (listp extension) > - (setq extension (list extension))) > + (interactive (dired--mark-suffix-interactive-spec)) > + (unless (listp extension) > + (setq extension (list extension))) > + (dired-mark-files-regexp > + (concat ".";; don't match names with nothing but an 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)) > + (unless (listp suffix) > + (setq suffix (list suffix))) > (dired-mark-files-regexp > (concat ".";; don't match names with nothing but an extension > "\\(" > - (mapconcat 'regexp-quote extension "\\|") > + (mapconcat 'regexp-quote suffix "\\|") > "\\)$") > marker-char)) > > diff --git a/test/lisp/dired-x-tests.el b/test/lisp/dired-x-tests.el > new file mode 100644 > index 0000000000..b11c440834 > --- /dev/null > +++ b/test/lisp/dired-x-tests.el > @@ -0,0 +1,48 @@ > +;;; dired-x-tests.el --- Test suite for dired-x. -*- lexical-binding: t -*- > + > +;; Copyright (C) 2017 Free Software Foundation, Inc. > + > +;; This file is part of GNU Emacs. > + > +;; GNU Emacs is free software: you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; GNU Emacs is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with GNU Emacs. If not, see . > + > +;;; Code: > +(require 'ert) > +(require 'dired-x) > + > + > +(ert-deftest dired-test-bug25942 () > + "Test for http://debbugs.gnu.org/25942 ." > + (let ((dirs '("Public" "Music")) > + (files '(".bashrc" "bar.c" "foo.c" "c" ".c")) > + (dir (make-temp-file "Bug25942" 'dir)) > + (extension "c")) > + (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 extension) > + (should (= (length '("foo.c" "bar.c")) > + (length (dired-get-marked-files)))) > + (dired-unmark-all-marks) > + (dired-mark-suffix extension) > + (should (= (length (delete "c" (append dirs files))) > + (length (dired-get-marked-files))))) > + (delete-directory dir 'recursive)))) > + > +(provide 'dired-x-tests) > +;; dired-x-tests.el ends here