bug#45693: 28.0.50; abbrev does not expand two words any more

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

bug#45693: 28.0.50; abbrev does not expand two words any more

Lars Ingebrigtsen
Uwe Brauer <[hidden email]> writes:

> I swear that worked some time ago.

This was discussed on the emacs-devel mailing list, and apparently it
never worked?  But reading that discussion, it seems like this is
under-documented.  Could you suggest something for the manual after you
actually get this working?  :-)

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#45693: 28.0.50; abbrev does not expand two words any more

Lars Ingebrigtsen
Uwe Brauer <[hidden email]> writes:

> I am trying to set up a recipe to reproduce that behavior. If I do that,
> should I open a new bug or just post it here?

Just post it here.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#45693: 28.0.50; abbrev does not expand two words any more

Uwe Brauer
>>> "LI" == Lars Ingebrigtsen <[hidden email]> writes:

> Uwe Brauer <[hidden email]> writes:
>> I am trying to set up a recipe to reproduce that behavior. If I do that,
>> should I open a new bug or just post it here?

> Just post it here.

Ok I will I just found another problem of Robert's solution concerning
flyspell (which is currently maintained by the emacs developers).

I will post both soon.

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it] (was: bug#45693: 28.0.50; abbrev does not expand two words any more)

Uwe Brauer
In reply to this post by Lars Ingebrigtsen
>>> "LI" == Lars Ingebrigtsen <[hidden email]> writes:

> Uwe Brauer <[hidden email]> writes:
>> I am trying to set up a recipe to reproduce that behavior. If I do that,
>> should I open a new bug or just post it here?

> Just post it here.

The solution posted by Robert Pluim allows a two word expansion but will
be destroyed by write-abbrev-file

Step to reproduce the issue.

    1. Start emacs -Q (using master commit  "84ec57fe06e187f41a3546131d5dae3b185c3511")

    2. Create an abbrev file (see attachment) called .abbrev-doble_defs
       that contain
       (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+\\)")

    3. Load files with the following lines
       (setq abbrev-file-name "~/ALLES/HGs/init_files/Abbrev-Doble/.abbrev-new_defs")
       (read-abbrev-file "~/ALLES/HGs/init_files/Abbrev-Doble/.abbrev-double_defs")
       (setq-default abbrev-mode t)
       Or any other path that is convenient.

    4. Open new file in fundamental mode, say called new
       execute in that file
       (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))

       Then asi--> así
       and
       a que--> a quë

    5. (write-abbrev-file "~/ALLES/HGs/init_files/Abbrev-Doble/.abbrev-new_defs")

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

Is gone!

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

> The part
>         (define-abbrev-table 'my-abbrev-table
>       '(
>         ("a que" "a qué" nil :count 0))
>       "Uwe's table"
>       :regexp "\\(\\w+ \\w+\\)")
>
> Is gone!

Yes, and it gets worse. You can get around the 'setq
local-abbrev-table' issue by using the ':parents' property:

    (define-abbrev-table 'fundamental-mode-abbrev-table
      '(
        ("asi" "así" nil :count 0))
      "Fundamental"
      :parents (list my-abbrev-table))

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


but write-abbrev-table then produces the following abbrev file:

;;-*-coding: utf-8;-*-
(define-abbrev-table 'fundamental-mode-abbrev-table
  '(
    ("asi" "así" nil :count 1)
   ))

(define-abbrev-table 'my-abbrev-table
  '(
    ("a que" "a qué" nil :count 1)
   ))

so write-abbrev-file doesnʼt write any of the properties specified in
define-abbrev-table to the abbrev file.

