]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/easy-mmode.el
(make-char): Fix typo in docstring.
[gnu-emacs] / lisp / emacs-lisp / easy-mmode.el
index 710c26e0c6c97aa2dd9e821c5cc951c580c022cb..b22e49dac34f8c0a39ea7e440d7416c44f895a76 100644 (file)
@@ -1,7 +1,7 @@
 ;;; easy-mmode.el --- easy definition for major and minor modes
 
 ;;; 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 <Georges.Brun-Cottan@inria.fr>
 ;; Maintainer: Stefan Monnier <monnier@gnu.org>
 
 ;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
 ;; Maintainer: Stefan Monnier <monnier@gnu.org>
@@ -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).
 
 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):
   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)))
 
     (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)
         (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;
 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
            `(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))
         (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)
                 (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)))
                    (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)
        (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))
              ,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)
 
 
 (provide 'easy-mmode)