]> code.delx.au - gnu-emacs/blobdiff - lisp/wid-browse.el
* lisp/simple.el (end-of-buffer): Don't touch unrelated windows.
[gnu-emacs] / lisp / wid-browse.el
index 799d9ae760e40569a90010a9d0aac3cbdf46d5f1..caf41427538e2bd8f35530f531e6c2de28353caa 100644 (file)
@@ -1,17 +1,17 @@
 ;;; wid-browse.el --- functions for browsing widgets
 ;;
-;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: extensions
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 ;;
@@ -32,7 +30,6 @@
 (require 'easymenu)
 (require 'custom)
 (require 'wid-edit)
-(eval-when-compile (require 'cl))
 
 (defgroup widget-browse nil
   "Customization support for browsing widgets."
 
 ;;; The Mode.
 
-(defvar widget-browse-mode-map nil
+(defvar widget-browse-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map widget-keymap)
+    (define-key map "q" 'bury-buffer)
+    map)
   "Keymap for `widget-browse-mode'.")
 
-(unless widget-browse-mode-map
-  (setq widget-browse-mode-map (make-sparse-keymap))
-  (set-keymap-parent widget-browse-mode-map widget-keymap)
-  (define-key widget-browse-mode-map "q" 'bury-buffer))
-
 (easy-menu-define widget-browse-mode-customize-menu
     widget-browse-mode-map
   "Menu used in widget browser buffers."
@@ -192,7 +188,7 @@ The :value of the widget shuld be the widget to be browsed."
   :value-create 'widget-browse-value-create
   :action 'widget-browse-action)
 
-(defun widget-browse-action (widget &optional event)
+(defun widget-browse-action (widget &optional _event)
   ;; Create widget browser for WIDGET's :value.
   (widget-browse (widget-get widget :value)))
 
@@ -208,12 +204,12 @@ The :value of the widget shuld be the widget to be browsed."
 
 ;;; Keyword Printer Functions.
 
-(defun widget-browse-widget (widget key value)
+(defun widget-browse-widget (_widget _key value)
   "Insert description of WIDGET's KEY VALUE.
 VALUE is assumed to be a widget."
   (widget-create 'widget-browse value))
 
-(defun widget-browse-widgets (widget key value)
+(defun widget-browse-widgets (_widget _key value)
   "Insert description of WIDGET's KEY VALUE.
 VALUE is assumed to be a list of widgets."
   (while value
@@ -223,7 +219,7 @@ VALUE is assumed to be a list of widgets."
     (when value
       (widget-insert " "))))
 
-(defun widget-browse-sexp (widget key value)
+(defun widget-browse-sexp (_widget _key value)
   "Insert description of WIDGET's KEY VALUE.
 Nothing is assumed about value."
   (let ((pp (condition-case signal
@@ -239,7 +235,7 @@ Nothing is assumed about value."
        (widget-insert pp)
       (widget-create 'push-button
                     :tag "show"
-                    :action (lambda (widget &optional event)
+                    :action (lambda (widget &optional _event)
                               (with-output-to-temp-buffer
                                   "*Pp Eval Output*"
                                 (princ (widget-get widget :value))))
@@ -265,38 +261,22 @@ VALUE is assumed to be a list of widgets."
 
 ;;; Widget Minor Mode.
 
-(defvar widget-minor-mode nil
-  "If non-nil, we are in Widget Minor Mode.")
-(make-variable-buffer-local 'widget-minor-mode)
-
-(defvar widget-minor-mode-map nil
+(defvar widget-minor-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map widget-keymap)
+    map)
   "Keymap used in Widget Minor Mode.")
 
-(unless widget-minor-mode-map
-  (setq widget-minor-mode-map (make-sparse-keymap))
-  (set-keymap-parent widget-minor-mode-map widget-keymap))
-
 ;;;###autoload
-(defun widget-minor-mode (&optional arg)
-  "Togle minor mode for traversing widgets.
-With arg, turn widget mode on if and only if arg is positive."
-  (interactive "P")
-  (cond ((null arg)
-        (setq widget-minor-mode (not widget-minor-mode)))
-       ((<= arg 0)
-        (setq widget-minor-mode nil))
-       (t
-        (setq widget-minor-mode t)))
-  (force-mode-line-update))
-
-(add-to-list 'minor-mode-alist '(widget-minor-mode " Widget"))
-
-(add-to-list 'minor-mode-map-alist
-            (cons 'widget-minor-mode widget-minor-mode-map))
+(define-minor-mode widget-minor-mode
+  "Minor mode for traversing widgets.
+With a prefix argument ARG, enable the mode if ARG is positive,
+and disable it otherwise.  If called from Lisp, enable the mode
+if ARG is omitted or nil."
+  :lighter " Widget")
 
 ;;; The End:
 
 (provide 'wid-browse)
 
-;;; arch-tag: d5ffb18f-8984-4735-8502-edf70456db21
 ;;; wid-browse.el ends here