From 9f70f91e94a4c855d7ff8a98cf948f24e0f3eb31 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 25 Feb 2013 20:50:45 -0500 Subject: [PATCH] * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Tweak logic. (easy-mmode-set-keymap-parents): Use make-composed-keymap. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/easy-mmode.el | 37 +++++++++++------------------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f01ef60c35a..72a7d11eaa2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-02-26 Stefan Monnier + + * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Tweak logic. + (easy-mmode-set-keymap-parents): Use make-composed-keymap. + 2013-02-25 Stefan Monnier * emacs-lisp/bytecomp.el (byte-compile-file): Use let. diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 2088e690228..abe7b1ea741 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -359,10 +359,8 @@ on if the hook has explicitly disabled it." (MODE-check-buffers (intern (concat global-mode-name "-check-buffers"))) (MODE-cmhh (intern (concat global-mode-name "-cmhh"))) - (MODE-disable-in-buffer - (intern (concat global-mode-name "-disable-in-buffer"))) (minor-MODE-hook (intern (concat mode-name "-hook"))) - (disable-MODE (intern (concat "disable-" mode-name))) + (MODE-set-explicitly (intern (concat mode-name "-set-explicitly"))) (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode"))) keyw) @@ -409,8 +407,6 @@ See `%s' for more information on %s." (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 '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)) @@ -425,7 +421,7 @@ See `%s' for more information on %s." ;; A function which checks whether MODE has been disabled in the major ;; mode hook which has just been run. - (add-hook ',minor-MODE-hook ',MODE-disable-in-buffer) + (add-hook ',minor-MODE-hook ',MODE-set-explicitly) ;; List of buffers left to process. (defvar ,MODE-buffers nil) @@ -435,8 +431,7 @@ See `%s' for more information on %s." (dolist (buf ,MODE-buffers) (when (buffer-live-p buf) (with-current-buffer buf - (if ,disable-MODE - (if ,mode (,mode -1)) + (unless ,MODE-set-explicitly (unless (eq ,MODE-major-mode major-mode) (if ,mode (progn @@ -457,30 +452,20 @@ See `%s' for more information on %s." (add-to-list ',MODE-buffers (current-buffer)) (add-hook 'post-command-hook ',MODE-check-buffers)) (put ',MODE-cmhh 'definition-name ',global-mode) - ;; disable-MODE is set in MODE-disable-in-buffer and cleared by + ;; MODE-set-explicitly is set in MODE-set-explicitly and cleared by ;; kill-all-local-variables. - (defvar-local ,disable-MODE nil) - (defun ,MODE-disable-in-buffer () - (unless ,mode - (setq ,disable-MODE t))) - (put ',MODE-disable-in-buffer 'definition-name ',global-mode)))) + (defvar-local ,MODE-set-explicitly nil) + (defun ,MODE-set-explicitly () + (setq ,MODE-set-explicitly t)) + (put ',MODE-set-explicitly 'definition-name ',global-mode)))) ;;; ;;; easy-mmode-defmap ;;; -(eval-and-compile - (if (fboundp 'set-keymap-parents) - (defalias 'easy-mmode-set-keymap-parents 'set-keymap-parents) - (defun easy-mmode-set-keymap-parents (m parents) - (set-keymap-parent - m - (cond - ((not (consp parents)) parents) - ((not (cdr parents)) (car parents)) - (t (let ((m (copy-keymap (pop parents)))) - (easy-mmode-set-keymap-parents m parents) - m))))))) +(defun easy-mmode-set-keymap-parents (m parents) + (set-keymap-parent + m (if (cdr parents) (make-composed-keymap parents) (car parents)))) ;;;###autoload (defun easy-mmode-define-keymap (bs &optional name m args) -- 2.39.2