From unknown Thu Aug 21 12:12:13 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25942 <25942@debbugs.gnu.org> To: bug#25942 <25942@debbugs.gnu.org> Subject: Status: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Reply-To: bug#25942 <25942@debbugs.gnu.org> Date: Thu, 21 Aug 2025 19:12:13 +0000 retitle 25942 26.0.50; dired-mark-extension prepend '.' to suffix if not pr= esent reassign 25942 emacs submitter 25942 Tino Calancha severity 25942 wishlist tag 25942 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 02 22:40:54 2017 Received: (at submit) by debbugs.gnu.org; 3 Mar 2017 03:40:54 +0000 Received: from localhost ([127.0.0.1]:37253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cje5N-0004cN-W5 for submit@debbugs.gnu.org; Thu, 02 Mar 2017 22:40:54 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56791) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cje5L-0004cB-O3 for submit@debbugs.gnu.org; Thu, 02 Mar 2017 22:40:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cje5F-000765-HD for submit@debbugs.gnu.org; Thu, 02 Mar 2017 22:40:46 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51921) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cje5F-00075u-Cd for submit@debbugs.gnu.org; Thu, 02 Mar 2017 22:40:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cje5E-0003PV-3z for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 22:40:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cje59-00075A-5w for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 22:40:44 -0500 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:35047) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cje59-000751-0h for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2017 22:40:39 -0500 Received: by mail-pf0-x22f.google.com with SMTP id j5so28789889pfb.2 for ; Thu, 02 Mar 2017 19:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=xVxZIT1NcgSom/iiH14I7DtTgtNgsn98HNYNGLoDfOk=; b=uZlaL/EH5BTN8bFMQq915FBc9QouHx1jJL/47SgShEglpTZ/sh7dr5Sh0OX31p1Auj kgaDIm/SL8Q5sXRImjNzsriyfltMSWGY3By3qK+zd3XB5b8ib4iSBCL/1iWT/IFqSpZU y7oRJrhSI4OhN73NAyHktLUqA7u8yGM7yagqbQRiojldnWIG+u2Jb2XaU7DVY7kOg5RV /sG9lhVpAoDkvIp5YVnoEyuIT/lPFMQGL9tqlOqnVxWpAwiUg7Zj9KPTyKpCwYwvj+DN jEjI33tXrFuuuyOtPjtJxCCNuQJAZPFzhNxy4a2ka6KHecWD0QMd3X1ru0rYbV/IaSly 68vw== 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:date:message-id:mime-version; bh=xVxZIT1NcgSom/iiH14I7DtTgtNgsn98HNYNGLoDfOk=; b=j2fad06jcUTfi5HbSvvJsg3UmqieV/NwDuzRLOBn3mRpzlhKsGtJZyLA15m3D3ARXO G3Tz7H1gRujBB4l/WB83HXTMVSN8xQOAIWamOdJ8T48cXYchlA6z8drP8bkQ+6x2OJdm ciqIu3xPz6cRl2koug01KqPunFEiVYde3TSofEfvtSWLI6rWMbEk2bju9mE0imQBmYWD 4GnvU7L4ftR8uPnQw0sqLT4H8dKVu4CWXEEp6Zhe6KEjWj22LFOYD0qMBni6TCGltirE i3uA4PhFR+2aoH3jE3oAcDO97mFgVHghh4JzifwI0r/wWnKlq3TvAlDy9iPrhinVUOmv S9cg== X-Gm-Message-State: AMke39n+m0HnK9iDiFymn+PHDotKdXUtgZ6lJiCPMz1qjlPVLYZ8/T3uLVoVRBst5XEwhg== X-Received: by 10.98.65.148 with SMTP id g20mr888048pfd.44.1488512437868; Thu, 02 Mar 2017 19:40:37 -0800 (PST) Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id y21sm19825658pgh.52.2017.03.02.19.40.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2017 19:40:37 -0800 (PST) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Date: Fri, 03 Mar 2017 12:40:33 +0900 Message-ID: <87d1dzjadq.fsf@calancha-pc> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 18:44:35 2017 Received: (at 25942) by debbugs.gnu.org; 26 Mar 2017 22:44:35 +0000 Received: from localhost ([127.0.0.1]:46405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csGtn-0002I5-9A for submit@debbugs.gnu.org; Sun, 26 Mar 2017 18:44:35 -0400 Received: from sub3.mail.dreamhost.com ([69.163.253.7]:56080 helo=homiemail-a11.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csGtk-0002Hp-7c for 25942@debbugs.gnu.org; Sun, 26 Mar 2017 18:44:32 -0400 Received: from homiemail-a11.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTP id A3313314C069; Sun, 26 Mar 2017 15:44:31 -0700 (PDT) Received: from localhost.linkov.net (m213-102-69-42.cust.tele2.ee [213.102.69.42]) (Authenticated sender: jurta@jurta.org) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTPA id D47B0314C062; Sun, 26 Mar 2017 15:44:30 -0700 (PDT) From: Juri Linkov To: Tino Calancha Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Organization: LINKOV.NET References: <87d1dzjadq.fsf@calancha-pc> Date: Mon, 27 Mar 2017 01:40:28 +0300 In-Reply-To: <87d1dzjadq.fsf@calancha-pc> (Tino Calancha's message of "Fri, 03 Mar 2017 12:40:33 +0900") Message-ID: <87bmsn1x2d.fsf@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) > 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 (=3D 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'. Is this a backward-compatible change? If not, then maybe better prepend =E2=80=98.=E2=80=99 only to the default value for interactive use= s? So users will get the right result when using =E2=80=98M-x dired-mark-extension RE= T RET=E2=80=99. But for the programmatic uses it's the responsibility of the caller to supply the right suffix in =E2=80=98(dired-mark-extension ".c")=E2=80=99 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 21:30:38 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 01:30:38 +0000 Received: from localhost ([127.0.0.1]:46574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csJUU-0006St-75 for submit@debbugs.gnu.org; Sun, 26 Mar 2017 21:30:38 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:35169) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csJUS-0006Sf-2l for 25942@debbugs.gnu.org; Sun, 26 Mar 2017 21:30:36 -0400 Received: by mail-pg0-f52.google.com with SMTP id 81so9209805pgh.2 for <25942@debbugs.gnu.org>; Sun, 26 Mar 2017 18:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=uH1bFowlxNyQrfOgLmHSKv9XtlzSV02pkIVscpWMfk0=; b=FbEdHzVoUiulzUjp1Vogx0Hq+3csf9I4UstfHWnzqvK9EVOT4bprAwkySCI8NbzKaM N4eJkD4lq/g3j+ztlSQ5EhzPi9IEBn4papQ05vjVz46RVyFrflMkF3wORM8EoTZq0ZPM nZ1goS5UZhw4W0k78GDkLkgHTasnroStSe7oVWdNjwh8GhcqKo9gEH6Pqa8BEiYvbhnM ezTg7Zc7WIFV8xp2LFkt+J18TEgjDyPMQKkKI+kzeAoCZAEaWcU9SqEvMVl2gA4QzPyb KJUXAYEj8KYC5QyD0UZfcGLwYMJxQo32LAt8ySX4gztc62HJxYM9kvutHM18W//BMVPF jP6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=uH1bFowlxNyQrfOgLmHSKv9XtlzSV02pkIVscpWMfk0=; b=Os+oFRtkpe7djSSDFDSSLr0fDx19V/M3POqQ7RKE21hjwdSWv9nyCYvS1kMkfv6/rW M37ymMnwCNYd1x9U4WmvbYJXx2B1B36e0SzAQ/OZapuNaU+dsdxQm+oTPNQ5o1pHohWb /VR7LnQx7u/heysuRN2De0+GhdHqp+A+q6uTR+ewWGn2r2q/0oE+TEWAM1LKxBFSSkRv YU8xomLE3dJZLFfpj9N2ZCMCNjHlHgVdzUT/m4Qpt/VDMSJTjLKQ0jnmZLng4q2EMdbP L8D5NXYLe0kJvcE1BAk2BMXjtlR+Qs8dRt4WC4wOn6ha5J9sefWelJLnNkH2tC+WY0pT r3RQ== X-Gm-Message-State: AFeK/H022YNvK5Lrok0x0jizj4qGi+Bg0yT8aEqQADh+kiOqjwsX/le4obYVwf7iN/E72Q== X-Received: by 10.98.139.78 with SMTP id j75mr21946826pfe.122.1490578230169; Sun, 26 Mar 2017 18:30:30 -0700 (PDT) Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id e16sm16964806pfb.102.2017.03.26.18.30.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Mar 2017 18:30:29 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Mon, 27 Mar 2017 10:30:26 +0900 (JST) X-X-Sender: calancha@calancha-pc To: Juri Linkov Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present In-Reply-To: <87bmsn1x2d.fsf@localhost> Message-ID: References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1284115119-1490578229=:3382" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, Tino Calancha X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --8323329-1284115119-1490578229=:3382 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Mon, 27 Mar 2017, Juri Linkov wrote: >> 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'. > > Is this a backward-compatible change? Yes, it is; but it makes a better global picture when we consider this function together with `file-name-extension' and `file-name-sans-extension' (More below). > If not, then maybe better > prepend ‘.’ only to the default value for > interactive uses? So users > will get the right result when using ‘M-x dired-mark-extension RET RET’. > But for the programmatic uses it's the responsibility of the caller to > supply the right suffix in ‘(dired-mark-extension ".c")’ The problem is that this command has a concept of 'extension' different than the two other functions mentioned above. [Using same names than in my code snippet]: (file-name-extension "Music") => nil (equal "Music" (file-name-sans-extension "Music")) => t (file-name-extension "foo.c") => "c" ;; Note: this command consider extension "c" (without period). (dired-mark-extension (file-name-extension "foo.c")) ;; This marks all the files, i.e., also marks "Music" and "Public". IMHO the correct behaviour for (dired-mark-extension (file-name-extension "foo.c")) would be to mark those files satisfying (lambda (f) (equal (file-name-extension f) (file-name-extension "foo.c"))) --8323329-1284115119-1490578229=:3382-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 21:32:20 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 01:32:20 +0000 Received: from localhost ([127.0.0.1]:46578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csJW8-0006VY-Hv for submit@debbugs.gnu.org; Sun, 26 Mar 2017 21:32:20 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:33261) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csJW7-0006VM-Me for 25942@debbugs.gnu.org; Sun, 26 Mar 2017 21:32:19 -0400 Received: by mail-pg0-f43.google.com with SMTP id n5so16093074pgh.0 for <25942@debbugs.gnu.org>; Sun, 26 Mar 2017 18:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=qdyI9cH9Ip+imHZdo/9LpA/FcOiWhMmqqWt9AZoEqOE=; b=cPaHfIpGpfY3BZVS1tl7x5T/yIy/giRvCoOcFQWYL4cVoSUpcNcoYA5W/L6FxTwFqL 6f2kMEqyWDCk45nPeGcBbARw8FuZNS3TjLqAbLmncHAJoJApKboEBZ6gEQKR48U2AV8H LpMqNTYHh0Esnmxs4iUxaC6U1kBDm45K8vWcHoQ9zM9UmO72B0HDJ1FqNA50do4IRKeW 13x49n5TD3M25CJiiSzHcDKE7P2ULJGx7/y6qI7LQxPaSjKn5ZIyCZtwo/HHxF/J/lmA 19x3fy2YCKDImNtD5DVSDc/8moF5iKX4CqMVLwuZJ9QC4nJHizMKmcYkoQyYQsN1b1gp BZ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=qdyI9cH9Ip+imHZdo/9LpA/FcOiWhMmqqWt9AZoEqOE=; b=MkEw9GwzuPrL/JL11C0795wFWvUld+7E6SnM4jfDbXfjJPFqZKpdit6DVQVS+rJf7m qd3lvwIlFApAU+RQYqbD/5Gv+NhceOiUyp7T+DyXczrG/nNspdDwEiseDcftLXmgtV3s U2mUGpgYS+cZ8L+Dye++liRDeC5PUmNetKoTvC4p6AGDKIT2Z/hE4dYHlpsPdRJoFmE+ 0qzEkYKCh9sAMBzratQ9N0eTX035T+e6WKOJK8AKUR7Es2PEBOnaElbcNeQ9bz9WZkKY o8EJGmAeSzi7EDN8qvO04ZHMrVUFpumOAZqt+p5d7WzA5gFB/Lna72lRUdqlztNtulDA Rqog== X-Gm-Message-State: AFeK/H0Ph8pzEvwVK3w00kX52irNK/GxC6bR8qVjm12ROj7X9XHI+G7vukurunGs5MCDdw== X-Received: by 10.98.205.7 with SMTP id o7mr22566256pfg.171.1490578334193; Sun, 26 Mar 2017 18:32:14 -0700 (PDT) Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id y6sm16993369pgc.1.2017.03.26.18.32.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Mar 2017 18:32:13 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Mon, 27 Mar 2017 10:32:11 +0900 (JST) X-X-Sender: calancha@calancha-pc To: Tino Calancha Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present In-Reply-To: Message-ID: References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) On Mon, 27 Mar 2017, Tino Calancha wrote: > > > On Mon, 27 Mar 2017, Juri Linkov wrote: > >>> 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'. >> >> Is this a backward-compatible change? > Yes, it is; but it makes a better global picture when we consider > this function together with `file-name-extension' and > `file-name-sans-extension' (More below). Sorry, i meant 'No, it isn't; but it makes a better ...' From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 22:35:56 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 02:35:56 +0000 Received: from localhost ([127.0.0.1]:46603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csKVg-0007zS-Mm for submit@debbugs.gnu.org; Sun, 26 Mar 2017 22:35:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43593) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csKVg-0007zH-26 for 25942@debbugs.gnu.org; Sun, 26 Mar 2017 22:35:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csKVW-0002ib-2b for 25942@debbugs.gnu.org; Sun, 26 Mar 2017 22:35:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csKVV-0002iV-Vg; Sun, 26 Mar 2017 22:35:46 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3289 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1csKVV-0003Ri-3b; Sun, 26 Mar 2017 22:35:45 -0400 Date: Mon, 27 Mar 2017 05:35:45 +0300 Message-Id: <83r31j8n0e.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-reply-to: (message from Tino Calancha on Mon, 27 Mar 2017 10:30:26 +0900 (JST)) Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Tino Calancha > Date: Mon, 27 Mar 2017 10:30:26 +0900 (JST) > Cc: 25942@debbugs.gnu.org, Tino Calancha > > The problem is that this command has a concept of 'extension' different > than the two other functions mentioned above. Then how about providing a new command, named dired-mark-suffix or somesuch, which would work like dired-mark-extension does now? Or maybe have an optional argument, activated by prefix arg to dired-mark-extension, to do that? That would leave users a way to get back the old behavior, if they want. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 01:34:42 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 05:34:42 +0000 Received: from localhost ([127.0.0.1]:46677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csNIf-00045G-V1 for submit@debbugs.gnu.org; Mon, 27 Mar 2017 01:34:42 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csNIe-000453-Gm for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 01:34:41 -0400 Received: by mail-pg0-f67.google.com with SMTP id g2so9794762pge.2 for <25942@debbugs.gnu.org>; Sun, 26 Mar 2017 22:34:40 -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=IEjBjEQcsff3DvTfCP+AUzoxtCJDjr+sXhtduJBn/uE=; b=kNPqkdJYuUaEd2XbZT8UAt/VMGWnpW9BXDuNBhhMRGY3er5oM0LdTHP1CPO51tKJm0 dZ00wllhcclsgnnJdN8B8BUf4oUKSAwEybQebqiFksyoKxDIZ9WRumvviAHg9ZRp5Qjv mnMclwNz8dnQ2XQUNQJwVw+xQTIllpVGjh/ga24iKAz06qiF8w4WolFe4CRQ3ILGzhfj piw4FmOkZ8gyel4PTiP/knktiWkKJC03wHMIhDBBpGC4xOc5+Mr5vSfsNugG0NimFqid tZzN4HBh5fj9960JNy4dYbhfNUNKIXJwoVyH3ZrM4blCp6U+JTkftD4IcCPc4TP8oKkv KJUQ== 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=IEjBjEQcsff3DvTfCP+AUzoxtCJDjr+sXhtduJBn/uE=; b=J5tYra2xAf50bkRfhyXfdtPU1YuNvwa1eVz/VpRId4UPkSLwe1wFwvCnWnSVQM18sI spBFMggJlOHLEsBJ3tsd7noQKsCX6QduOczzdqiywLY1Yn/x3JiIok9OTvGAqJcWG+fP MIq4N3F4W8GoTQklW4eQtOmaA1B0ov6Dp5DimaXRhaOPjRUkwv5BuMs7DEEMdCB3vc8Q ewS0VBAkRe34grtQkVSHp5DTbmYy+Zxy0PWtTWFbfgrDw/krYqwBll5C1casMr7nsikK Rq117FQj3JE1yufAe/8Q2ikwYJJuu1ca+o86qV8Zy+yPzjv1vuuvGxWhPh+b6bnO1iKf ibiA== X-Gm-Message-State: AFeK/H1NlHabkhpWI9TUfgGpzjEzwTz6+EQ643bfdk9LReyzgGITYKXurWGgBCBfoAfQmw== X-Received: by 10.84.130.2 with SMTP id 2mr26761044plc.24.1490592874642; Sun, 26 Mar 2017 22:34:34 -0700 (PDT) Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id b74sm17970716pfd.90.2017.03.26.22.34.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Mar 2017 22:34:34 -0700 (PDT) From: Tino Calancha To: Eli Zaretskii Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> Date: Mon, 27 Mar 2017 14:34:30 +0900 In-Reply-To: <83r31j8n0e.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Mar 2017 05:35:45 +0300") Message-ID: <87zig7jna1.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, tino.calancha@gmail.com, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Eli Zaretskii writes: >> From: Tino Calancha >> Date: Mon, 27 Mar 2017 10:30:26 +0900 (JST) >> Cc: 25942@debbugs.gnu.org, Tino Calancha >> >> The problem is that this command has a concept of 'extension' different >> than the two other functions mentioned above. > > Then how about providing a new command, named dired-mark-suffix or > somesuch, which would work like dired-mark-extension does now? Or > maybe have an optional argument, activated by prefix arg to > dired-mark-extension, to do that? That would leave users a way to get > back the old behavior, if they want. I like your first suggestion. The second is less convenient because we already use prefices 'C-u' and 'C-u C-u'. The following patch adds a new command 'dired-mark-suffix', and modifies 'dired-mark-extension'. I) dired-mark-suffix: it behaves as 'dired-mark-extension' used to do, i.e., don't prepends any '.' to the user input. II) dired-mark-extension: It prepends '.' to EXTENSION when not present. This way became consistent with 'file-name-extension', that is, if (file-name-extension FILE) returns nil, then 'dired-mark-extension' will not mark FILE. --8<-----------------------------cuthere---------------start------------->8--- >From e995e2ab6ffbd1ef94b9548d492394f9283fe490 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Mon, 27 Mar 2017 14:31:35 +0900 Subject: [PATCH] dired-mark-suffix: New command Now dired-mark-extension prepends '.' to extension when not present. Add the new 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 | 16 +++++++++-- etc/NEWS | 5 ++++ lisp/dired-x.el | 80 ++++++++++++++++++++++++++++++++++----------------- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 1e6f4b03bb..369b2da42a 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -721,8 +721,7 @@ 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. +is automatically prepended to the string entered when not present. If invoked with prefix argument @kbd{C-u}, this command unmark 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. @@ -730,6 +729,19 @@ Advanced Mark Commands 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 than @var{dired-mark-extension} which prepends +a @samp{.} if not present. +If invoked with prefix argument @kbd{C-u}, this command unmark 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 suffices +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..a043784a75 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -332,46 +332,74 @@ 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 `.' 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. 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))) + (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 suffices 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 12, x86_64-pc-linux-gnu, GTK+ Version 3.22.9) of 2017-03-27 Repository revision: 05bfebfc91bc053435287f560aeb956926d31583 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 10:28:17 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 14:28:17 +0000 Received: from localhost ([127.0.0.1]:47515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csVd2-0001va-SH for submit@debbugs.gnu.org; Mon, 27 Mar 2017 10:28:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csVd1-0001vK-MS for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 10:28:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csVcv-0007XT-O1 for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 10:28:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csVcn-0007VI-RW; Mon, 27 Mar 2017 10:28:01 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3715 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1csVcn-0004Tm-1S; Mon, 27 Mar 2017 10:28:01 -0400 Date: Mon, 27 Mar 2017 17:28:01 +0300 Message-Id: <83poh294lq.fsf@gnu.org> From: Eli Zaretskii To: Tino Calancha In-reply-to: <87zig7jna1.fsf@calancha-pc> (message from Tino Calancha on Mon, 27 Mar 2017 14:34:30 +0900) Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, tino.calancha@gmail.com, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > 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." Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 11:32:37 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 15:32:37 +0000 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 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 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) 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) From: Tino Calancha To: Eli Zaretskii Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> <83poh294lq.fsf@gnu.org> Date: Tue, 28 Mar 2017 00:32:25 +0900 In-Reply-To: <83poh294lq.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 27 Mar 2017 17:28:01 +0300") Message-ID: <871stid9bq.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, tino.calancha@gmail.com, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 18:45:59 2017 Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 22:45:59 +0000 Received: from localhost ([127.0.0.1]:47900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csdOg-0005kQ-P4 for submit@debbugs.gnu.org; Mon, 27 Mar 2017 18:45:58 -0400 Received: from sub3.mail.dreamhost.com ([69.163.253.7]:50496 helo=homiemail-a11.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csdOf-0005kH-Cj for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 18:45:57 -0400 Received: from homiemail-a11.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTP id 9EB0C314C066; Mon, 27 Mar 2017 15:45:55 -0700 (PDT) Received: from localhost.linkov.net (m213-102-69-42.cust.tele2.ee [213.102.69.42]) (Authenticated sender: jurta@jurta.org) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTPA id 9711A314C062; Mon, 27 Mar 2017 15:45:54 -0700 (PDT) From: Juri Linkov To: Tino Calancha Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Organization: LINKOV.NET References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> Date: Tue, 28 Mar 2017 01:44:12 +0300 In-Reply-To: <87zig7jna1.fsf@calancha-pc> (Tino Calancha's message of "Mon, 27 Mar 2017 14:34:30 +0900") Message-ID: <87h92e9w77.fsf@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) > The following patch adds a new command 'dired-mark-suffix', and > modifies 'dired-mark-extension'. > I) dired-mark-suffix: it behaves as 'dired-mark-extension' used to do, > i.e., don't prepends any '.' to the user input. > II) dired-mark-extension: It prepends '.' to EXTENSION when not present. > This way became consistent with 'file-name-extension', that is, if > (file-name-extension FILE) returns nil, then 'dired-mark-extension' > will not mark FILE. Thanks. > 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 There is a special section in etc/NEWS for Incompatible Changes that would be a more likely place to find this change. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 27 21:23:46 2017 Received: (at 25942) by debbugs.gnu.org; 28 Mar 2017 01:23:46 +0000 Received: from localhost ([127.0.0.1]:48056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csfrN-0002x7-Vb for submit@debbugs.gnu.org; Mon, 27 Mar 2017 21:23:46 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:34199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csfrL-0002wr-Tm for 25942@debbugs.gnu.org; Mon, 27 Mar 2017 21:23:44 -0400 Received: by mail-pg0-f49.google.com with SMTP id 21so56740399pgg.1 for <25942@debbugs.gnu.org>; Mon, 27 Mar 2017 18:23:43 -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=sCAXaQxhvYJIQ5yzhlLvJlEQFHhVaV2m4m1q/uj5XEA=; b=CH9oYk7t6+lLCGI6jBfr+fQ3mHg3RUTS1KL07OzL5ZGlWzuk5pNaKML5FlSgXhsxRo mbK/5XjgvtXCLnpQW1JepWgVF5xH9iX/T8B4DDSse3Xpby94VPUw9+k/3VqOm9xlNGmL 2xLh6gLLOZ8a3HXPiyMRVcXHat+ZXNpxqhUyZQ8kVCDXHREzHlRk7mxDbc7XSyjqiEmT tG1LpuzOlGKKiuqyulpsGAm9fJ6KTxgJqYUpXi6OEO0X0geMogVKAWQrIGRUqZ/tLU6m Y6jjC8gYQoHa2AQPW+6xrf0bbrDHVmB8NhMc6qRsNcdNA2y4Y8EqcgKY1kdXTe0O7K13 g+zQ== 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=sCAXaQxhvYJIQ5yzhlLvJlEQFHhVaV2m4m1q/uj5XEA=; b=mNXNaZS1kJgtGqs77w8TbOZ19Yscqkt0/cynngTxB5T2kWD5eoViaecNQXBAAOsuKn 4k9G4XYdMcP6zs8GEp3HAkp+kl8ZPanaYiKAvY3qCH+SBMzG9kMkKskOKOrFaXm42xSu Z9RBWMrmXZLdfZl88x1JXKV423s9qj1FqSb2cUqCI+rqMiqAdcUgKJ+++nSb8Tju2sX9 UQH1UUZU1d08JWWn8w0JE5Dt0k06YMY54nXfbpmz10i2w/ME60ArRDnbPfb0lB2QIzD2 ONzdoxVdr4NouvlJ5sVeghsuLCDMtXH4rhqWPwFJygt1RYBt6QRMi2sByWR1PwCCHLXx C6+g== X-Gm-Message-State: AFeK/H0MRZiWm+ZviRWkVFwv118JxvKyeAKtTGaFYVdWaXmH8h+58Jpyw0BOkMA366CPLg== X-Received: by 10.98.139.195 with SMTP id e64mr28893880pfl.86.1490664217966; Mon, 27 Mar 2017 18:23:37 -0700 (PDT) Received: from calancha-pc (234.204.100.220.dy.bbexcite.jp. [220.100.204.234]) by smtp.gmail.com with ESMTPSA id a5sm3341301pfh.124.2017.03.27.18.23.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Mar 2017 18:23:37 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> <87h92e9w77.fsf@localhost> Date: Tue, 28 Mar 2017 10:23:32 +0900 In-Reply-To: <87h92e9w77.fsf@localhost> (Juri Linkov's message of "Tue, 28 Mar 2017 01:44:12 +0300") Message-ID: <87vaqu42jv.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942 Cc: 25942@debbugs.gnu.org, Eli Zaretskii , tino.calancha@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Juri Linkov writes: >> 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 > > 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: --8<-----------------------------cut here---------------start------------->8--- >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 -- 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: a62437d4b933825a92ac3836836edbca3540fa1c From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 31 04:34:39 2017 Received: (at 25942-done) by debbugs.gnu.org; 31 Mar 2017 08:34:39 +0000 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 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 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) 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) From: Tino Calancha To: 25942-done@debbugs.gnu.org Subject: Re: bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> <83r31j8n0e.fsf@gnu.org> <87zig7jna1.fsf@calancha-pc> <87h92e9w77.fsf@localhost> <87vaqu42jv.fsf@calancha-pc> Date: Fri, 31 Mar 2017 17:34:26 +0900 In-Reply-To: <87vaqu42jv.fsf@calancha-pc> (Tino Calancha's message of "Tue, 28 Mar 2017 10:23:32 +0900") Message-ID: <87r31dq1yl.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25942-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) 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 From unknown Thu Aug 21 12:12:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 28 Apr 2017 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator