From c1ebb47e3da1840bb438372f67335df1d30c4ffd Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 24 Oct 2011 13:37:03 -0400 Subject: * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Doc fix. (Bug#9819) --- lisp/emacs-lisp/easy-mmode.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/easy-mmode.el') diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index b1cb0615e43..4b6f4d634ca 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -94,8 +94,9 @@ Optional LIGHTER is displayed in the modeline when the mode is on. Optional KEYMAP is the default keymap bound to the mode keymap. If non-nil, it should be a variable name (whose value is a keymap), or an expression that returns either a keymap or a list of - arguments for `easy-mmode-define-keymap'. If KEYMAP is not a symbol, - this also defines the variable MODE-map. + arguments for `easy-mmode-define-keymap'. If you supply a KEYMAP + argument that is not a symbol, this macro defines the variable + MODE-map and gives it the value that KEYMAP specifies. BODY contains code to execute each time the mode is enabled or disabled. It is executed after toggling the mode, and before running MODE-hook. -- cgit v1.2.3 From 15de15c66d96905aa21f1781861067eebd68b24b Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 27 Oct 2011 11:01:40 +0800 Subject: Replace fundamental-mode-hook with change-major-mode-after-body-hook. * lisp/simple.el (fundamental-mode): * lisp/emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28 change introducing fundamental-mode-hook. * lisp/subr.el (change-major-mode-after-body-hook): New hook. (run-mode-hooks): Run it. * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use change-major-mode-before-body-hook. --- etc/NEWS | 21 ++++++++++++++------- lisp/ChangeLog | 12 ++++++++++++ lisp/emacs-lisp/derived.el | 2 +- lisp/emacs-lisp/easy-mmode.el | 6 ++++-- lisp/simple.el | 3 ++- lisp/subr.el | 5 ++++- 6 files changed, 37 insertions(+), 12 deletions(-) (limited to 'lisp/emacs-lisp/easy-mmode.el') diff --git a/etc/NEWS b/etc/NEWS index 6e60f2a65f9..9e407133e8b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1218,15 +1218,22 @@ syntactic rules. ** frame-local variables cannot be let-bound any more. +** Major and minor mode changes +++ -** prog-mode is a new major-mode meant to be the parent of programming mode. -The prog-mode-hook it defines can be used to enable features for -programming modes. For example: -(add-hook 'prog-mode-hook 'flyspell-prog-mode) -enables on the fly spell checking for comments and strings for -programming modes. +*** `prog-mode' is a new major mode from which programming modes +should be derived. -** define-minor-mode accepts a new keyword :variable. +**** `prog-mode-hook' can be used to enable features for programming +modes, e.g. (add-hook 'prog-mode-hook 'flyspell-prog-mode) to enable +on-the-fly spell checking for comments and strings. + +*** New hook `change-major-mode-after-body-hook', run by +`run-mode-hooks' just before any other mode hooks. + +*** Enabled globalized minor modes can be disabled in specific modes, +by running (FOO-mode-hook 0) via a mode hook. + +*** `define-minor-mode' accepts a new keyword :variable. +++ ** `delete-file' and `delete-directory' now accept optional arg TRASH. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ba25dc89ab..f4a0ceecf93 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2011-10-27 Chong Yidong + + * subr.el (change-major-mode-after-body-hook): New hook. + (run-mode-hooks): Run it. + + * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use + change-major-mode-before-body-hook. + + * simple.el (fundamental-mode): + * emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28 + change introducing fundamental-mode-hook. + 2011-10-26 Juanma Barranquero * term/w32-win.el (w32-default-color-map): Declare obsolete. (Bug#9785) diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index 81932f9940a..55ea102ed2a 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -230,7 +230,7 @@ No problems result if this variable is not bound. ; Run the parent. (delay-mode-hooks - (,(or parent 'fundamental-mode)) + (,(or parent 'kill-all-local-variables)) ; Identify the child mode. (setq major-mode (quote ,child)) (setq mode-name ,name) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 4b6f4d634ca..bf9f2c9d6ed 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -368,11 +368,13 @@ See `%s' for more information on %s." (progn (add-hook 'after-change-major-mode-hook ',MODE-enable-in-buffers) - (add-hook 'fundamental-mode-hook ',MODE-enable-in-buffers) + (add-hook 'change-major-mode-after-body-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 'change-major-mode-after-body-hook + ',MODE-enable-in-buffers) (remove-hook 'find-file-hook ',MODE-check-buffers) (remove-hook 'change-major-mode-hook ',MODE-cmhh)) diff --git a/lisp/simple.el b/lisp/simple.el index 79de6aea3dd..90d22c817b0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -349,7 +349,8 @@ location." Other major modes are defined by comparison with this one." (interactive) (kill-all-local-variables) - (run-mode-hooks 'fundamental-mode-hook)) + (unless delay-mode-hooks + (run-hooks 'after-change-major-mode-hook))) ;; Special major modes to view specially formatted data rather than files. diff --git a/lisp/subr.el b/lisp/subr.el index 7ac287d2473..f3cd4dabe20 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1530,6 +1530,9 @@ if it is empty or a duplicate." (make-variable-buffer-local 'delayed-mode-hooks) (put 'delay-mode-hooks 'permanent-local t) +(defvar change-major-mode-after-body-hook nil + "Normal hook run in major mode functions, before the mode hooks.") + (defvar after-change-major-mode-hook nil "Normal hook run at the very end of major mode functions.") @@ -1546,7 +1549,7 @@ FOO-mode-hook." ;; 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) + (apply 'run-hooks (cons 'change-major-mode-after-body-hook hooks)) (run-hooks 'after-change-major-mode-hook))) (defmacro delay-mode-hooks (&rest body) -- cgit v1.2.3