help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non word abbrevs


From: Stefan Monnier
Subject: Re: non word abbrevs
Date: Mon, 01 Nov 2021 13:58:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> Try something like: "[^<>=-]\\([<>=-]+\\)"
>> [ Yes, this shortest match business is a PITA.  ]
>
> My abbrevs are arrows composed of < or > at the tips and - or = with
> a minimum of 2 characters and a max of 3:
>
> → ⇒
> ← ⇐
> ↔ ⇔
>
> In a different world, I'd try [<>=-]{2,3}
>
> Is that what you mean ?

No, the [^<>=-] is the important part: it tells Emacs to keep looking
(going backward) for a longer match.

If you use "[<>=-]\\{2,3\\}" (which does exist in our beloved ELisp
world), then Emacs's regexp matcher will go as follows:

- Let's say we're in a line with "<=> hello", with point just after the ">".
- The regexp search will first try to match (backward) ">" against the
  regexp, which will fail.
- It will then try to match "=>" against the regexp, which will succeed.
- At this point it stops and fails to notice that the regexp would also
  have matched "<=>", so you won't get the abbrev expansion you wanted.


-- Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]