X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0ceed14b2e38e1de08823efb6737b9af1ce4268f..5dd1c041c7fdb876b52bf33f41e8aeb119282cef:/lisp/emacs-lisp/easy-mmode.el diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 710c26e0c6..b22e49dac3 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -1,7 +1,7 @@ ;;; easy-mmode.el --- easy definition for major and minor modes -;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005 -;; Free Software Foundation, Inc. +;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005, +;; 2006 Free Software Foundation, Inc. ;; Author: Georges Brun-Cottan ;; Maintainer: Stefan Monnier @@ -101,9 +101,9 @@ Optional KEYMAP is the default (defvar) keymap bound to the mode keymap. The above three arguments can be skipped if keyword arguments are used (see below). -BODY contains code that will be executed each time the mode is (dis)activated. - It will be executed after any toggling but before running the hook variable - `mode-HOOK'. +BODY contains code to execute each time the mode is activated or deactivated. + It is executed after toggling the mode, + and before running the hook variable `mode-HOOK'. Before the actual body code, you can write keyword arguments (alternating keywords and values). These following keyword arguments are supported (other keywords will be passed to `defcustom' if the minor mode is global): @@ -139,7 +139,8 @@ For example, you could write (setq body (list* lighter keymap body) lighter nil keymap nil)) ((keywordp keymap) (push keymap body) (setq keymap nil))) - (let* ((mode-name (symbol-name mode)) + (let* ((last-message (current-message)) + (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode lighter)) (globalp nil) (set nil) @@ -199,7 +200,8 @@ Use the command `%s' to change this variable." pretty-name mode)) See the command `%s' for a description of this minor-mode." (if body " Setting this variable directly does not take effect; -use either \\[customize] or the function `%s'.")))) +either customize it (see the info node `Easy Customization') +or call the function `%s'.")))) `(defcustom ,mode ,init-value ,(format base-doc-string pretty-name mode mode) ,@set @@ -236,7 +238,10 @@ With zero or negative ARG turn mode off. (if (called-interactively-p) (progn ,(if globalp `(customize-mark-as-set ',mode)) - (unless (current-message) + ;; Avoid overwriting a message shown by the body, + ;; but do overwrite previous messages. + (unless ,(and (current-message) + (not (equal last-message (current-message)))) (message ,(format "%s %%sabled" pretty-name) (if ,mode "en" "dis"))))) (force-mode-line-update) @@ -515,6 +520,7 @@ found, do widen first and then call NARROWFUN with no args after moving." (unless (pos-visible-in-window-p endpt nil t) (recenter '(0)))))) ,re-narrow-maybe))) + (put ',next-sym 'definition-name ',base) (defun ,prev-sym (&optional count) ,(format "Go to the previous COUNT'th %s" (or name base-name)) (interactive) @@ -524,7 +530,8 @@ found, do widen first and then call NARROWFUN with no args after moving." ,check-narrow-maybe (unless (re-search-backward ,re nil t count) (error "No previous %s" ,name)) - ,re-narrow-maybe)))))) + ,re-narrow-maybe))) + (put ',prev-sym 'definition-name ',base)))) (provide 'easy-mmode)