unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* did the abbrev mechanism ever expand «two words» to «two different words».
@ 2021-01-07 20:10 Uwe Brauer
  2021-01-07 20:15 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Uwe Brauer @ 2021-01-07 20:10 UTC (permalink / raw)
  To: emacs-devel



Hi

I thought I had used the following successfully some time ago


(define-abbrev-table 'fundamental-mode-abbrev-table
  '(
    ("a que" "a qué" nil :count 0)
    ("asi" "así" nil :count 1)
    ("ciertas problemas" "ciertos problemas" nil :count 0)
    ("di nos" "dinos" nil :count 0)
    ("lamentamos de" "lamentamos comunicarte" nil :count 0)
    ("likke" "bike" nil :count 0)
    ("los siguientes circunstancias" "las siguientes circunstancias" nil :count 0)
    ("no se" "no sé" nil :count 0)
    ("portail" "portátil" nil :count 0)
    ("premierment" "premièrement" nil :count 0)
    ("thiss" "this" nil :count 0)
    ("varias ordenadores" "varios ordenadores" nil :count 0)
   ))


I open an empty file in fundamental mode turn abbrev mode on

And type 

 asi --> así  So the expansion works

However 

 "a que" is NOT expanded to "a qué"

As indicated in the table. I am pretty sure that worked some time ago. 

I filed even a bug report but now I am starting to doubt my own memory.
Could someone with a better memory than mine, help and tell me whether I
am wrong or correct?

Thanks 

Uwe Brauer 




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:10 did the abbrev mechanism ever expand «two words» to «two different words» Uwe Brauer
@ 2021-01-07 20:15 ` Eli Zaretskii
  2021-01-07 20:29   ` Uwe Brauer
                     ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Eli Zaretskii @ 2021-01-07 20:15 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

> From: Uwe Brauer <oub@mat.ucm.es>
> Date: Thu, 07 Jan 2021 21:10:54 +0100
> 
> I open an empty file in fundamental mode turn abbrev mode on
> 
> And type 
> 
>  asi --> así  So the expansion works
> 
> However 
> 
>  "a que" is NOT expanded to "a qué"
> 
> As indicated in the table. I am pretty sure that worked some time ago. 

I doubt it.  From the Emacs manual:

  An “abbrev” is a word that has been defined to “expand” into a specified
  “expansion”.  When you insert a word-separator character following the
  abbrev, that expands the abbrev—replacing the abbrev with its expansion.
  For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer
  otter’, then typing ‘f o o .’ will insert ‘find outer otter.’.

This mean a word-separator character cannot be part of an abbrev.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:15 ` Eli Zaretskii
@ 2021-01-07 20:29   ` Uwe Brauer
  2021-01-07 20:36   ` Stefan Monnier
  2021-01-09  6:37   ` did the abbrev mechanism ever expand «two words» to «two different words» Richard Stallman
  2 siblings, 0 replies; 19+ messages in thread
From: Uwe Brauer @ 2021-01-07 20:29 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1140 bytes --]

>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

>> From: Uwe Brauer <oub@mat.ucm.es>
>> Date: Thu, 07 Jan 2021 21:10:54 +0100
>> 
>> I open an empty file in fundamental mode turn abbrev mode on
>> 
>> And type 
>> 
>> asi --> así  So the expansion works
>> 
>> However 
>> 
>> "a que" is NOT expanded to "a qué"
>> 
>> As indicated in the table. I am pretty sure that worked some time ago. 

> I doubt it.  From the Emacs manual:

>   An “abbrev” is a word that has been defined to “expand” into a specified
>   “expansion”.  When you insert a word-separator character following the
>   abbrev, that expands the abbrev—replacing the abbrev with its expansion.
>   For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer
>   otter’, then typing ‘f o o .’ will insert ‘find outer otter.’.

> This mean a word-separator character cannot be part of an abbrev.


Yeah makes sense, but is there or was some package that would allow to
replace several strings by several other strings, in my case

 "a que" a "a qué"

I thought I had used that functionality, hm 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:15 ` Eli Zaretskii
  2021-01-07 20:29   ` Uwe Brauer
