From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: Fundamental mode vs. special mode Date: Tue, 25 Oct 2011 11:51:40 +0800 Message-ID: <87obx5zq2b.fsf@gnu.org> References: <86sjmkvl80.fsf@googlemail.com> <878vob4zq0.fsf@gnu.org> <878vo9vlr5.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1319514719 28940 80.91.229.12 (25 Oct 2011 03:51:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 25 Oct 2011 03:51:59 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 25 05:51:56 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RIY3O-00036M-Aj for ged-emacs-devel@m.gmane.org; Tue, 25 Oct 2011 05:51:54 +0200 Original-Received: from localhost ([::1]:54981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIY3N-0003cZ-UZ for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2011 23:51:53 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIY3K-0003cT-4Q for emacs-devel@gnu.org; Mon, 24 Oct 2011 23:51:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIY3J-0006Ty-0l for emacs-devel@gnu.org; Mon, 24 Oct 2011 23:51:49 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:47628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIY3I-0006Tu-TJ for emacs-devel@gnu.org; Mon, 24 Oct 2011 23:51:48 -0400 Original-Received: from bb116-14-207-132.singnet.com.sg ([116.14.207.132]:40415 helo=furball) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1RIY3H-0004Dp-Of for emacs-devel@gnu.org; Mon, 24 Oct 2011 23:51:48 -0400 In-Reply-To: <878vo9vlr5.fsf@gnu.org> (Chong Yidong's message of "Tue, 25 Oct 2011 10:38:22 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.10 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:145491 Archived-At: Chong Yidong 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)