unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mmaug@yahoo.com
@ 2005-05-28 19:24 Luc Teirlinck
  2005-05-29 12:04 ` mmaug@yahoo.com Richard Stallman
  2005-05-29 13:40 ` mmaug@yahoo.com Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Luc Teirlinck @ 2005-05-28 19:24 UTC (permalink / raw)


There appear to be several derived modes that do not yet properly
enclose the call to the parent mode in a delay-mode-hooks form.
Examples include sql-interactive-mode, inferior-emacs-lisp-mode and
inferior-lisp-mode.

Currently, we recommend to put the call to delay-mode-hooks around the
entire body, excluding the final call to run-mode-hooks.  That is what
define-derived-mode does.  It is strictly speaking the safest, just in
case anything else (except for the parent mode) should run a mode hook.
But that should really not happen.  So it should be sufficient to
enclose the call to the parent mode inside a delay-mode-hooks form,
which results in less deeply nested code.

I will take care of inferior-emacs-lisp-mode, inferior-lisp-mode and
any other modes I find (although I will leave sql-interactive-mode to
Michael), once I know how we want to handle them.  We could make them
all use define-derived-mode, but that has to be done carefully and has
the potential of introducing bugs.  Enclosing stuff in a
delay-mode-hooks form is routine, especially if it is only the parent
mode that needs to be enclosed.  This is important, as there may be
_many_ such modes.

So what do we do: insist on converting to define-derived-mode, using
delay-mode-hooks around the entire body except final call to
run-mode-hooks, or use delay-mode-hooks only around the call to the
parent mode?

If we decide on the latter, we could also make the following change to
modes.texi:

===File ~/modes.texi-diff===================================
*** modes.texi	23 May 2005 10:25:40 -0500	1.109
--- modes.texi	28 May 2005 14:06:53 -0500	
***************
*** 437,446 ****
  command (called the @dfn{parent mode}) and then alter some of its
  settings.  A mode that does this is called a @dfn{derived mode}.  The
  recommended way to define one is to use @code{define-derived-mode},
! but this is not required.  Such a mode should use
! @code{delay-mode-hooks} around its entire body (including the call to
! the parent mode command) @emph{except} for the final call to
! @code{run-mode-hooks}, which runs the derived mode's hook.  (Using
  @code{define-derived-mode} does this automatically.)  @xref{Derived
  Modes}, and @ref{Mode Hooks}.
  
--- 437,444 ----
  command (called the @dfn{parent mode}) and then alter some of its
  settings.  A mode that does this is called a @dfn{derived mode}.  The
  recommended way to define one is to use @code{define-derived-mode},
! but this is not required.  Such a mode should call the parent mode
! command inside a @code{delay-mode-hooks} form.  (Using
  @code{define-derived-mode} does this automatically.)  @xref{Derived
  Modes}, and @ref{Mode Hooks}.
  
============================================================

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

* Re: mmaug@yahoo.com
  2005-05-28 19:24 mmaug@yahoo.com Luc Teirlinck
@ 2005-05-29 12:04 ` Richard Stallman
  2005-05-29 13:40 ` mmaug@yahoo.com Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2005-05-29 12:04 UTC (permalink / raw)
  Cc: emacs-devel

    So it should be sufficient to
    enclose the call to the parent mode inside a delay-mode-hooks form,
    which results in less deeply nested code.

Yes, that is fine.

      command (called the @dfn{parent mode}) and then alter some of its
      settings.  A mode that does this is called a @dfn{derived mode}.  The
      recommended way to define one is to use @code{define-derived-mode},
    ! but this is not required.  Such a mode should call the parent mode
    ! command inside a @code{delay-mode-hooks} form.  (Using
      @code{define-derived-mode} does this automatically.)  @xref{Derived
      Modes}, and @ref{Mode Hooks}.

That change is ok too.

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

* Re: mmaug@yahoo.com
  2005-05-28 19:24 mmaug@yahoo.com Luc Teirlinck
  2005-05-29 12:04 ` mmaug@yahoo.com Richard Stallman
@ 2005-05-29 13:40 ` Stefan Monnier
  2005-05-29 16:57   ` mmaug@yahoo.com Luc Teirlinck
  2005-05-29 17:21   ` Wrong subject (Re: mmaug@yahoo.com) Luc Teirlinck
  1 sibling, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-05-29 13:40 UTC (permalink / raw)
  Cc: emacs-devel

> Michael), once I know how we want to handle them.  We could make them
> all use define-derived-mode, but that has to be done carefully and has
> the potential of introducing bugs.  Enclosing stuff in a

If at all possible, please use define-derived-mode which results in
cleaner code and neatly hides those details.


        Stefan

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

* Re: mmaug@yahoo.com
  2005-05-29 13:40 ` mmaug@yahoo.com Stefan Monnier
@ 2005-05-29 16:57   ` Luc Teirlinck
  2005-05-30 21:08     ` mmaug@yahoo.com Stefan Monnier
  2005-05-29 17:21   ` Wrong subject (Re: mmaug@yahoo.com) Luc Teirlinck
  1 sibling, 1 reply; 6+ messages in thread
From: Luc Teirlinck @ 2005-05-29 16:57 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:

   If at all possible, please use define-derived-mode which results in
   cleaner code and neatly hides those details.

The problem is that rewriting a mode to use define-derived-mode has to
be done carefully and takes time.  Otherwise, there is the risk of
introducing bugs.  On the other hand, enclosing the parent mode inside a
delay-mode-hooks is so completely routine and quick that it can be
done right after one notices the problem.  This is important, since
there may be a lot of these problems out there.  Rewriting the mode to
use define-derived-mode can always be done later when one has more
time and has no other, more urgent, things to do.

Sincerely,

Luc.

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

* Wrong subject (Re: mmaug@yahoo.com).
  2005-05-29 13:40 ` mmaug@yahoo.com Stefan Monnier
  2005-05-29 16:57   ` mmaug@yahoo.com Luc Teirlinck
@ 2005-05-29 17:21   ` Luc Teirlinck
  1 sibling, 0 replies; 6+ messages in thread
From: Luc Teirlinck @ 2005-05-29 17:21 UTC (permalink / raw)
  Cc: mmaug, emacs-devel

Sorry, I did not really mean to have this "Subject" field for this
thread.  That address was supposed to be a CC.  I must have messed
things up one way or the other.  I only noticed now.

Sincerely,

Luc.

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

* Re: mmaug@yahoo.com
  2005-05-29 16:57   ` mmaug@yahoo.com Luc Teirlinck
@ 2005-05-30 21:08     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-05-30 21:08 UTC (permalink / raw)
  Cc: emacs-devel

> Rewriting the mode to use define-derived-mode can always be done later
> when one has more time and has no other, more urgent, things to do.

When was the last time this happened to you?


        Stefan

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

end of thread, other threads:[~2005-05-30 21:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-28 19:24 mmaug@yahoo.com Luc Teirlinck
2005-05-29 12:04 ` mmaug@yahoo.com Richard Stallman
2005-05-29 13:40 ` mmaug@yahoo.com Stefan Monnier
2005-05-29 16:57   ` mmaug@yahoo.com Luc Teirlinck
2005-05-30 21:08     ` mmaug@yahoo.com Stefan Monnier
2005-05-29 17:21   ` Wrong subject (Re: mmaug@yahoo.com) Luc Teirlinck

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).