From: Tino Calancha <tino.calancha@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 25942@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
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) [thread overview]
Message-ID: <alpine.DEB.2.20.1703271017250.3382@calancha-pc> (raw)
In-Reply-To: <87bmsn1x2d.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]
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")))
next prev parent reply other threads:[~2017-03-27 1:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 3:40 bug#25942: 26.0.50; dired-mark-extension prepend '.' to suffix if not present Tino Calancha
2017-03-26 22:40 ` Juri Linkov
2017-03-27 1:30 ` Tino Calancha [this message]
2017-03-27 1:32 ` Tino Calancha
2017-03-27 2:35 ` Eli Zaretskii
2017-03-27 5:34 ` Tino Calancha
2017-03-27 14:28 ` Eli Zaretskii
2017-03-27 15:32 ` Tino Calancha
2017-03-27 22:44 ` Juri Linkov
2017-03-28 1:23 ` Tino Calancha
2017-03-31 8:34 ` Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1703271017250.3382@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=25942@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.