all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Troubles with abbrev-mode
@ 2006-09-26 18:56 Tassilo Horn
  2006-09-26 20:14 ` Reiner Steib
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2006-09-26 18:56 UTC (permalink / raw)


Hi all,

I want to start using abbrev-mode but I don't get it right. I use emacs
from the current CVS head, which I updated today.

Those are my abbrevs (`list-abbrevs'):

--8<---------------cut here---------------start------------->8---
(message-mode-abbrev-table)

"lg"           0    "Liebe Grüße"
"mw"           0    "meines Wissens"
"vg"           0    "Viele Grüße,"


(text-mode-abbrev-table)

"vg"           3    "Viele Grüße,"


(lisp-mode-abbrev-table)

"da"           0    "defalias"
"dl"           0    "dolist ("
"dm"           0    "defmacro"
"ia"           0    "interactive"
"se"           0    "save-excursion"
"swe"          0    "save-window-excursion"
--8<---------------cut here---------------end--------------->8---

And those are my problems:

a) The abbrevs for `message-mode' I defined with `edit-abbrevs'. Then I
   started writing a message (in `message-mode') and wondered why my
   abbrevs don't expand. I inserted a new abbrev with
   `add-mode-abbrev'. But that abbrev was added to
   `text-mode-abbrev-table' instead of message-mode's one. And in
   `message-mode' only abbrev defined in `text-mode-abbrev-table'
   expand. Why? Is it a bug?

b) All the abbrevs below `lisp-mode-abbrev-table' were defined when I
   was in `emacs-lisp-mode'. But they also expand in SLIME's common lisp
   mode, where `save-excursion' and `interactive' are totally
   useless. Isn't it possible to save abbrevs strictly mode-specific?

Best regards,
Tassilo
-- 
A child of five could understand this! Fetch me a child of five!

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

* Re: Troubles with abbrev-mode
  2006-09-26 18:56 Troubles with abbrev-mode Tassilo Horn
@ 2006-09-26 20:14 ` Reiner Steib
  2006-09-26 21:33   ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Reiner Steib @ 2006-09-26 20:14 UTC (permalink / raw)


On Tue, Sep 26 2006, Tassilo Horn wrote:

> a) The abbrevs for `message-mode' I defined with `edit-abbrevs'. Then I
>    started writing a message (in `message-mode') and wondered why my
>    abbrevs don't expand. I inserted a new abbrev with
>    `add-mode-abbrev'. But that abbrev was added to
>    `text-mode-abbrev-table' instead of message-mode's one. And in
>    `message-mode' only abbrev defined in `text-mode-abbrev-table'
>    expand. Why? Is it a bug?

FWIW, `message.el' sets `local-abbrev-table' to
`text-mode-abbrev-table':

(define-derived-mode message-mode text-mode "Message"
  "Major mode for editing mail and news to be sent.
Like Text Mode but with these additional commands:\\<message-mode-map>
[...]
M-RET    `message-newline-and-reformat' (break the line and reformat)."
  (setq local-abbrev-table text-mode-abbrev-table)
[...]

I don't know if this is good or not, but it has been there since ages:

| 6.202 (zsh 07-Feb-02): (setq local-abbrev-table text-mode-abbrev-table)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: Troubles with abbrev-mode
  2006-09-26 20:14 ` Reiner Steib
@ 2006-09-26 21:33   ` Tassilo Horn
  2006-09-27  7:56     ` Reiner Steib
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2006-09-26 21:33 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> writes:

> FWIW, `message.el' sets `local-abbrev-table' to
> `text-mode-abbrev-table':
>
> [...]
>
> I don't know if this is good or not, but it has been there since ages:
>
> | 6.202 (zsh 07-Feb-02): (setq local-abbrev-table text-mode-abbrev-table)

Hm, in my opinion that's a really bad behavior, because...

  a) if the user wants that behavior, he can set in `message-mode-hook'.

  b) adding abbrevs in message mode (with `add-mode-abbrev' or
     `inverse-add-mode-abbrev') adds it to
     `message-mode-abbrev-table'. So you effectively cannot add abbrevs
     interactively.

So I see two possible fixes:

  1) Delete the setq. (To me that seems right and proper.)
  
  2) Fix `add-mode-abbrev' and `inverse-add-mode-abbrev', so that they
     insert into `local-abbrev-table'.

To me the second point should be done, too, because that's what a user
would expect. Only then he has the possibility to use a abbrev-table for
multiple modes, e.g. text-mode-abbrev-table for
message-mode-abbrev-table. 

What do you mean?

Bye,
Tassilo
-- 
A morning without coffee is like something without something else.

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

* Re: Troubles with abbrev-mode
  2006-09-26 21:33   ` Tassilo Horn
@ 2006-09-27  7:56     ` Reiner Steib
  2006-09-27  9:36       ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Reiner Steib @ 2006-09-27  7:56 UTC (permalink / raw)


On Tue, Sep 26 2006, Tassilo Horn wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>> | 6.202 (zsh 07-Feb-02): (setq local-abbrev-table text-mode-abbrev-table)
>
> Hm, in my opinion that's a really bad behavior, because...
>
>   a) if the user wants that behavior, he can set in `message-mode-hook'.

And if he doesn't want the current behavior, he can probably also do
it in `message-mode-hook' now? [1]

>   b) adding abbrevs in message mode (with `add-mode-abbrev' or
>      `inverse-add-mode-abbrev') adds it to
>      `message-mode-abbrev-table'. So you effectively cannot add abbrevs
>      interactively.
>
> So I see two possible fixes:
>
>   1) Delete the setq. (To me that seems right and proper.)

