unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: Bugs caused by recent use of define-derived-mode
Date: Mon, 02 Sep 2002 12:29:34 -0400	[thread overview]
Message-ID: <200209021629.g82GTY707192@rum.cs.yale.edu> (raw)
In-Reply-To: 200209020237.VAA26080@eel.dms.auburn.edu

> There are two types of bugs related to define-derived-mode and its
> recent increased use, including uses for purposes it was not
> originally intended for.  The two types of bugs have similar symptoms,
> but different causes.  Both can easily be fixed, but the best way to
> fix the second one depends on some more general questions.  (Actually
> there are three kinds of bugs, but fixing the first automatically
> fixes the third.)
> 
> To investigate these types of bug, I believe one has to start by
> temporarily "hiding" one's .abbrev_defs from emacs, for instance by
> temporarily renaming it.  Then do emacs-21.3.50 -q.  (The bugs do not
> occur in 21.2.90 or earlier versions.)  They are caused by recent new
> uses of define-derived-mode in emacs21.3.50.
> 
> Do M-x list-abbrevs.
> 
> What is paragraph-indent-text-mode-abbrev-table doing in this list?

Could please state clearly what are the bugs ?
I.e. a set of commands that shows a behavior you didn't expect ?

> It is not there in 21.2.90.

So what ?

> How could the expansion of an abbrev
> possibly depend on the details of paragraph indentation?  This is an
> example of the first type of bugs.

The only problem with it is that if you change text-mod-abbrev-table, it
will not be immediately propagated to paragraph-indent-text-mode-abbrev-table
because we don't have inheritance of abbrev-tables, so define-derived-mode
only simulates it by copying the abbrev-table of the parent.

> Now a new abbrev-table has appeared, mail-mode-abbrev-table.  There is
> no such abbrev-table.  Mail-mode uses the text-mode-abbrev-table.  Yet

That's a bug in mail-mode, then.  See appended patch.

> There is no way for the user to find out that the senseless
> paragraph-indent-text-mode-abbrev-table is "real" and the
> mail-mode-abbrev-table (which actually would make at least slightly
> more sense, though not enough) is a "fake", other than to read the
> source code or to start experimenting.

There is no fake abbrev-table.  It's just a bug.

> The user also has no way of
> knowing that abbrevs defined in the regular text-mode-abbrev-table may
> or may not expand in paragraph-indent-text-mode, depending on whether
> some other buffer using paragraph-indent-text-mode was created in the
> meantime or not.  (This dependency is clearly in itself yet another,
> third bug.)

That is a more serious problem, as mentioned earlier:
abbrev-tables should be able to inherit from each other.

> The second type of bugs could potentially also create similar problems
> for syntax-tables, because, with respect to this kind of bug, the code
> for syntax-tables is broken in exactly the same way as the one for
> abbrevs.  (See a later message.)  The first and third bugs are
> abbrev-specific.

Not at all.  Syntax-tables provide real inheritance (just like keymaps)
and thus do not suffer from the same problems.  Of course, there might
still be problems, but then I'd welcome a real bug-report.

> nearly identical.  Mail mode is about as far removed from text mode as
> any truly derived mode is going to be and it, correctly, uses the
> same abbrev table as text mode.

I'm not sure it's correct.  There has already been people on gnu.emacs.help
asking why they can't define abbrevs that are specific to their mail buffers.

> Instead of trying to copy the parent mode's abbrev-table (and
> producing bugs in the process) define-derived-mode should simply make
> the derived mode use the parent's abbrev-table.  This is trivial to
> do, it actually simplifies the current code.

We could do that indeed.  I don't have a preference either way, as long
as it's easy for the code-author to choose whether to create a new
abbrev-table or to use the parent's (it's pretty easy right now (see patch)
but it is biased towards creating new abbrev-tables).


	Stefan


--- sendmail.el.~1.256.~	Tue May 21 19:43:31 2002
+++ sendmail.el	Mon Sep  2 12:22:47 2002
@@ -473,6 +473,7 @@
   :type 'hook
   :options '(footnote-mode))
 
+(defvar mail-mode-abbrev-table text-mode-abbrev-table)
 ;;;###autoload
 (define-derived-mode mail-mode text-mode "Mail"
   "Major mode for editing mail to be sent.
@@ -489,7 +490,6 @@
 \\[mail-sent-via]  mail-sent-via (add a Sent-via field for each To or CC).
 Turning on Mail mode runs the normal hooks `text-mode-hook' and
 `mail-mode-hook' (in that order)."
-  (setq local-abbrev-table text-mode-abbrev-table)
   (make-local-variable 'mail-reply-action)
   (make-local-variable 'mail-send-actions)
   (setq buffer-offer-save t)

  reply	other threads:[~2002-09-02 16:29 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-02  2:37 Bugs caused by recent use of define-derived-mode Luc Teirlinck
2002-09-02 16:29 ` Stefan Monnier [this message]
2002-09-02 23:02   ` Luc Teirlinck
2002-09-02 23:20     ` Stefan Monnier
2002-09-02 23:25       ` Luc Teirlinck
2002-09-02 23:29         ` Stefan Monnier
2002-09-02 23:46           ` Luc Teirlinck
2002-09-03  0:26             ` Stefan Monnier
2002-09-03  1:21       ` Luc Teirlinck
2002-09-03  2:08         ` Stefan Monnier
2002-09-03  2:04       ` Luc Teirlinck
2002-09-03  2:07         ` Stefan Monnier
2002-09-03 14:05     ` Kai Großjohann
2002-09-03 15:06       ` Stefan Monnier
2002-09-03 15:36         ` Luc Teirlinck
2002-09-03 21:23           ` Luc Teirlinck
2002-09-04  0:01             ` Luc Teirlinck
2002-09-04  3:28               ` Luc Teirlinck
2002-09-04  3:49                 ` Miles Bader
2002-09-04 12:31                   ` Luc Teirlinck
2002-09-05  2:46               ` Richard Stallman
2002-09-05  4:37                 ` Luc Teirlinck
2002-09-08 12:54                   ` Richard Stallman
2002-09-09  0:14                     ` Luc Teirlinck
2002-09-09  1:36                       ` Luc Teirlinck
2002-09-09 23:33                         ` Richard Stallman
2002-09-10  0:12                           ` Luc Teirlinck
2002-09-09  2:35                       ` Luc Teirlinck
2002-09-09 13:49                       ` Miles Bader
2002-09-09 15:25                         ` Kim F. Storm
2002-09-09 18:42                         ` Luc Teirlinck
2002-09-10 16:36                           ` Richard Stallman
2002-09-11  4:30                             ` Luc Teirlinck
2002-09-11 20:03                               ` Richard Stallman
2002-09-09 19:15                       ` Richard Stallman
2002-09-05 11:07                 ` Kai Großjohann
2002-09-06  1:26                   ` Miles Bader
2002-09-06  2:11                     ` Luc Teirlinck
2002-09-06  2:26                       ` Miles Bader
2002-09-06  2:31                         ` Luc Teirlinck
2002-09-06  2:31                       ` Miles Bader
2002-09-06 10:52                       ` Kai Großjohann
2002-09-07  3:16                         ` Richard Stallman
2002-09-06 20:03                     ` Richard Stallman
2002-09-06 15:11                   ` Richard Stallman
2002-09-04 14:13   ` Richard Stallman
2002-09-04 16:01     ` Stefan Monnier
2002-09-03 13:26 ` Richard Stallman
2002-09-03 14:57   ` Stefan Monnier
2002-09-05  2:46     ` Richard Stallman
2002-09-06 16:07       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200209021629.g82GTY707192@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).