From: Paul Eggert <eggert@cs.ucla.edu>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Scan of Emacs regexp mistakes
Date: Wed, 15 Apr 2020 11:19:50 -0700 [thread overview]
Message-ID: <06c10772-75fa-0f80-2ed5-775e5b245b16@cs.ucla.edu> (raw)
In-Reply-To: <140DB045-4529-4862-99B8-5F0DEF1EE8D4@acm.org>
On 4/14/20 3:52 AM, Mattias Engdegård wrote:
> (defvar authors-obsolete-files-regexps
> - '(".*loaddefs.el$" ; not obsolete, but auto-generated
> + '(".*loaddefs\\.el$" ; not obsolete, but auto-generated
> "\\.\\(bzr\\|cvs\\|git\\)ignore$" ; obsolete or uninteresting
> "\\.arch-inventory$"
Should those trailing "$"s be changed to "\\'"s?
> ;; Match anything but `.' and `..'.
> -(defvar dired-re-no-dot "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")
> +(defvar dired-re-no-dot (rx (or (not ".") "...")))
...
> (defconst directory-files-no-dot-files-regexp
> - "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"
> + "[^.]\\|\\.\\.\\."
> "Regexp matching any file name except \".\" and \"..\".")
We shouldn't have two names for the same variable. I suggest obsoleting
dired-re-no-dot and replacing its only use with directory-files-no-dot-files-regexp.
As Drew's comments make evident, the doc string is unclear. It should be
something like 'Regexp that matches part of a nonempty string if the string is
neither "." nor "..".'
> (let ((files (directory-files
> - directory t "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
> + directory t (rx (or (not ".") "..."))))
Shouldn't this and similar uses of (rx (or (not ".") "...")) be replaced by
directory-files-no-dot-files-regexp? That would be clearer.
I agree with you that directory-files should not return "." and "..", though
that indeed is a different topic.
next prev parent reply other threads:[~2020-04-15 18:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-05 12:30 Scan of Emacs regexp mistakes Mattias Engdegård
2020-04-14 10:52 ` Mattias Engdegård
2020-04-14 11:15 ` Andreas Schwab
2020-04-16 10:15 ` Mattias Engdegård
2020-04-14 15:47 ` Drew Adams
2020-04-15 18:19 ` Paul Eggert [this message]
2020-04-16 10:29 ` Mattias Engdegård
2020-04-16 10:37 ` Mattias Engdegård
2020-04-16 16:08 ` Paul Eggert
2020-04-16 18:01 ` Mattias Engdegård
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06c10772-75fa-0f80-2ed5-775e5b245b16@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=mattiase@acm.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).