@ 2021-01-07 20:36   ` Stefan Monnier
  2021-01-07 20:40     ` Eli Zaretskii
  2021-01-08  8:20     ` Uwe Brauer
  2021-01-09  6:37   ` did the abbrev mechanism ever expand «two words» to «two different words» Richard Stallman
  2 siblings, 2 replies; 19+ messages in thread
From: Stefan Monnier @ 2021-01-07 20:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Uwe Brauer, emacs-devel

>   An “abbrev” is a word that has been defined to “expand” into a specified
>   “expansion”.  When you insert a word-separator character following the
>   abbrev, that expands the abbrev—replacing the abbrev with its expansion.
>   For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer
>   otter’, then typing ‘f o o .’ will insert ‘find outer otter.’.
>
> This mean a word-separator character cannot be part of an abbrev.

That's true for the default behavior.
Since Emacs-24, abbrev tables do support abbrevs whose name includes
non-word characters, but it requires extra work on the part of the user
in order to characterize the possible names via the `:regexp` property
(see `C-h o define-abbrev-table`).


        Stefan




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:36   ` Stefan Monnier
@ 2021-01-07 20:40     ` Eli Zaretskii
  2021-01-08  8:20     ` Uwe Brauer
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2021-01-07 20:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: oub, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Uwe Brauer <oub@mat.ucm.es>,  emacs-devel@gnu.org
> Date: Thu, 07 Jan 2021 15:36:52 -0500
> 
> >   An “abbrev” is a word that has been defined to “expand” into a specified
> >   “expansion”.  When you insert a word-separator character following the
> >   abbrev, that expands the abbrev—replacing the abbrev with its expansion.
> >   For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer
> >   otter’, then typing ‘f o o .’ will insert ‘find outer otter.’.
> >
> > This mean a word-separator character cannot be part of an abbrev.
> 
> That's true for the default behavior.
> Since Emacs-24, abbrev tables do support abbrevs whose name includes
> non-word characters, but it requires extra work on the part of the user
> in order to characterize the possible names via the `:regexp` property
> (see `C-h o define-abbrev-table`).

Then I guess we did a poor job of documenting that extension.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:36   ` Stefan Monnier
  2021-01-07 20:40     ` Eli Zaretskii
@ 2021-01-08  8:20     ` Uwe Brauer
  2021-01-08 10:55       ` Robert Pluim
  1 sibling, 1 reply; 19+ messages in thread
From: Uwe Brauer @ 2021-01-08  8:20 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]

>>> "SM" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> An “abbrev” is a word that has been defined to “expand” into a specified
>> “expansion”.  When you insert a word-separator character following the
>> abbrev, that expands the abbrev—replacing the abbrev with its expansion.
>> For example, if ‘foo’ is defined as an abbrev expanding to ‘find outer
>> otter’, then typing ‘f o o .’ will insert ‘find outer otter.’.
>> 
>> This mean a word-separator character cannot be part of an abbrev.

> That's true for the default behavior.
> Since Emacs-24, abbrev tables do support abbrevs whose name includes
> non-word characters, but it requires extra work on the part of the user
> in order to characterize the possible names via the `:regexp` property
> (see `C-h o define-abbrev-table`).

Thanks, I read the documentation but I am unable to figure out, what
regexp has to be used for that regexp I should use in order to make a
two word expansion work. 

All regexp I tried returned error.

So this 

(define-abbrev-table 'fundamental-mode-abbrev-table
  '(
    ("a que" "a qué" :regexp 1 :count 0)))


Does not return error but does not work as well.

May I suggest to add an example in the documentation of 

`C-h o define-abbrev-table`

Thanks 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08  8:20     ` Uwe Brauer
@ 2021-01-08 10:55       ` Robert Pluim
  2021-01-08 13:28         ` Uwe Brauer
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Pluim @ 2021-01-08 10:55 UTC (permalink / raw)
  To: emacs-devel

Uwe Brauer <oub@mat.ucm.es> writes:

> Thanks, I read the documentation but I am unable to figure out, what
> regexp has to be used for that regexp I should use in order to make a
> two word expansion work. 
>
> All regexp I tried returned error.
>
> So this 
>
> (define-abbrev-table 'fundamental-mode-abbrev-table
>   '(
>     ("a que" "a qué" :regexp 1 :count 0)))
>
>
> Does not return error but does not work as well.
>

You've forgotten the 'hook' argument in the abbrev definition. Also,
:regexp is a property for the whole table, so you need something like
this:

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