Robert



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Eli Zaretskii
> From: Robert Pluim <[hidden email]>
> Date: Mon, 11 Jan 2021 11:49:41 +0100
> Cc: Lars Ingebrigtsen <[hidden email]>, [hidden email]
>
> Uwe Brauer <[hidden email]> writes:
>
> > The part
> >         (define-abbrev-table 'my-abbrev-table
> >       '(
> >         ("a que" "a qué" nil :count 0))
> >       "Uwe's table"
> >       :regexp "\\(\\w+ \\w+\\)")
> >
> > Is gone!
>
> Yes, and it gets worse. You can get around the 'setq
> local-abbrev-table' issue by using the ':parents' property:
>
>     (define-abbrev-table 'fundamental-mode-abbrev-table
>       '(
>         ("asi" "así" nil :count 0))
>       "Fundamental"
>       :parents (list my-abbrev-table))
>
>     (define-abbrev-table 'my-abbrev-table
>       '(
>         ("a que" "a qué" nil :count 0))
>       "Uwe's table"
>       :regexp "\\(\\w+ \\w+\\)")
>
>
> but write-abbrev-table then produces the following abbrev file:
>
> ;;-*-coding: utf-8;-*-
> (define-abbrev-table 'fundamental-mode-abbrev-table
>   '(
>     ("asi" "así" nil :count 1)
>    ))
>
> (define-abbrev-table 'my-abbrev-table
>   '(
>     ("a que" "a qué" nil :count 1)
>    ))
>
> so write-abbrev-file doesnʼt write any of the properties specified in
> define-abbrev-table to the abbrev file.

So does it mean we had better avoid describing this "feature" in the
docs, until and unless it gets fixed to be more user-friendly?



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer


> So does it mean we had better avoid describing this "feature" in the
> docs, until and unless it gets fixed to be more user-friendly?

Well, I find it useful and found a real kludge by using two abbrev files
and associated minor modes. I think what is *really* missing is to
improve/rewrite the write-abbrev-file function.

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

>> So does it mean we had better avoid describing this "feature" in the
>> docs, until and unless it gets fixed to be more user-friendly?
>
> Well, I find it useful and found a real kludge by using two abbrev files
> and associated minor modes. I think what is *really* missing is to
> improve/rewrite the write-abbrev-file function.

At the very least we need to support :regexp and
:case-fixed. Something like this, maybe?