This will break existing configurations, wouldn't it?  `message-mode'
derived from `text-mode': Do we have guidelines / conventions / best
practice in Emacs on how to deal with abbrevs in derived modes?

>   2) Fix `add-mode-abbrev' and `inverse-add-mode-abbrev', so that they
>      insert into `local-abbrev-table'.
>
> To me the second point should be done, too, because that's what a user
> would expect. Only then he has the possibility to use a abbrev-table for
> multiple modes, e.g. text-mode-abbrev-table for
> message-mode-abbrev-table. 
>
> What do you mean?

I don't have a strong opinion here (as I don't know what the docs
suggest here).

[1] BTW, in my init files I find...
(add-hook
 'gnus-message-setup-hook
 '(lambda ()
    (when (boundp 'rs-message-mode-abbrev-table)
      (setq local-abbrev-table rs-message-mode-abbrev-table))
    [...]

... but I don't exactly recall it's purpose.  At least, I have some
abbrevs in message-mode that are not present in text-mode.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: Troubles with abbrev-mode
  2006-09-27  7:56     ` Reiner Steib
@ 2006-09-27  9:36       ` Tassilo Horn
  2006-09-29 20:52         ` Reiner Steib
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2006-09-27  9:36 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> writes:

Hi Reiner,

>> Hm, in my opinion that's a really bad behavior, because...
>>
>>   a) if the user wants that behavior, he can set in `message-mode-hook'.
>
> And if he doesn't want the current behavior, he can probably also do
> it in `message-mode-hook' now? [1]

Yes, he can. But I think the current behavior patronizes the user too
much. It's not logical to use a abbrev-table from a different mode, even
if the current mode is derived from it, when newly added abbrevs go into
the current mode's abbrev-table, thus have no effect at all.

If you know what's going on, you can handle it, but for a normal user
without any knowledge about how abbrev-mode works it's simply wrong
accoring to the docs.

