[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scan of Emacs regexp mistakes
From: |
Paul Eggert |
Subject: |
Re: Scan of Emacs regexp mistakes |
Date: |
Wed, 15 Apr 2020 11:19:50 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
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.