all messages for Emacs-related lists mirrored at yhetil.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: Fri, 6 Sep 2002 17:53:22 -0500 (CDT)	[thread overview]
Message-ID: <200209062253.RAA04993@eel.dms.auburn.edu> (raw)
In-Reply-To: <200209061803.g86I3N900442@rum.cs.yale.edu> (monnier+gnu/emacs@rum.cs.yale.edu)

Stefan Monnier wrote:

   Are you saying that if we have

	   (defalias 'define-major-mode 'define-derived-mode)

   we can't make define-major-mode more flexible ?
   I definitely think define-derived-mode should be more flexible
   and intend to do exactly that, using keyword arguments.

I actually do believe that it can be made flexible enough, but from
previous messages it seemed to me you were not willing to go far
enough in that direction.  I describe below what would make it
acceptable as a standard to me.  Only Richard can answer the much more
important question of whether that would make it acceptable to him.
Richard has clearly stated that define-derived-mode in its present
form is unacceptable to him as a standard way to define a major mode.

To me, the important thing is the following:

As long as authors adhere to all standards described in the Elisp
manual, they should be able to easily override any default behavior
you specify, using arguments.  Most of these arguments should probably
be CL style keywords arguments.  Authors should mot be forced to write
extra code to override defaults.

The reasons for that are plenty.  We should not inconvenience major
mode writers who adhere to all standards.  Any extra code is extra
risk for bugs or "nuisance features".  The extra code makes the source
code more difficult to understand and debug.

In other words I do not want the macro-expanded code to look like:

;;author code
(prevent-action2)
(prevent-part1-of-action3)
;;macro-written code
(defun my-mode ()
   ...
   (action1)
   (action2)
   (action3)
;;author code
   (undo-action1)
   (undo-part2-of-action3)
   (alternative-action1)
    ......

Instead I would like it to look like this (all macro-written code):

(defun my-mode ()
  ...
  (if argument1 (action1 argument1) (default-action1))
   .......

or similar.

Of course the arguments could be CL style keyword arguments.

As long as there are situations where the default should be
overwritten, we should not decide that these situation are too
infrequent to worry about.  As long as there is at least one such
situation, there will be others, whether we are able to think about
them or not.

To give you an idea of the flexibility needed, I quote part of the
reaction Richard had to my proposed code.  (The relevant part of my
proposed code was literally taken over from define-derived-mode's
expansion.)

	  (defun mymode nil "docstring\n\nThis mode runs the hook
	  `mymode-hook', as the final step\nduring
	  initialization.\n\n\\{mymode-map}"

    We don't always want to use \\{...} in every major mode doc string.

One could put in a CL style keyword argument that would enable an
author to override this.

    Can you give me examples of atypical modes ?

I do not know which modes Richard is talking about and why \\{...}
would be inappropriate for them, but I would guess such modes would
qualify as a-typical, because for typical modes \\{...} would be
appropriate.

Further suggestions (these are details):

Maybe the docstring should automatically list the abbrev-table and
syntax-table used by the mode.  I believe that would be very useful.

I like Mario Lang's suggestion:

add:

(put mode 'major-mode t)

to the macro expansion.

Richard seemed to like it too, although, as Richard pointed out, as
long as the standard is not universally followed, it will not work
perfectly.

Sincerely,

Luc.

  parent reply	other threads:[~2002-09-06 22:53 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
2002-09-06 18:03         ` Stefan Monnier
2002-09-06 18:48           ` David Masterson
2002-09-06 22:53           ` Luc Teirlinck [this message]
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

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

  git send-email \
    --in-reply-to=200209062253.RAA04993@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 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.