,----[ (info "(emacs)Defining Abbrevs") ]
| `C-x a g'
|      Define an abbrev, using one or more words before point as its
|      expansion (`add-global-abbrev').
| 
| `C-x a l'
|      Similar, but define an abbrev specific to the current major mode
|      (`add-mode-abbrev').          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| 
| `C-x a i g'
|      Define a word in the buffer as an abbrev
|      (`inverse-add-global-abbrev').
| 
| `C-x a i l'
|      Define a word in the buffer as a mode-specific abbrev
|      (`inverse-add-mode-abbrev').     ^^^^^^^^^^^^^^^^^^^^
`----

>>   b) adding abbrevs in message mode (with `add-mode-abbrev' or
>>      `inverse-add-mode-abbrev') adds it to
>>      `message-mode-abbrev-table'. So you effectively cannot add abbrevs
>>      interactively.
>>
>> So I see two possible fixes:
>>
>>   1) Delete the setq. (To me that seems right and proper.)
>
> This will break existing configurations, wouldn't it?

Yep, but it would be easy to fix. The user could copy his abbrevs to
`message-mode-abbrev-table' or setq `local-abbrev-table' back to
`text-mode-abbrev-table' in `message-mode-hook' (or
`gnus-message-setup-hook'). Ok, the second solution still suffers from
this adding-abbrevs-problem...

> `message-mode' derived from `text-mode': Do we have guidelines /
> conventions / best practice in Emacs on how to deal with abbrevs in
> derived modes?

As I'm not really involved in emacs development I don't know. Should I
start a new thread about point 2 in gmane.emacs.devel?

>>   2) Fix `add-mode-abbrev' and `inverse-add-mode-abbrev', so that they
>>      insert into `local-abbrev-table'.
>>
>> To me the second point should be done, too, because that's what a
>> user would expect. Only then he has the possibility to use a
>> abbrev-table for multiple modes, e.g. text-mode-abbrev-table for
>> message-mode-abbrev-table.
>>
>> What do you mean?
>
> I don't have a strong opinion here (as I don't know what the docs
> suggest here).

At least you have to admit that it's inconvenient for the user if he
adds abbrevs interactively, but they don't work.

> [1] BTW, in my init files I find...
> (add-hook
>  'gnus-message-setup-hook
>  '(lambda ()
>     (when (boundp 'rs-message-mode-abbrev-table)
>       (setq local-abbrev-table rs-message-mode-abbrev-table))
>     [...]
>
> ... but I don't exactly recall it's purpose. At least, I have some
> abbrevs in message-mode that are not present in text-mode.

But you alway added them with `edit-abbrevs', not interactively with
`add-mode-abbrev' or `inverse-add-mode-abbrev', right?

Bye,
Tassilo
-- 
A morning without coffee is like something without something else.

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

* Re: Troubles with abbrev-mode
  2006-09-27  9:36       ` Tassilo Horn
@ 2006-09-29 20:52         ` Reiner Steib
  2006-09-29 22:17           ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Reiner Steib @ 2006-09-29 20:52 UTC (permalink / raw)


On Wed, Sep 27 2006, Tassilo Horn wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
[...]
> If you know what's going on, you can handle it, but for a normal user
> without any knowledge about how abbrev-mode works it's simply wrong
> accoring to the docs.
>
> ,----[ (info "(emacs)Defining Abbrevs") ]

[...]
>> `message-mode' derived from `text-mode': Do we have guidelines /
>> conventions / best practice in Emacs on how to deal with abbrevs in
>> derived modes?
>
> As I'm not really involved in emacs development I don't know. Should I
> start a new thread about point 2 in gmane.emacs.devel?

Maybe a good idea.

[...]
>> I don't have a strong opinion here (as I don't know what the docs
>> suggest here).
>
> At least you have to admit that it's inconvenient for the user if he
> adds abbrevs interactively, but they don't work.

Sure.

[...]
>>       (setq local-abbrev-table rs-message-mode-abbrev-table))
>>     [...]
>> ... but I don't exactly recall it's purpose. At least, I have some
>> abbrevs in message-mode that are not present in text-mode.
>
> But you alway added them with `edit-abbrevs', not interactively with
> `add-mode-abbrev' or `inverse-add-mode-abbrev', right?

