[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
- Re: non word abbrevs, Jean-Christophe Helary, 2021/11/01
- Re: non word abbrevs, Emanuel Berg, 2021/11/01
- Re: non word abbrevs, Stefan Monnier, 2021/11/01
- Re: non word abbrevs, Jean-Christophe Helary, 2021/11/06
- Re: non word abbrevs, Stefan Monnier, 2021/11/06
- Re: non word abbrevs, Jean-Christophe Helary, 2021/11/06
- Re: non word abbrevs, Stefan Monnier, 2021/11/06
- Re: non word abbrevs, Jean-Christophe Helary, 2021/11/06
- Re: non word abbrevs, Emanuel Berg, 2021/11/07
- Re: non word abbrevs, Kevin Vigouroux, 2021/11/08
- Re: non word abbrevs, Jean-Christophe Helary, 2021/11/08
- Re: non word abbrevs, Stefan Monnier, 2021/11/08
- Re: non word abbrevs, Emanuel Berg, 2021/11/07