emacs-devel
[Top][All Lists]
Advanced

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

Re: did the abbrev mechanism ever expand «two words» to «two different w


From: Uwe Brauer
Subject: Re: did the abbrev mechanism ever expand «two words» to «two different words».
Date: Fri, 08 Jan 2021 19:48:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>> "RP" == Robert Pluim <rpluim@gmail.com> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>> Right, thanks, however good and bad news.
>> 
>> 
>> I am using 
>> 
>> (define-abbrev-table 'fundamental-mode-abbrev-table
>> '(
>> ("a que" "a qué" nil :count 0)
>> ("asi" "así" nil :count 0))
>> "Uwe's table"
>> :regexp "\\(\\w+ \\w+\\)")
>> 
>> 
>> 1. It works in the sense that "a que" is expanded to "a qué"
>> 
>> 2. But now asi is *not* expanded to así
>> 
>> The reasons seems to me that what you did is globally for the whole
>> table, while I hoped it could be done locally for each entry.
>> 

> Thatʼs not the way abbrev tables work: the regexp answers the question
> "which characters before point do I use to lookup abbrevs in this
> table?". That can't be both two words separated by a space and a
> single word at the same time, ie using

> "\\(\\w+ \\w+\\)\\|\\(w+\\)


This is indeed what I tried.


> will fail, since that will match the 'two word' version if thereʼs a
> space on the line, so in order to get what you want you need two
> abbrev tables:

>     (define-abbrev-table 'fundamental-mode-abbrev-table
>       '(
>         ("asi" "así" nil :count 0)))

>     (define-abbrev-table 'my-abbrev-table
>       '(
>         ("a que" "a qué" nil :count 0))
>       "Uwe's table"
>       :regexp "\\(\\w+ \\w+\\)")
>     (setq local-abbrev-table (list my-abbrev-table 
> fundamental-mode-abbrev-table))

Thanks where  is the setq line supposed to be? Most likely in the file
in question which is in fundamental mode?

Not in  the .abbrev_devs file?

I tried the former and it works! May thanks. 

I might need to edit my abbrev times from time to time but that is ok
and it might be a hassle in mail  modes, but better than nothing.



> (thereʼs a ':parents' property you can set on an abbrev table to achieve
> the same thing, in theory, but I donʼt know how that interacts with
> ':regexp')

Maybe some other developer has an idea?


In any case, I think it would be very useful to add some of the stuff
Robert told me to the documentation, which is a bit sparse, I'd say.

Thanks and regards

Uwe 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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