(I agree the documentation could be clearer)

Robert



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 10:55       ` Robert Pluim
@ 2021-01-08 13:28         ` Uwe Brauer
  2021-01-08 14:05           ` Robert Pluim
  0 siblings, 1 reply; 19+ messages in thread
From: Uwe Brauer @ 2021-01-08 13:28 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

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

> Uwe Brauer <oub@mat.ucm.es> writes:
>> Thanks, I read the documentation but I am unable to figure out, what
>> regexp has to be used for that regexp I should use in order to make a
>> two word expansion work. 
>> 
>> All regexp I tried returned error.
>> 
>> So this 
>> 
>> (define-abbrev-table 'fundamental-mode-abbrev-table
>> '(
>> ("a que" "a qué" :regexp 1 :count 0)))
>> 
>> 
>> Does not return error but does not work as well.
>> 

> You've forgotten the 'hook' argument in the abbrev definition. Also,
> :regexp is a property for the whole table, so you need something like
> this:

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

> (I agree the documentation could be clearer)

Thanks but it did not work. 
I am using emacs (28) master
commit 
"84ec57fe06e187f41a3546131d5dae3b185c3511"

I overwrote my complete fundamental-mode-abbrev-table
with your suggestion and restarted emacs
(BTW edit-abbrev did not show the regexp)

In any case 

 a que was not expanded to a qué 

To make matter worse, I added your suggestion to my old
fundamental-mode-abbrev-table restarted emacs and then *nothing* was
expanded.

I am puzzled

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 13:28         ` Uwe Brauer
@ 2021-01-08 14:05           ` Robert Pluim
  2021-01-08 15:23             ` Uwe Brauer
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Pluim @ 2021-01-08 14:05 UTC (permalink / raw)
  To: emacs-devel

> To make matter worse, I added your suggestion to my old
> fundamental-mode-abbrev-table restarted emacs and then *nothing* was
> expanded.
>
> I am puzzled
>

Hmm, so am I. Youʼre right, what I sent doesnʼt work, but this does:

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

Robert



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 14:05           ` Robert Pluim
@ 2021-01-08 15:23             ` Uwe Brauer
  2021-01-08 18:05               ` Robert Pluim
  0 siblings, 1 reply; 19+ messages in thread
From: Uwe Brauer @ 2021-01-08 15:23 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

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

>> To make matter worse, I added your suggestion to my old
>> fundamental-mode-abbrev-table restarted emacs and then *nothing* was
>> expanded.
>> 
>> I am puzzled
>> 

> Hmm, so am I. Youʼre right, what I sent doesnʼt work, but this does:

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

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.

Am I correct?



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 15:23             ` Uwe Brauer
@ 2021-01-08 18:05               ` Robert Pluim
  2021-01-08 18:48                 ` Uwe Brauer
                                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Robert Pluim @ 2021-01-08 18:05 UTC (permalink / raw)
  To: emacs-devel

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+\\)

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))

(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')

Robert



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 18:05               ` Robert Pluim
@ 2021-01-08 18:48                 ` Uwe Brauer
  2021-01-08 20:29                 ` Stefan Monnier
  2021-01-09 13:42                 ` [BUG? write-abbrev-file destroys this construction] (was: did the abbrev mechanism ever expand «two words» to «two different words».) Uwe Brauer
  2 siblings, 0 replies; 19+ messages in thread
From: Uwe Brauer @ 2021-01-08 18:48 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2201 bytes --]

>>> "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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 18:05               ` Robert Pluim
  2021-01-08 18:48                 ` Uwe Brauer
@ 2021-01-08 20:29                 ` Stefan Monnier
  2021-01-08 21:06                   ` Uwe Brauer
  2021-01-09 13:42                 ` [BUG? write-abbrev-file destroys this construction] (was: did the abbrev mechanism ever expand «two words» to «two different words».) Uwe Brauer
  2 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2021-01-08 20:29 UTC (permalink / raw)
  To: emacs-devel

> 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+\\)

Note that these regexps will be matched via `re-search-backward` so
\\(w+\\) will typically only match a single character (it stops at the
*rightmost* match).

