unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: monnier+gnu/emacs@rum.cs.yale.edu, emacs-devel@gnu.org
Subject: Re: Recent attempts at standardizing major mode definitions.
Date: Wed, 4 Sep 2002 17:36:53 -0500 (CDT)	[thread overview]
Message-ID: <200209042236.RAA00683@eel.dms.auburn.edu> (raw)
In-Reply-To: <200209041540.g84FeAf19413@rum.cs.yale.edu> (monnier+gnu/emacs@rum.cs.yale.edu)

Stefan Monnier wrote:

   although it (of course) needs to be flexible enough to allow those
   defaults to be overridden (which the current `define-derived-mode'
   does allow although not always in the most natural/convenient way).

Yes, but the question is, do we allow them to override by choosing a
more general function or do we force them to use "tricks".  The former
is not only much more convenient for the author, it also avoids the
extremely real possibility of those "tricks" introducing bugs and
unintended side effects.  Overriding with a separate function seems
much more natural.  We get two functions: 

1. define-derived-mode, to be used if either the author is not sure
which values to plug in for the arguments of define-major-mode or if
the new mode is a "true" derived mode.

2. A more general function define-major-mode, if the author needs more
flexibility.



   Many authors forget to setup an abbrev-table.

define-major-mode will have an abbrev-table argument.  End of problem.
The author can explicitly choose not to have an abbrev-table, but
(s)he can not do it without thinking.

   Many authors forget to run hooks.

define-major-mode will run the standard mode-hook as the very last
thing it does.

   Other authors forget to run kill-all-local-variables.

define-major-mode will call that function just as define-derived-mode
does.

   Others don't use a `foo-mode-map' variable.

Either this will be set automatically or the author will have to
explicitly ask for this not to be done.

   Yet others don't use a `foo-mode-syntax-table' variable.

Will only work if the author explicitly asks not to use it.

   Some authors don't notice that their mode should derive from text-mode.
   Others do notice but derive the mode in incorrect ways (or at
   least in inconsistent ways).
   Most authors don't seem to realize that just like there is a text-mode
   from which most text-like editing modes derive, there should be a prog-mode
   from which most programming modes derive.

define-derived-mode does not solve that problem.  The author still
has to choose the parent mode and that choice could be stupid.

define-major-mode will have more arguments than define-derived-mode
does and forces the author to worry about all kinds of stuff.  If
(s)he does not need flexibility, (s)he will choose
define-derived-mode.  We could, and maybe should, have the two
documentation strings refer to each other, thus making sure that the
author knows that (s)he has a less complex (more flexible,
respectively) function available.

   Take a look at the expansion of define-derived-mode when the
   PARENT is nil.

I did.  As I pointed out, the piece of code I sent was essentially an
adaptation of that expansion.  It was just a rough draft, however.  It
needs to be changed to take care of Richard's remarks and problems I
myself discovered in the meantime.  Of course, it could also be
changed to take care of any objections you have.  Remember though that
define-major-mode is intended for knowledgeable authors and should
work for a-typical modes.

Sincerely,

Luc.

  reply	other threads:[~2002-09-04 22:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-02  2:40 Recent attempts at standardizing major mode definitions Luc Teirlinck
2002-09-02 16:51 ` Stefan Monnier
2002-09-02 17:49   ` Kai Großjohann
2002-09-02 20:39   ` Luc Teirlinck
2002-09-02 23:14     ` Stefan Monnier
2002-09-04  0:59       ` Luc Teirlinck
2002-09-04 15:27         ` Stefan Monnier
2002-09-04  1:24   ` Luc Teirlinck
2002-09-04 15:25     ` Stefan Monnier
2002-09-05  2:46     ` Richard Stallman
2002-09-04  1:35   ` Luc Teirlinck
2002-09-04 15:24     ` Stefan Monnier
2002-09-04 21:52       ` Luc Teirlinck
2002-09-05 15:54         ` Stefan Monnier
2002-09-05 16:52           ` Luc Teirlinck
2002-09-05 17:15             ` Luc Teirlinck
2002-09-04  2:06   ` Luc Teirlinck
2002-09-04 15:40     ` Stefan Monnier
2002-09-04 22:36       ` Luc Teirlinck [this message]
2002-09-06 18:03         ` Stefan Monnier
2002-09-06 18:48           ` David Masterson
2002-09-06 22:53           ` Luc Teirlinck
2002-09-07  0:05             ` Luc Teirlinck
2002-09-07  2:47             ` Luc Teirlinck
2002-09-07  3:06               ` Luc Teirlinck
2002-09-03 13:26 ` Richard Stallman
2002-09-03 13:56   ` Mario Lang
2002-09-05  2:45     ` Richard Stallman

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=200209042236.RAA00683@eel.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier+gnu/emacs@rum.cs.yale.edu \
    /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).