Re: looking-back

Arash Esbati <[email protected]> Sat, 01 Aug 2026 22:04:16 +0200
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Andreas R=C3=B6hler <[email protected]> writes:

> re-search-backward below stops at the "(" in the regexp itself, not at
> BOL as expected.
>
> ( (re-search-backward "( +" (line-beginning-position) t 1)

I presume you eval the form above by hitting 'C-x C-e' at the end of it.
Then Emacs starts running the code where point is, and find the first
occurrence of "( +" in the regexp itself.  Try this instead:

  ( *

where * indicated the position of point and hit:

  M-: (re-search-backward "( +" (line-beginning-position) t 1) RET

The same goes also for your other example:

  ( (looking-back "\\\\( +" (line-beginning-position) t) =3D=3D> nil

Try with :

  ( *

Again * is point and:

  M-: (looking-back "( +" (line-beginning-position)) RET

HTH.  Best, Arash