On Thu, Jan 13 2022, Tomi Ollila wrote: [...] > I am curious about this regexp, \b is matching word/non-word boundary -- so > I had to test it. > > (replace-regexp-in-string "\\b%t\\b" "repl" "foo %t bar") ;; no replacement > (replace-regexp-in-string "\\b%t\\b" "repl" "foo-%t-bar") ;; no replacement > ... > (replace-regexp-in-string "\\b%t\\b" "repl" "foox%t-bar") ;; replacement! > > before % there is "word" character and after t there is "non-word" character. Ah, yes... i messed up, i think we want here (replace-regexp-in-string "\\_<%t\\_>" "repl" "foo %t bar") i.e. \_< .. \_> to correctly delimit beginning and end of word, not just boundary (i always trip on this!). > Also tried (format-spec "foo-%t-bar" '((?t . "repl"))) ;; which works as > I'd expect. yeah, that's what i use and didn't notice my error above. format-spec is much nicer than a plain regexp subs, one can use format specifiers like %3t and many others, but unfortunately seems to have been introduced in emacs 27. thanks for checking, and if you can confirm the above fix looks better, i'll submit a new version. cheers, jao -- A language that doesn't affect the way you think about programming, is not worth knowing. - Alan Perlis, Epigrams on Programming _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org