[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35564: [PATCH v2] Tweak dired warning about "wildcard" characters
From: |
Kévin Le Gouguec |
Subject: |
bug#35564: [PATCH v2] Tweak dired warning about "wildcard" characters |
Date: |
Thu, 13 Jun 2019 08:19:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Noam Postavsky <npostavs@gmail.com> writes:
> I think this might be better expressed in regexp:
I guess it is; I just tend to get superstitious about messing with match
data.
> Although this gives different results for things like:
>
> (dired--isolated-char-p "?`foo`" 0)
>
> Do we care about that? (if yes, then that's a missing test case)
I think we do care; if I look at what the existing code says,
(dired--star-or-qmark-p "?`foo`" "?")
;; => nil
Off the top of my head, this is the best I can come up with to satisfy
this edge case:
(defun dired--isolated-char-p (command pos)
"Assert whether the character at POS is isolated within COMMAND.
A character is isolated if:
- it is surrounded by whitespace, the start of the command, or
the end of the command,
- it is surrounded by `\\=`' characters."
(let ((start (max 0 (1- pos)))
(char (string (aref command pos))))
(and (or (string-match
(rx-to-string '(seq (or bos blank)
(group char)
(or eos blank)))
command start)
(string-match
(rx-to-string '(seq ?`
(group char)
?`))
command start))
(= pos (match-beginning 1)))))
> And perhaps the regexp above (if it's correct) can be integrated into
> this search? (maybe not though, since negation isn't straightforward in
> regexps)
I will look into that.
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Can't we use `(... ,.. ..) instead of `eval`?
>
>
> Stefan
That works too from what I tested, although it's not necessary anymore
with the new version above.
Thank you both for the review! I will come back with an updated patch
(with the new test case) Some Time Later™.
bug#35564: [PATCH v3] Tweak dired warning about "wildcard" characters, Kévin Le Gouguec, 2019/06/26