emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fundamental mode vs. special mode


From: Chong Yidong
Subject: Re: Fundamental mode vs. special mode
Date: Tue, 25 Oct 2011 11:51:40 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

Chong Yidong <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]