Another way to go about it is to construct the regexp from the set of
abbrevs using `regexp-opt`.


        Stefan




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 20:29                 ` Stefan Monnier
@ 2021-01-08 21:06                   ` Uwe Brauer
  2021-01-09 12:14                     ` Eric S Fraga
  0 siblings, 1 reply; 19+ messages in thread
From: Uwe Brauer @ 2021-01-08 21:06 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

>>> "SM" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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+\\)

> Note that these regexps will be matched via `re-search-backward` so
> \\(w+\\) will typically only match a single character (it stops at the
> *rightmost* match).

> Another way to go about it is to construct the regexp from the set of
> abbrevs using `regexp-opt`.


Robert's solution works, the only downside is that I need and additional 

    (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))

In each buffer which is a bit cumbersome. 

Are you saying this could be avoided using regexp-opt? If so how?


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-07 20:15 ` Eli Zaretskii
  2021-01-07 20:29   ` Uwe Brauer
  2021-01-07 20:36   ` Stefan Monnier
@ 2021-01-09  6:37   ` Richard Stallman
  2021-01-09  8:11     ` [adding abbrev using two-word-expansions] (was: did the abbrev mechanism ever expand «two words» to «two different words».) Uwe Brauer
  2 siblings, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2021-01-09  6:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: oub, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > This mean a word-separator character cannot be part of an abbrev.

I am pretty sure that was always the case.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 19+ messages in thread

* [adding abbrev using two-word-expansions] (was: did the abbrev mechanism ever expand «two words» to «two different words».)
  2021-01-09  6:37   ` did the abbrev mechanism ever expand «two words» to «two different words» Richard Stallman
@ 2021-01-09  8:11     ` Uwe Brauer
  0 siblings, 0 replies; 19+ messages in thread
From: Uwe Brauer @ 2021-01-09  8:11 UTC (permalink / raw)
  To: Richard Stallman; +Cc: oub, Eli Zaretskii, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 6337 bytes --]

>>> "RS" == Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]

>> This mean a word-separator character cannot be part of an abbrev.

> I am pretty sure that was always the case.

Well in my .abbrev_defs files I have entries like 


    ("en cambio" "a cambio" nil :count 34)

Which seems to indicate that it worked at same stage. Maybe I used code
similar of what Robert suggested but deleted it some time ago
(documentation is important).


I want to add a remark, concerning adding new abbrev.

I have now  a modification of my code



(define-minor-mode castellano-minor-mode
    nil nil nil nil
    (setq local-abbrev-table
          (if castellano-minor-mode
              (list my-abbrev-table castellano-minor-mode-abbrev-table)))
    (message "Added the local `my-abbrev-table' to the `castellano-minor-abbrev-table'"))


I used to define two words abbrev like this


(defun ediff-define-abbrev ()
  (interactive)
  (let ((name (get-register ?A)))
	(let ((expansion (get-register ?B)))
	  (set-text-properties 0 (length name) nil name)
	  (define-abbrev local-abbrev-table  name (downcase expansion))))
  (message "abbrev is added using register A and B."))

That however does not work any more instead gives an error of the form 


Any idea what to do, now?