diff --git i/lisp/abbrev.el w/lisp/abbrev.el
index 65f7118385..21b4af095f 100644
--- i/lisp/abbrev.el
+++ w/lisp/abbrev.el
@@ -1074,7 +1074,11 @@ insert-abbrev-table-description
 a call to `define-abbrev-table' that when evaluated will define
 the abbrev table NAME exactly as it is currently defined.
 Abbrevs marked as \"system abbrevs\" are ignored."
-  (let ((symbols (abbrev--table-symbols name readable)))
+  (let* ((symbols (abbrev--table-symbols name readable))
+        (docstring (or (documentation-property name 'variable-documentation)
+                       "no documentation"))
+        (sym (obarray-get (symbol-value name) ""))
+        (props (symbol-plist sym)))
     (setq symbols (sort symbols 'string-lessp))
     (let ((standard-output (current-buffer)))
       (if readable
@@ -1090,7 +1094,13 @@ insert-abbrev-table-description
             (insert " '())\n\n")
           (insert "\n  '(\n")
           (mapc 'abbrev--write symbols)
-          (insert "   ))\n\n")))
+          (insert "   )\n")
+          (insert (format "%S\n" docstring))
+          (when (plist-member props :case-fixed)
+            (insert (format "%s %s\n" :case-fixed (plist-get props :case-fixed))))
+          (when (plist-member props :regexp)
+            (insert (format "%s %S\n" :regexp (plist-get props :regexp))))
+          (insert ")\n\n")))
       nil)))
 
 (defun abbrev--table-symbols (name &optional system)



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer
>>> "RP" == Robert Pluim <[hidden email]> writes:

> Uwe Brauer <[hidden email]> writes:
>>> So does it mean we had better avoid describing this "feature" in the
>>> docs, until and unless it gets fixed to be more user-friendly?
>>
>> Well, I find it useful and found a real kludge by using two abbrev files
>> and associated minor modes. I think what is *really* missing is to
>> improve/rewrite the write-abbrev-file function.

Thanks,

    1. I pulled the last GNU Emacs master,

    2. applied your patch, compiled,

    3. started emacs -Q

    4. loaded the new abbrev file and

    5. then repeated the steps as described,

but the write function behaved in the same way as before. Maybe I am too
tired and should retry it tomorrow.

Sorry.

> At the very least we need to support :regexp and
> :case-fixed. Something like this, maybe?

> diff --git i/lisp/abbrev.el w/lisp/abbrev.el
> index 65f7118385..21b4af095f 100644
> --- i/lisp/abbrev.el
> +++ w/lisp/abbrev.el
> @@ -1074,7 +1074,11 @@ insert-abbrev-table-description
>  a call to `define-abbrev-table' that when evaluated will define
>  the abbrev table NAME exactly as it is currently defined.
>  Abbrevs marked as \"system abbrevs\" are ignored."
> -  (let ((symbols (abbrev--table-symbols name readable)))
> +  (let* ((symbols (abbrev--table-symbols name readable))
> +        (docstring (or (documentation-property name 'variable-documentation)
> +                       "no documentation"))
> +        (sym (obarray-get (symbol-value name) ""))
> +        (props (symbol-plist sym)))
>      (setq symbols (sort symbols 'string-lessp))
>      (let ((standard-output (current-buffer)))
>        (if readable
> @@ -1090,7 +1094,13 @@ insert-abbrev-table-description
>              (insert " '())\n\n")
>            (insert "\n  '(\n")
>            (mapc 'abbrev--write symbols)
> -          (insert "   ))\n\n")))
> +          (insert "   )\n")
> +          (insert (format "%S\n" docstring))
> +          (when (plist-member props :case-fixed)
> +            (insert (format "%s %s\n" :case-fixed (plist-get props :case-fixed))))
> +          (when (plist-member props :regexp)
> +            (insert (format "%s %S\n" :regexp (plist-get props :regexp))))
> +          (insert ")\n\n")))
>        nil)))
 
>  (defun abbrev--table-symbols (name &optional system)

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

>>>> "RP" == Robert Pluim <[hidden email]> writes:
>
>> Uwe Brauer <[hidden email]> writes:
>>>> So does it mean we had better avoid describing this "feature" in the
>>>> docs, until and unless it gets fixed to be more user-friendly?
>>>
>>> Well, I find it useful and found a real kludge by using two abbrev files
>>> and associated minor modes. I think what is *really* missing is to
>>> improve/rewrite the write-abbrev-file function.
>
> Thanks,
>
>     1. I pulled the last GNU Emacs master,
>
>     2. applied your patch, compiled,
>
>     3. started emacs -Q
>
>     4. loaded the new abbrev file and
>

Which new abbrev file? You'll need to do at least some
'define-abbrev-table' followed by 'write-abbrev-file' (and the patch
doesnʼt solve the :parents issue).

Robert



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer

> Uwe Brauer <[hidden email]> writes:

> It should have been, and was in my testing


> Iʼve only tested my code, not proven it bug-free :-)


I think I found a bug. I restart my emacs with your patched abbrev file
and all my stuff, then I obtain the following error:

Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" ".abbrev_defs")
  load(".abbrev_defs" nil t)
  read-abbrev-file(".abbrev_defs" t)
  quietly-read-abbrev-file(".abbrev_defs")
  command-line()
  normal-top-level()


This is part of the list of my files in the home directory

  lrwxrwxrwx   1 oub  oub    43 ene 11 21:14 .abbrev_defs -> /home/oub/ALLES/HGs/init_files/.abbrev_defs
  -rw-r--r--   1 oub  oub     0 mar 12  2018 .abbrev_defs_xemacs
  lrwxrwxrwx   1 oub  oub    49 feb  6  2018 .abbrev-emacs_defs -> /home/oub/ALLES/HGs/init_files/.abbrev-emacs_defs
  -rw-rw-r--   1 oub  oub  1,4K ene 11 20:57 abbrev-patch
  -rw-rw-r--   1 oub  oub  1,4K nov 27 08:41 abstract2.patch
  -rw-------   1 oub  oub  1,4K nov 27 08:40 abstract.patch

So what works is
(read-abbrev-file "~/.abbrev_defs")

But not

(read-abbrev-file ".abbrev_defs")

 what currently emacs is trying to do.

Uwe

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer
>>> "RP" == Robert Pluim <[hidden email]> writes:

> Uwe Brauer <[hidden email]> writes:
>>> Uwe Brauer <[hidden email]> writes:
>>
>>> It should have been, and was in my testing
>>
>>
>>> Iʼve only tested my code, not proven it bug-free :-)
>>
>>
>> I think I found a bug. I restart my emacs with your patched abbrev file
>> and all my stuff, then I obtain the following error:
>>
>> Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" ".abbrev_defs")
>> load(".abbrev_defs" nil t)
>> read-abbrev-file(".abbrev_defs" t)
>> quietly-read-abbrev-file(".abbrev_defs")
>> command-line()
>> normal-top-level()
>>

