unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fundamental mode.
@ 2005-06-15  8:59 Lute Kamstra
  2005-06-15  9:19 ` Juanma Barranquero
  2005-06-16  4:07 ` Richard Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Lute Kamstra @ 2005-06-15  8:59 UTC (permalink / raw)


Modes derived from fundamental mode run after-change-major-mode-hook
twice because fundamental mode runs it unconditionally.  Fundamental
mode should only run after-change-major-mode-hook if delay-mode-hooks
is nil.  We can either test this directly or use (run-mode-hooks
'fundamental-mode-hook).  The latter also introduces
fundamental-mode-hook, of course.  I see no problem with that, but I'm
a bit surprised it hasn't been done already.  (So I suspect there is
some reason for not running fundamental-mode-hook.)

What do others think is best?

Lute.

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

* Re: Fundamental mode.
  2005-06-15  8:59 Fundamental mode Lute Kamstra
@ 2005-06-15  9:19 ` Juanma Barranquero
  2005-06-16  4:07 ` Richard Stallman
  1 sibling, 0 replies; 6+ messages in thread
From: Juanma Barranquero @ 2005-06-15  9:19 UTC (permalink / raw)
  Cc: emacs-devel

> The latter also introduces
> fundamental-mode-hook, of course.  I see no problem with that, but I'm
> a bit surprised it hasn't been done already.  (So I suspect there is
> some reason for not running fundamental-mode-hook.)

Probably no one needed fundamental-mode-hook before. (run-mode-hooks
'fundamental-mode-hook) seems reasonable IMO.

-- 
                    /L/e/k/t/u

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

* Re: Fundamental mode.
  2005-06-15  8:59 Fundamental mode Lute Kamstra
  2005-06-15  9:19 ` Juanma Barranquero
@ 2005-06-16  4:07 ` Richard Stallman
  2005-06-16 12:41   ` Lute Kamstra
  2005-06-18 15:04   ` Johan Bockgård
  1 sibling, 2 replies; 6+ messages in thread
From: Richard Stallman @ 2005-06-16  4:07 UTC (permalink / raw)
  Cc: emacs-devel

    Modes derived from fundamental mode run after-change-major-mode-hook
    twice because fundamental mode runs it unconditionally.  Fundamental
    mode should only run after-change-major-mode-hook if delay-mode-hooks
    is nil.  We can either test this directly or use (run-mode-hooks
    'fundamental-mode-hook).  The latter also introduces
    fundamental-mode-hook, of course.  I see no problem with that, but I'm
    a bit surprised it hasn't been done already.

Fundamental mode does not run a mode hook because what it means is
"put settings in their default values".  But it needs to run
after-change-major-mode-hook, since the minor modes that should apply
to all buffers apply to these buffers too.

Could you do that explicitly?

Thanks.

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

* Re: Fundamental mode.
  2005-06-16  4:07 ` Richard Stallman
@ 2005-06-16 12:41   ` Lute Kamstra
  2005-06-18 15:04   ` Johan Bockgård
  1 sibling, 0 replies; 6+ messages in thread
From: Lute Kamstra @ 2005-06-16 12:41 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     Modes derived from fundamental mode run after-change-major-mode-hook
>     twice because fundamental mode runs it unconditionally.  Fundamental
>     mode should only run after-change-major-mode-hook if delay-mode-hooks
>     is nil.  We can either test this directly or use (run-mode-hooks
>     'fundamental-mode-hook).  The latter also introduces
>     fundamental-mode-hook, of course.  I see no problem with that, but I'm
>     a bit surprised it hasn't been done already.
>
> Fundamental mode does not run a mode hook because what it means is
> "put settings in their default values".  But it needs to run
> after-change-major-mode-hook, since the minor modes that should apply
> to all buffers apply to these buffers too.
>
> Could you do that explicitly?

I committed the patch below.

Lute.


Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.728
diff -c -r1.728 simple.el
*** lisp/simple.el	8 Jun 2005 15:35:05 -0000	1.728
--- lisp/simple.el	16 Jun 2005 12:37:30 -0000
***************
*** 327,333 ****
  Other major modes are defined by comparison with this one."
    (interactive)
    (kill-all-local-variables)
!   (run-hooks 'after-change-major-mode-hook))
  
  ;; Making and deleting lines.
  
--- 327,334 ----
  Other major modes are defined by comparison with this one."
    (interactive)
    (kill-all-local-variables)
!   (unless delay-mode-hooks
!     (run-hooks 'after-change-major-mode-hook)))
  
  ;; Making and deleting lines.

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

* Re: Fundamental mode.
  2005-06-16  4:07 ` Richard Stallman
  2005-06-16 12:41   ` Lute Kamstra
@ 2005-06-18 15:04   ` Johan Bockgård
  2005-06-19  0:49     ` Lute Kamstra
  1 sibling, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2005-06-18 15:04 UTC (permalink / raw)



I have some questions.

Richard Stallman <rms@gnu.org> writes:

> Lute Kamstra wrote:

>> Modes derived from fundamental mode run after-change-major-mode-hook
>> twice because fundamental mode runs it unconditionally.

I don't understand this. As define-derived-mode is currently defined modes
derived from fundamental-mode do not automatically call the fundamental-mode
function.

[define-derived-mode]

      (when (eq parent 'fundamental-mode) (setq parent nil))
      [...]
      (,(or parent 'kill-all-local-variables))

> Fundamental mode does not run a mode hook because what it means is "put
> settings in their default values". But it needs to run
> after-change-major-mode-hook, since the minor modes that should apply to
> all buffers apply to these buffers too.

Which are "these buffers" that this refers to? A buffer that defaults to
fundamental-mode (as created through C-x C-f on some unknown file type or
through C-x b) does not run the `fundamental-mode' lisp function. Currently
set-buffer-major-mode does not call the major-mode function when the default
mode is fundamental-mode.

[Fset_buffer_major_mode]

      if (NILP (function) || EQ (function, Qfundamental_mode))
        return Qnil;
      [...]
      call0 (function);

-- 
Johan Bockgård

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

* Re: Fundamental mode.
  2005-06-18 15:04   ` Johan Bockgård
@ 2005-06-19  0:49     ` Lute Kamstra
  0 siblings, 0 replies; 6+ messages in thread
From: Lute Kamstra @ 2005-06-19  0:49 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

>>> Modes derived from fundamental mode run after-change-major-mode-hook
>>> twice because fundamental mode runs it unconditionally.
>
> I don't understand this. As define-derived-mode is currently defined modes
> derived from fundamental-mode do not automatically call the fundamental-mode
> function.
>
> [define-derived-mode]
>
>       (when (eq parent 'fundamental-mode) (setq parent nil))
>       [...]
>       (,(or parent 'kill-all-local-variables))

True.  But it's possible to define a derived mode manually, without
using the define-derived-mode macro.

Lute.

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

end of thread, other threads:[~2005-06-19  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15  8:59 Fundamental mode Lute Kamstra
2005-06-15  9:19 ` Juanma Barranquero
2005-06-16  4:07 ` Richard Stallman
2005-06-16 12:41   ` Lute Kamstra
2005-06-18 15:04   ` Johan Bockgård
2005-06-19  0:49     ` Lute Kamstra

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