Debugger entered--Lisp error: (wrong-type-argument vectorp ([de\ usar 0
  0 en\ la\ mayor\ brevedad\ posible de\ la\ entrega 0 en\ la\
  siguiente\ manera los\ prácticas\ 0 hola\ salva a\ final 0 0 0 0 los\
  funciones 0 0 0 0 0 0 hola\ gabriel a\ penas de\ comprometerme\ de\
  darte 0 0 0 0 hola\ raúl posibilidad\ hacerlo 0 0 0 hola\ alicia 0 0
  los\ siguientes\ cosas 0 0 0 los\ siguientes\ posibilidades les\
  ruego\ aclararme en\ internet los\ manos 0 0 0 0 lamento\ que\ me\
  has\ encontrado ...] [áfrica vacio votacion utlidad volutarios útlies
  vistemos vicino terero vacuana áfin vostros util vostotros vistido
  veronica varibilidad vienieras varidad traquilidad veniste tristesa
  verifca venieron victimas volvia traduccir volutaria vecorial
  virtualizar àrea viveis supervision trival tutoria zanhoria vivia
  vivian vivisite vuitre tradicion volutario varon zero volvere tuvé
  vistitado virnes ví vendria ...])) intern-soft("" ([de\ usar 0 0 en\
  la\ mayor\ brevedad\ posible de\ la\ entrega 0 en\ la\ siguiente\
  manera los\ prácticas\ 0 hola\ salva a\ final 0 0 0 0 los\ funciones 0
  0 0 0 0 0 hola\ gabriel a\ penas de\ comprometerme\ de\ darte 0 0 0 0
  hola\ raúl posibilidad\ hacerlo 0 0 0 hola\ alicia 0 0 los\
  siguientes\ cosas 0 0 0 los\ siguientes\ posibilidades les\ ruego\
  aclararme en\ internet los\ manos 0 0 0 0 lamento\ que\ me\ has\
  encontrado ...] [áfrica vacio votacion utlidad volutarios útlies
  vistemos vicino terero vacuana áfin vostros util vostotros vistido
  veronica varibilidad vienieras varidad traquilidad veniste tristesa
  verifca venieron victimas volvia traduccir volutaria vecorial
  virtualizar àrea viveis supervision trival tutoria zanhoria vivia
  vivian vivisite vuitre tradicion volutario varon zero volvere tuvé
  vistitado virnes ví vendria ...])) obarray-get(([de\ usar 0 0 en\ la\
  mayor\ brevedad\ posible de\ la\ entrega 0 en\ la\ siguiente\ manera
  los\ prácticas\ 0 hola\ salva a\ final 0 0 0 0 los\ funciones 0 0 0 0
  0 0 hola\ gabriel a\ penas de\ comprometerme\ de\ darte 0 0 0 0 hola\
  raúl posibilidad\ hacerlo 0 0 0 hola\ alicia 0 0 los\ siguientes\
  cosas 0 0 0 los\ siguientes\ posibilidades les\ ruego\ aclararme en\
  internet los\ manos 0 0 0 0 lamento\ que\ me\ has\ encontrado ...]
  [áfrica vacio votacion utlidad volutarios útlies vistemos vicino
  terero vacuana áfin vostros util vostotros vistido veronica
  varibilidad vienieras varidad traquilidad veniste tristesa verifca
  venieron victimas volvia traduccir volutaria vecorial virtualizar àrea
  viveis supervision trival tutoria zanhoria vivia vivian vivisite
  vuitre tradicion volutario varon zero volvere tuvé vistitado virnes ví
  vendria ...]) "") abbrev-table-get(([de\ usar 0 0 en\ la\ mayor\
  brevedad\ posible de\ la\ entrega 0 en\ la\ siguiente\ manera los\
  prácticas\ 0 hola\ salva a\ final 0 0 0 0 los\ funciones 0 0 0 0 0 0
  hola\ gabriel a\ penas de\ comprometerme\ de\ darte 0 0 0 0 hola\ raúl
  posibilidad\ hacerlo 0 0 0 hola\ alicia 0 0 los\ siguientes\ cosas 0 0
  0 los\ siguientes\ posibilidades les\ ruego\ aclararme en\ internet
  los\ manos 0 0 0 0 lamento\ que\ me\ has\ encontrado ...] [áfrica
  vacio votacion utlidad volutarios útlies vistemos vicino terero
  vacuana áfin vostros util vostotros vistido veronica varibilidad
  vienieras varidad traquilidad veniste tristesa verifca venieron
  victimas volvia traduccir volutaria vecorial virtualizar àrea viveis
  supervision trival tutoria zanhoria vivia vivian vivisite vuitre
  tradicion volutario varon zero volvere tuvé vistitado virnes ví
  vendria ...]) :abbrev-table-modiff) define-abbrev(([de\ usar 0 0 en\
  la\ mayor\ brevedad\ posible de\ la\ entrega 0 en\ la\ siguiente\
  manera los\ prácticas\ 0 hola\ salva a\ final 0 0 0 0 los\ funciones 0
  0 0 0 0 0 hola\ gabriel a\ penas de\ comprometerme\ de\ darte 0 0 0 0
  hola\ raúl posibilidad\ hacerlo 0 0 0 hola\ alicia 0 0 los\
  siguientes\ cosas 0 0 0 los\ siguientes\ posibilidades les\ ruego\
  aclararme en\ internet los\ manos 0 0 0 0 lamento\ que\ me\ has\
  encontrado ...] [áfrica vacio votacion utlidad volutarios útlies
  vistemos vicino terero vacuana áfin vostros util vostotros vistido
  veronica varibilidad vienieras varidad traquilidad veniste tristesa
  verifca venieron victimas volvia traduccir volutaria vecorial
  virtualizar àrea viveis supervision trival tutoria zanhoria vivia
  vivian vivisite vuitre tradicion volutario varon zero volvere tuvé
  vistitado virnes ví vendria ...]) "cuando antes" "cuanto antes")
  ediff-define-abbrev() funcall-interactively(ediff-define-abbrev)
  call-interactively(ediff-define-abbrev nil nil)
  command-execute(ediff-define-abbrev)

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-08 21:06                   ` Uwe Brauer
@ 2021-01-09 12:14                     ` Eric S Fraga
  2021-01-09 13:39                       ` Uwe Brauer
  0 siblings, 1 reply; 19+ messages in thread
From: Eric S Fraga @ 2021-01-09 12:14 UTC (permalink / raw)
  To: emacs-devel

On Friday,  8 Jan 2021 at 22:06, Uwe Brauer wrote:
> Robert's solution works, the only downside is that I need and additional 
>
> (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))
>
> In each buffer which is a bit cumbersome. 

If all of your files are in a directory (or collection of
subdirectories), you could use directory local variables maybe?

-- 
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: did the abbrev mechanism ever expand «two words» to «two different words».
  2021-01-09 12:14                     ` Eric S Fraga
