Re: looking-back
Andreas Röhler <[email protected]> Sun, 2 Aug 2026 07:58:20 +0200
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
Thanks all! Am 01.08.26 um 20:12 schrieb Michael Heerdegen via Users list for the GNU Emacs text editor: > Andreas Röhler<[email protected]> writes: > >> want to match an opening paren followed by a whitespace. Tried the >> forms below without success. >> Any suggestion? > Honestly: give up trial and error. > >> ( (looking-back "\\\\( +" (line-beginning-position) t) ==> nil >> ( (looking-back (regexp-quote (rx "(" (+ space))) (line-beginning-position) t) ==> nil > Using `rx' is a good idea. > > Only some hints: > > `rx' returns ready-to-use regexps (of course!), no need for another > `regexp-quote' wrapper. You are using a regexp that matches occurrences of > the regexp you want, not of the text you actually want to match. > > `looking-back' is expensive. It's better to use > > | (save-excursion (goto-char ...) (looking-at ...)) > > wherever possible. "possible" most of the time means you know where the > matched text starts. > > > Michael. > >