Probably I've edited ~/.abbrev_defs manually (I don't change my
abbrevs often: the time stamp says 2005-11-30).

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: Troubles with abbrev-mode
  2006-09-29 20:52         ` Reiner Steib
@ 2006-09-29 22:17           ` Tassilo Horn
  2006-09-30  8:02             ` Reiner Steib
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2006-09-29 22:17 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> writes:

>>> `message-mode' derived from `text-mode': Do we have guidelines /
>>> conventions / best practice in Emacs on how to deal with abbrevs in
>>> derived modes?
>>
>> As I'm not really involved in emacs development I don't know. Should
>> I start a new thread about point 2 in gmane.emacs.devel?
>
> Maybe a good idea.

Gnmpf, I cannot reproduce the problem anymore. I don't even know if the
problem existed sometime at all or if I was confused, which is more
likely.

,----[ ~/uni/repos/heimdall-uni/programs/elisp/th-abbrev.el ]
| [...]
| (define-abbrev-table 'th-emacs-lisp-mode-abbrev-table
|   '(("da" "(defalias °)" (lambda ()
|                            (th-abbrev-set-point)))
|     [...] ))))
| 
| (add-hook 'emacs-lisp-mode-hook
|           (lambda ()
|             (setq local-abbrev-table th-emacs-lisp-mode-abbrev-table)
|             (th-abbrev-mode-initialize)))
| 
| (define-abbrev-table 'th-message-mode-abbrev-table
|   '([...]
|     ("vg" "Viele Grüße,\n°" (lambda ()
|                               (th-abbrev-set-point)))))
| 
| (add-hook 'message-mode-hook
|           (lambda ()
|             (setq local-abbrev-table th-message-mode-abbrev-table)
|             (th-abbrev-mode-initialize)))
`----

Whenever I add an abbrev interactively it goes into the local
abbrev-table (one of the th-<mode>-abbrev-tables), which is correct.

So the only question is why gnus uses text-mode-abbrev-table (where
interactively added abbrevs go, too) when there's a
message-mode-abbrev-table in `edit-abbrevs' by default.

Regards,
Tassilo
-- 
A morning without coffee is like something without something else.

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

* Re: Troubles with abbrev-mode
  2006-09-29 22:17           ` Tassilo Horn
@ 2006-09-30  8:02             ` Reiner Steib
  0 siblings, 0 replies; 8+ messages in thread
From: Reiner Steib @ 2006-09-30  8:02 UTC (permalink / raw)


On Sat, Sep 30 2006, Tassilo Horn wrote:

> So the only question is why gnus uses text-mode-abbrev-table (where
> interactively added abbrevs go, too) when there's a
> message-mode-abbrev-table in `edit-abbrevs' by default.

`define-derived-mode' does this by default:

,----[ (info "(elisp)Derived Modes") | Emacs 22 ]
|         * The new mode has its own abbrev table, kept in the variable
|           `VARIANT-abbrev-table', unless you override this using the
|           `:abbrev-table' keyword (see below).
|
| [...]
|
|     `:abbrev-table'
|           You can use this to explicitly specify an abbrev table for
|           the new mode.  If you specify a `nil' value, the new mode
|           uses the same abbrev table as PARENT, or
|           `fundamental-mode-abbrev-table' if PARENT is `nil'.  (Again,
|           a `nil' value is _not_ equivalent to not specifying this
|           keyword.)
`----

Maybe `message-mode' could use ":abbrev-table nil" instead of "(setq
local-abbrev-table text-mode-abbrev-table)".  (Probably we need it for
compatibility with Emacs 21 and/or XEmacs.)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

end of thread, other threads:[~2006-09-30  8:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 18:56 Troubles with abbrev-mode Tassilo Horn
2006-09-26 20:14 ` Reiner Steib
2006-09-26 21:33   ` Tassilo Horn
2006-09-27  7:56     ` Reiner Steib
2006-09-27  9:36       ` Tassilo Horn
2006-09-29 20:52         ` Reiner Steib
2006-09-29 22:17           ` Tassilo Horn
2006-09-30  8:02             ` Reiner Steib

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.