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: Mon, 27 Mar 2017 10:30:26 +0900 (JST) Message-ID: References: <87d1dzjadq.fsf@calancha-pc> <87bmsn1x2d.fsf@localhost> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-1284115119-1490578229=:3382" X-Trace: blaine.gmane.org 1490578285 9710 195.159.176.226 (27 Mar 2017 01:31:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 27 Mar 2017 01:31:25 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 25942@debbugs.gnu.org, Tino Calancha To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 27 03:31:21 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 1csJV0-0000kh-Tn for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Mar 2017 03:31:11 +0200 Original-Received: from localhost ([::1]:43708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csJV5-0002pd-5J for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Mar 2017 21:31:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csJUx-0002on-Ah for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2017 21:31:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csJUs-00037e-E5 for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2017 21:31:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csJUs-00037Z-Ab for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2017 21:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1csJUr-0006TZ-QB for bug-gnu-emacs@gnu.org; Sun, 26 Mar 2017 21:31: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 01:31: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.149057823824859 (code B ref 25942); Mon, 27 Mar 2017 01:31:01 +0000 Original-Received: (at 25942) by debbugs.gnu.org; 27 Mar 2017 01:30:38 +0000 Original-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 Original-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 Original-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) Original-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) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87bmsn1x2d.fsf@localhost> 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:130997 Archived-At: --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--