> What's your 'abbrev-file-name' set to? Emacs uses 'load' to read it,

,----
| abbrev-file-name is a variable defined in ‘abbrev.el’.
| Its value is ".abbrev_defs"
| Original value was
| "/home/oub/.abbrev_defs"
|
|   You can customize this variable.
|
| Documentation:
| Default name of file from which to read abbrevs.
`----

The default value .abbrev_defs seems odd to me shouldn't it per default
be
"~/.abbrev_defs" at least for Unix/BSD dialects and MacOS?

> so it should be a complete pathname, ie "~/.abbrev_defs", or it should
> be in your 'load-path' somewhere.

But the point is. If I use the vanilla abbrev file from master I don't
get an error, with your patched version I do, but I think I know what's
up, I had some old abbrev.el file somewhere in my load path. Because
with abbrev vanilla from emacs master, my abbrevs are not loaded.
I check that and re try your patched version later (I still struggle
with flyspells abbrev mechanism).


smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer
In reply to this post by Uwe Brauer

> Uwe Brauer <[hidden email]> writes:

> What's your 'abbrev-file-name' set to? Emacs uses 'load' to read it,
> so it should be a complete pathname, ie "~/.abbrev_defs", or it should
> be in your 'load-path' somewhere.

Good and bad news. I repeated the test carefully looking around for old
abbrev.el or .abbrev_defs file.

    1. Good, I can confirm that your patched abbrev.el works in the
       sense that write-abbrev-file does not destroy the properties of
       the table.

    2. However I tried to add a local abbrev (or an inverse local
       abbrev) in the fundamental mode, but I obtain

obarray-get: Wrong type argument: vectorp, ([## 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0 0 0 0 0 ...]) [2 times]

That is maybe the reason I run into difficulties if I want to use
flyspell's abbrev mode if a correction occurs.

Regards

Uwe

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

>> Uwe Brauer <[hidden email]> writes:
>
>> What's your 'abbrev-file-name' set to? Emacs uses 'load' to read it,
>> so it should be a complete pathname, ie "~/.abbrev_defs", or it should
>> be in your 'load-path' somewhere.
>
> Good and bad news. I repeated the test carefully looking around for old
> abbrev.el or .abbrev_defs file.
>
>     1. Good, I can confirm that your patched abbrev.el works in the
>        sense that write-abbrev-file does not destroy the properties of
>        the table.
>
>     2. However I tried to add a local abbrev (or an inverse local
>        abbrev) in the fundamental mode, but I obtain
>
> obarray-get: Wrong type argument: vectorp, ([## 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0 0 0 0 0 ...]) [2 times]

Could you tell me exactly what you did? I suspect there are more
places that are not aware of the :parents property that need fixing.

> That is maybe the reason I run into difficulties if I want to use
> flyspell's abbrev mode if a correction occurs.

I donʼt use flyspell. Tell me more and we can look at fixing that as
well.

Robert



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer
>>> "RP" == Robert Pluim <[hidden email]> writes:

> Uwe Brauer <[hidden email]> writes:
>>> Uwe Brauer <[hidden email]> writes:
>>
>>> What's your 'abbrev-file-name' set to? Emacs uses 'load' to read it,
>>> so it should be a complete pathname, ie "~/.abbrev_defs", or it should
>>> be in your 'load-path' somewhere.
>>
>> Good and bad news. I repeated the test carefully looking around for old
>> abbrev.el or .abbrev_defs file.
>>
>> 1. Good, I can confirm that your patched abbrev.el works in the
>> sense that write-abbrev-file does not destroy the properties of
>> the table.
>>
>> 2. However I tried to add a local abbrev (or an inverse local
>> abbrev) in the fundamental mode, but I obtain
>>
>> obarray-get: Wrong type argument: vectorp, ([## 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0 0 0 0 0 ...]) [2 times]

> Could you tell me exactly what you did? I suspect there are more
> places that are not aware of the :parents property that need fixing.

I will first describe the problem adding a local abbrev, I suspect that
fixing that problem would also fix the flyspell problem, since flyspell
uses the local-abbrev command (at least in my setting: I have
set
(setq flyspell-use-global-abbrev-table-p nil))



Steps to reproduce (I attach the files for convenience)

    1. Start emacs -Q

    2. Load the patched abbrev.el provided by Robert

    3. Load or execute the following

       a. (setq abbrev-file-name "~/Abbrev-Doble/.abbrev-new_defs") ; or
          any other path

       b. (read-abbrev-file "~/Abbrev-Doble/.abbrev-double_defs") ; file attached

       c. (setq-default abbrev-mode t)

    4. Open a file in fundamental mode, called say new.

    5. Execute (setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))

    6. Check via edit-abbrevs (note: the properties are not displayed by
       this function! Should that be fixed also?

    7. Check whether the doble expansion works:

       a. Type a que

       b. Indeed it works

    8. Add a local (inverse) abbrev:

       a. Type nacion

       b. Put the cursor at the end of the word

       c. Type C-x a i l

       d. Type nación

       e. The error pops up
          obarray-get: Wrong type argument: vectorp, ([## 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0 0 0 0 0 ...])

    9. Repeat step 7 but use C-x a i g

       a. No error! Understandable because the global abbrev table does
          not have properties.

Did I explain that enough?

Uwe



.abbrev-double_defs (402 bytes) Download Attachment
new (500 bytes) Download Attachment
test-doble-abbrev.el (236 bytes) Download Attachment
smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer

> Uwe Brauer <[hidden email]> writes:

> Yes, perfect, thanks. inverse-add-mode-abbrev tries to add the abbrev
> to 'local-abbrev-table', which is a list here:

> Debugger entered--Lisp error: (wrong-type-argument vectorp ([## 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0 0 asi 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...]))
>   intern-soft("" ([## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0
> 0 0 asi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 ...]))
>   obarray-get(([## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0 0
> 0 asi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 ...]) "")
>   abbrev-table-get(([## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0
> 0 0 0 asi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 ...]) :abbrev-table-modiff)
>   define-abbrev(([## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0 0 0
> 0 0 asi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 ...]) "nacion" "the nation")
>   inverse-add-abbrev(([## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a\ que 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...] [## 0 0
> 0 0 0 0 asi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 ...]) "Mode" 1)
>   inverse-add-mode-abbrev(1)
>   funcall-interactively(inverse-add-mode-abbrev 1)
>   call-interactively(inverse-add-mode-abbrev nil nil)
>   command-execute(inverse-add-mode-abbrev)

> So itʼs explicitly documented that 'local-abbrev-table' can be a
> *list* of abbrev tables, but lots of the abbrev code assumes that
> it gets passed a single table.

> Itʼs easy enough to check for 'consp' in such cases, but then which of
> tables in that list should we add the abbrev to? The first one? All of
> them?

> Iʼm leaning towards "first, and document that you should put the most
> specific table at the front of the list of local abbrev tables", but
> Iʼd welcome opinions from others.

I am not entirely sure, I understand the logic behind this. To give you
a concrete example. (That enters now the flyspell problem).

I have defined for each language I use flypsell/ispell a minor mode and
a corresponding local-abbrev table.

    1. American

    2. British

    3. German

    4. Spanish

    5. French

    6. And even Hebrew (but we can leave that may out for the moment).

Now say I am in latex mode and turn spelling for American on (which in
turn turn the minor mode american-spelling on), is then the local abbrev
table the first in that list?


Uwe

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

>> So itʼs explicitly documented that 'local-abbrev-table' can be a
>> *list* of abbrev tables, but lots of the abbrev code assumes that
>> it gets passed a single table.
>
>> Itʼs easy enough to check for 'consp' in such cases, but then which of
>> tables in that list should we add the abbrev to? The first one? All of
>> them?
>
>> Iʼm leaning towards "first, and document that you should put the most
>> specific table at the front of the list of local abbrev tables", but
>> Iʼd welcome opinions from others.
>
> I am not entirely sure, I understand the logic behind this. To give you
> a concrete example. (That enters now the flyspell problem).
>
> I have defined for each language I use flypsell/ispell a minor mode and
> a corresponding local-abbrev table.
>
>     1. American
>
>     2. British
>
>     3. German
>
>     4. Spanish
>
>     5. French
>
>     6. And even Hebrew (but we can leave that may out for the moment).
>
> Now say I am in latex mode and turn spelling for American on (which in
> turn turn the minor mode american-spelling on), is then the local abbrev
> table the first in that list?

Thatʼs under the control of your code, no? Itʼs whatever does 'setq
local-abbrev-table (list ... ...)'

Robert



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer

> Uwe Brauer <[hidden email]> writes:

> Thatʼs under the control of your code, no? Itʼs whatever does 'setq
> local-abbrev-table (list ... ...)'


That is what I expect. I have
(define-minor-mode american-minor-mode
    nil nil nil nil
    (setq local-abbrev-table
          (if american-minor-mode
              american-minor-mode-abbrev-table)))

Now if in LaTeX (mayor) mode (which has its own local-abbrev-table)
I turn on the american mode, in my understanding the local-abbrev-table
of american minor mode should be first in the list. At least if I add an
abbrev (via flyspell) it is added to the amercian-minor-mode-abbrev-table
not to the latex-mode-abbrev-table.

If that is the case I would say yes to your question, but I am not sure
how to check that it is indeed the first in the list. (I only know it is «activated»)

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Robert Pluim
Uwe Brauer <[hidden email]> writes:

>> Uwe Brauer <[hidden email]> writes:
>
>> Thatʼs under the control of your code, no? Itʼs whatever does 'setq
>> local-abbrev-table (list ... ...)'
>
>
> That is what I expect. I have
> (define-minor-mode american-minor-mode
>     nil nil nil nil
>     (setq local-abbrev-table
>           (if american-minor-mode
>               american-minor-mode-abbrev-table)))
>
> Now if in LaTeX (mayor) mode (which has its own local-abbrev-table)
> I turn on the american mode, in my understanding the local-abbrev-table
> of american minor mode should be first in the list. At least if I add an
> abbrev (via flyspell) it is added to the amercian-minor-mode-abbrev-table
> not to the latex-mode-abbrev-table.
>
> If that is the case I would say yes to your question, but I am not sure
> how to check that it is indeed the first in the list. (I only know it is «activated»)

Based on the code above, there is no list: youʼre unconditionally
setting local-abbrev-table to a single table. You'd want something
like:

(define-minor-mode american-minor-mode
    nil nil nil nil
    (setq local-abbrev-table
          (if american-minor-mode
              (list american-minor-mode-abbrev-table local-abbrev-table))))

which would then fail when adding abbrevs, of course.

Robert



Reply | Threaded
Open this post in threaded view
|

bug#45693: [two word expansion works, but write-abbrev-file destroys it]

Uwe Brauer

> Uwe Brauer <[hidden email]> writes:

> Based on the code above, there is no list: youʼre unconditionally
> setting local-abbrev-table to a single table. You'd want something
> like:

> (define-minor-mode american-minor-mode
>     nil nil nil nil
>     (setq local-abbrev-table
>           (if american-minor-mode
>               (list american-minor-mode-abbrev-table local-abbrev-table))))

Ok I did not think that through, you were referring to
(setq local-abbrev-table (list my-abbrev-table fundamental-mode-abbrev-table))

And the question is what comes first in that list, right?

You asked whether to take the first or all elements of the list, would
it be very resource consuming to take all?

smime.p7s (7K) Download Attachment
12