all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@gnu.org>
To: emacs-devel@gnu.org
Subject: Re: Fundamental mode vs. special mode
Date: Tue, 25 Oct 2011 11:51:40 +0800	[thread overview]
Message-ID: <87obx5zq2b.fsf@gnu.org> (raw)
In-Reply-To: <878vo9vlr5.fsf@gnu.org> (Chong Yidong's message of "Tue, 25 Oct 2011 10:38:22 +0800")

Chong Yidong <cyd@gnu.org> writes:

> I think this change is problematic.  IIUC, it introduces a nontrivial
> backward incompatibility: major modes defined with define-derived-mode
> now run fundamental-mode-hook, and thus behave differently from major
> modes that are defined directly according to previous Emacs guidelines
> for major modes (which was to simply call kill-all-local-variables).

I propose to remove the fundamental-mode-hook variable introduced in
that change, and introduce `run-mode-hooks-hook', which `run-mode-hooks'
runs before all the other hooks.  Then minor modes can use
`run-mode-hooks-hook', and the "turning off global modes" feature will
be available to non-derived modes.

=== modified file 'lisp/emacs-lisp/derived.el'
*** lisp/emacs-lisp/derived.el	2011-08-25 05:37:55 +0000
--- lisp/emacs-lisp/derived.el	2011-10-25 02:35:20 +0000
***************
*** 230,236 ****
  					; Run the parent.
  	 (delay-mode-hooks
  
! 	  (,(or parent 'fundamental-mode))
  					; Identify the child mode.
  	  (setq major-mode (quote ,child))
  	  (setq mode-name ,name)
--- 230,236 ----
  					; Run the parent.
  	 (delay-mode-hooks
  
! 	  (,(or parent 'kill-all-local-variables))
  					; Identify the child mode.
  	  (setq major-mode (quote ,child))
  	  (setq mode-name ,name)

=== modified file 'lisp/emacs-lisp/easy-mmode.el'
*** lisp/emacs-lisp/easy-mmode.el	2011-10-19 12:54:24 +0000
--- lisp/emacs-lisp/easy-mmode.el	2011-10-25 03:30:57 +0000
***************
*** 367,377 ****
  	     (progn
  	       (add-hook 'after-change-major-mode-hook
  			 ',MODE-enable-in-buffers)
! 	       (add-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
  	       (add-hook 'find-file-hook ',MODE-check-buffers)
  	       (add-hook 'change-major-mode-hook ',MODE-cmhh))
  	   (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers)
!            (remove-hook 'fundamental-mode-hook ',MODE-enable-in-buffers)
  	   (remove-hook 'find-file-hook ',MODE-check-buffers)
  	   (remove-hook 'change-major-mode-hook ',MODE-cmhh))
  
--- 367,377 ----
  	     (progn
  	       (add-hook 'after-change-major-mode-hook
  			 ',MODE-enable-in-buffers)
! 	       (add-hook 'run-mode-hooks-hook ',MODE-enable-in-buffers)
  	       (add-hook 'find-file-hook ',MODE-check-buffers)
  	       (add-hook 'change-major-mode-hook ',MODE-cmhh))
  	   (remove-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers)
!            (remove-hook 'run-mode-hooks-hook ',MODE-enable-in-buffers)
  	   (remove-hook 'find-file-hook ',MODE-check-buffers)
  	   (remove-hook 'change-major-mode-hook ',MODE-cmhh))
  

=== modified file 'lisp/simple.el'
*** lisp/simple.el	2011-10-19 12:54:24 +0000
--- lisp/simple.el	2011-10-25 02:35:48 +0000
***************
*** 349,355 ****
  Other major modes are defined by comparison with this one."
    (interactive)
    (kill-all-local-variables)
!   (run-mode-hooks 'fundamental-mode-hook))
  
  ;; Special major modes to view specially formatted data rather than files.
  
--- 349,356 ----
  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)))
  
  ;; Special major modes to view specially formatted data rather than files.
  

=== modified file 'lisp/subr.el'
*** lisp/subr.el	2011-10-06 19:15:19 +0000
--- lisp/subr.el	2011-10-25 03:30:33 +0000
***************
*** 1527,1532 ****
--- 1527,1535 ----
  (defvar after-change-major-mode-hook nil
    "Normal hook run at the very end of major mode functions.")
  
+ (defvar run-mode-hooks-hook nil
+   "Normal hook run before `run-mode-hooks' runs the mode hooks.")
+ 
  (defun run-mode-hooks (&rest hooks)
    "Run mode hooks `delayed-mode-hooks' and HOOKS, or delay HOOKS.
  Execution is delayed if the variable `delay-mode-hooks' is non-nil.
***************
*** 1540,1546 ****
      ;; Normal case, just run the hook as before plus any delayed hooks.
      (setq hooks (nconc (nreverse delayed-mode-hooks) hooks))
      (setq delayed-mode-hooks nil)
!     (apply 'run-hooks hooks)
      (run-hooks 'after-change-major-mode-hook)))
  
  (defmacro delay-mode-hooks (&rest body)
--- 1543,1549 ----
      ;; Normal case, just run the hook as before plus any delayed hooks.
      (setq hooks (nconc (nreverse delayed-mode-hooks) hooks))
      (setq delayed-mode-hooks nil)
!     (apply 'run-hooks (cons 'run-mode-hooks-hook hooks))
      (run-hooks 'after-change-major-mode-hook)))
  
  (defmacro delay-mode-hooks (&rest body)




  reply	other threads:[~2011-10-25  3:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-22 20:13 Fundamental mode vs. special mode Christoph Scholtes
2011-10-23  7:21 ` Chong Yidong
2011-10-23  9:19   ` martin rudalics
2011-10-23 13:28     ` Juri Linkov
2011-10-23 18:59       ` martin rudalics
2011-10-24  5:07         ` Juri Linkov
2011-10-24 16:39         ` Richard Stallman
2011-10-23 13:14   ` Johan Bockgård
2011-10-25  2:38     ` Chong Yidong
2011-10-25  3:51       ` Chong Yidong [this message]
2011-10-25 12:30         ` Stefan Monnier
2011-10-25 13:53           ` Juanma Barranquero
2011-10-25 15:11             ` Paul Eggert
2011-10-25 20:02               ` Stefan Monnier
2011-10-25 20:30                 ` Alan Mackenzie
2011-10-26  1:11                   ` Chong Yidong
2011-10-26 12:11                     ` Nix
2011-10-26 11:50                   ` Richard Stallman
2011-10-27  2:25                     ` Chong Yidong
2011-10-23 14:58   ` Christoph Scholtes
2011-10-24  5:11     ` Juri Linkov
2011-10-24 12:46       ` Stefan Monnier
2011-10-24 17:17       ` Alan Mackenzie
2011-10-25  4:30         ` Juri Linkov
2011-10-25 20:49           ` Alan Mackenzie
2011-10-26  1:18             ` Chong Yidong

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=87obx5zq2b.fsf@gnu.org \
    --to=cyd@gnu.org \
    --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 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.