diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-07-25 09:50:34 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-07-25 09:50:34 +0200 |
| commit | b377adb68c8d124d6d6ef1cba21ac7862c6cb1c3 (patch) | |
| tree | c10a17d20c74335ded82ad0ea09009c46d57dc4e /test | |
| parent | eda5d3682ab8af3961232d0d026c3a4b12adf3c2 (diff) | |
Use shorthand match-str instead of match-string-no-properties
Almost always would it be better to use `match-string-no-properties'
instead of `match-string', but because the name of the former is
excruciatingly long for a function that one often wants to use in
tight spaces and because it usually "does not really matter", I
usually went for the latter.
The problem is, it does matter. For example, even strings that are
usually only used by code may end up obfuscating debug statements.
So let's start doing the right thing, even though there surely will
be people frowning at the use of a shorthand.
The fake ("match-string" "match-string") shorthand is necessary to
protect literal `match-string' and `match-string-no-properties' from
being corrupted by interpreted as shorthand for the non-existent
`match-stringing' and `match-string-no-propertiesing'.
Unfortunately the shorthands have to be specified in each library
individually. Using "dir-locals.el" only works if the libraries
are compiled. At least this additional noise is neatly tucked away
at the end of the files.
It might turn out that out of the more than two hundred instances
where this replaces `match-string' with `match-string-no-properties'
we should have stuck with the former in an instance or two. That's
the price of progress and can be fixed once such regressions are
reported.
Diffstat (limited to 'test')
| -rw-r--r-- | test/magit-tests.el | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/magit-tests.el b/test/magit-tests.el index dcf796d..d8e98ae 100644 --- a/test/magit-tests.el +++ b/test/magit-tests.el @@ -271,13 +271,13 @@ (let* ((prompts '("^foo '\\(?99:.*\\)': ?$")) (prompt (magit-process-match-prompt prompts "foo 'bar':"))) (should (equal prompt "foo 'bar': ")) - (should (equal (match-string 99 "foo 'bar':") "bar")))) + (should (equal (matched 99 "foo 'bar':") "bar")))) (ert-deftest magit-process:password-prompt-regexps () (cl-flet ((m (prompt) (and (magit-process-match-prompt magit-process-password-prompt-regexps prompt) - (or (match-string 99 prompt) t)))) + (or (matched 99 prompt) t)))) ;; History of `magit-process-password-prompt-regexps': ;; a36a801cc2 Initial noisy version. ;; 2a3bbc3c53 First cleanup. @@ -537,4 +537,7 @@ Recent commits\n[[:xdigit:]]\\{7,\\} master dummy\\'" ;;; _ (provide 'magit-tests) +;; Local Variables: +;; read-symbol-shorthands: (("matched" . "match-string-no-properties")) +;; End: ;;; magit-tests.el ends here |
