Richard Stallman wrote: Would you please explain what problem would happen in this case?
I could, but it would be moot. The patch to easy-mmode I propose below does not have the problem. It assumes, however, that the problems for Font Lock mode get taken care of. ===File ~/easy-mmode-diff=================================== *** easy-mmode.el 22 May 2005 16:50:33 -0500 1.63 --- easy-mmode.el 31 May 2005 19:34:34 -0500 *************** *** 271,284 **** TURN-ON is a function that will be called with no args in every buffer and that should try to turn MODE on if applicable for that buffer. KEYS is a list of CL-style keyword arguments: ! :group to specify the custom group." (let* ((global-mode-name (symbol-name global-mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) (pretty-global-name (easy-mmode-pretty-mode-name global-mode)) (group nil) (extra-args nil) (buffers (intern (concat global-mode-name "-buffers"))) ! (cmmh (intern (concat global-mode-name "-cmmh")))) ;; Check keys. (while (keywordp (car keys)) --- 271,293 ---- TURN-ON is a function that will be called with no args in every buffer and that should try to turn MODE on if applicable for that buffer. KEYS is a list of CL-style keyword arguments: ! :group to specify the custom group. ! ! If MODE's set-up depends on the major mode in effect when it was ! enabled, then disabling and reenabling MODE should make MODE work ! correctly with the current major mode. This is important to ! prevent problems with derived modes, that is, major modes that ! call another major mode in their body." ! (let* ((global-mode-name (symbol-name global-mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) (pretty-global-name (easy-mmode-pretty-mode-name global-mode)) (group nil) (extra-args nil) (buffers (intern (concat global-mode-name "-buffers"))) ! (buffers-check (intern (concat global-mode-name "-check-buffers"))) ! (cmmh (intern (concat global-mode-name "-cmmh"))) ! (stored-mode (intern (concat (symbol-name mode) "-stored-mode")))) ;; Check keys. (while (keywordp (car keys)) *************** *** 294,299 **** --- 303,310 ---- "-mode\\'" "" (symbol-name mode)))))) `(progn + (defvar ,stored-mode nil) + (make-variable-buffer-local ',stored-mode) ;; The actual global minor-mode (define-minor-mode ,global-mode ,(format "Toggle %s in every buffer. *************** *** 307,314 **** --- 318,327 ---- (if ,global-mode (progn (add-hook 'after-change-major-mode-hook ',buffers) + (add-hook 'find-file-hook ',buffers-check) (add-hook 'change-major-mode-hook ',cmmh)) (remove-hook 'after-change-major-mode-hook ',buffers) + (remove-hook 'find-file-hook ',buffers-check) (remove-hook 'change-major-mode-hook ',cmmh)) ;; Go through existing buffers. *************** *** 325,341 **** ;; The function that calls TURN-ON in each buffer. (defun ,buffers () ! (remove-hook 'post-command-hook ',buffers) (while ,buffers (let ((buf (pop ,buffers))) (when (buffer-live-p buf) ! (with-current-buffer buf (,turn-on)))))) ! (put ',buffers 'definition-name ',global-mode) ;; The function that catches kill-all-local-variables. (defun ,cmmh () (add-to-list ',buffers (current-buffer)) ! (add-hook 'post-command-hook ',buffers)) (put ',cmmh 'definition-name ',global-mode)))) ;;; --- 338,374 ---- ;; The function that calls TURN-ON in each buffer. (defun ,buffers () ! (dolist (buf ,buffers) ! (when (buffer-live-p buf) ! (with-current-buffer buf ! (if ,mode ! (unless (eq ,stored-mode major-mode) ! (,mode -1) ! (,turn-on) ! (setq ,stored-mode major-mode)) ! (,turn-on) ! (setq ,stored-mode major-mode)))))) ! (put ',buffers 'definition-name ',global-mode) ! ! (defun ,buffers-check () ! (remove-hook 'post-command-hook ',buffers-check) (while ,buffers (let ((buf (pop ,buffers))) (when (buffer-live-p buf) ! (with-current-buffer buf ! (if ,mode ! (unless (eq ,stored-mode major-mode) ! (,mode -1) ! (,turn-on) ! (setq ,stored-mode major-mode)) ! (,turn-on) ! (setq ,stored-mode major-mode))))))) ! (put ',buffers-check 'definition-name ',global-mode) ;; The function that catches kill-all-local-variables. (defun ,cmmh () (add-to-list ',buffers (current-buffer)) ! (add-hook 'post-command-hook ',buffers-check)) (put ',cmmh 'definition-name ',global-mode)))) ;;; ============================================================ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel