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

From: Uwe Brauer <[email-masked]>
Date: Mon, 11 Jan 2021 21:17:06 +0100

>>> "RP" == Robert Pluim <[email-masked]> writes:

> Uwe Brauer <[email-masked]> 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)