@ 2021-01-09 13:39                       ` Uwe Brauer
  0 siblings, 0 replies; 19+ messages in thread
From: Uwe Brauer @ 2021-01-09 13:39 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

>>> "ESF" == Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Friday,  8 Jan 2021 at 22:06, Uwe Brauer wrote:
>> Robert's solution works, the only downside is that I need and additional 
>> 
>> (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))
>> 
>> In each buffer which is a bit cumbersome. 

> If all of your files are in a directory (or collection of
> subdirectories), you could use directory local variables maybe?

I found a way around this problem: I will use minor modes.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [BUG? write-abbrev-file destroys this construction] (was: did the abbrev mechanism ever expand «two words» to «two different words».)
  2021-01-08 18:05               ` Robert Pluim
  2021-01-08 18:48                 ` Uwe Brauer
  2021-01-08 20:29                 ` Stefan Monnier
@ 2021-01-09 13:42                 ` Uwe Brauer
  2 siblings, 0 replies; 19+ messages in thread
From: Uwe Brauer @ 2021-01-09 13:42 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]


> Uwe Brauer <oub@mat.ucm.es> writes:

> 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+\\)

> 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+\\)")


Your code works, if I put it in by .abbrev_defs file and re-read the
abbrev file. However when close emacs write-abbrev-file somehow destroys
the table with the regexp. Is this a bug?

This parts enters a minor mode
>     (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-01-09 13:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 20:10 did the abbrev mechanism ever expand «two words» to «two different words» Uwe Brauer
2021-01-07 20:15 ` Eli Zaretskii
2021-01-07 20:29   ` Uwe Brauer
2021-01-07 20:36   ` Stefan Monnier
2021-01-07 20:40     ` Eli Zaretskii
2021-01-08  8:20     ` Uwe Brauer
2021-01-08 10:55       ` Robert Pluim
2021-01-08 13:28         ` Uwe Brauer
2021-01-08 14:05           ` Robert Pluim
2021-01-08 15:23             ` Uwe Brauer
2021-01-08 18:05               ` Robert Pluim
2021-01-08 18:48                 ` Uwe Brauer
2021-01-08 20:29                 ` Stefan Monnier
2021-01-08 21:06                   ` Uwe Brauer
2021-01-09 12:14                     ` Eric S Fraga
2021-01-09 13:39                       ` Uwe Brauer
2021-01-09 13:42                 ` [BUG? write-abbrev-file destroys this construction] (was: did the abbrev mechanism ever expand «two words» to «two different words».) Uwe Brauer
2021-01-09  6:37   ` did the abbrev mechanism ever expand «two words» to «two different words» Richard Stallman
2021-01-09  8:11     ` [adding abbrev using two-word-expansions] (was: did the abbrev mechanism ever expand «two words» to «two different words».) Uwe Brauer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).