Mercurial > hg > xemacs-beta
diff lisp/custom/custom.el @ 120:cca96a509cfe r20-1b12
Import from CVS: tag r20-1b12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:25:29 +0200 |
parents | 7d55a9ba150c |
children | 9b50b4588a93 |
line wrap: on
line diff
--- a/lisp/custom/custom.el Mon Aug 13 09:24:19 2007 +0200 +++ b/lisp/custom/custom.el Mon Aug 13 09:25:29 2007 +0200 @@ -4,7 +4,7 @@ ;; ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> ;; Keywords: help, faces -;; Version: 1.69 +;; Version: 1.74 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ ;;; Commentary: @@ -23,6 +23,9 @@ (define-widget-keywords :prefix :tag :load :link :options :type :group) +(defvar custom-define-hook nil + "Hook called after defining each customize option.") + ;; These autoloads should be deleted when the file is added to Emacs (unless (fboundp 'load-gc) @@ -33,7 +36,6 @@ (autoload 'customize-apropos "cus-edit" nil t) (autoload 'customize-customized "cus-edit" nil t) (autoload 'custom-buffer-create "cus-edit") - (autoload 'custom-menu-update "cus-edit") (autoload 'custom-make-dependencies "cus-edit") ;; From cus-face.el (autoload 'custom-declare-face "cus-face") @@ -43,12 +45,18 @@ (defun custom-declare-variable (symbol value doc &rest args) "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments." - (unless (and (default-boundp symbol) - (not (get symbol 'saved-value))) + ;; Bind this variable unless it already is bound. + (unless (default-boundp symbol) + ;; Use the saved value if it exists, otherwise the factory setting. (set-default symbol (if (get symbol 'saved-value) (eval (car (get symbol 'saved-value))) (eval value)))) + ;; Remember the factory setting. (put symbol 'factory-value (list value)) + ;; Maybe this option was rogue in an earlier version. It no longer is. + (when (get symbol 'force-value) + ;; It no longer is. + (put symbol 'force-value nil)) (when doc (put symbol 'variable-documentation doc)) (while args @@ -278,9 +286,13 @@ (value (nth 1 entry)) (now (nth 2 entry))) (put symbol 'saved-value (list value)) - (when now - (put symbol 'force-value t) - (set-default symbol (eval value))) + (cond (now + ;; Rogue variable, set it now. + (put symbol 'force-value t) + (set-default symbol (eval value))) + ((default-boundp symbol) + ;; Something already set this, overwrite it. + (set-default symbol (eval value)))) (setq args (cdr args))) ;; Old format, a plist of SYMBOL VALUE pairs. (let ((symbol (nth 0 args)) @@ -288,43 +300,6 @@ (put symbol 'saved-value (list value))) (setq args (cdr (cdr args))))))) -;;; Meta Customization - -(defcustom custom-define-hook nil - "Hook called after defining each customize option." - :group 'customize - :type 'hook) - -;;; Menu support - -(defconst custom-help-menu - `("Customize" - ,(if (string-match "XEmacs" emacs-version) - '("Emacs" :filter (lambda (&rest junk) - (cdr (custom-menu-create 'emacs)))) - ["Update menu..." custom-menu-update t]) - ["Group..." customize t] - ["Variable..." customize-variable t] - ["Face..." customize-face t] - ["Saved..." customize-customized t] - ["Apropos..." customize-apropos t]) - "Customize menu") - -(defun custom-menu-reset () - "Reset customize menu." - (remove-hook 'custom-define-hook 'custom-menu-reset) - (if (string-match "XEmacs" emacs-version) - (when (fboundp 'add-submenu) - (add-submenu '("Options") custom-help-menu)) - (define-key global-map [menu-bar help-menu customize-menu] - (cons (car custom-help-menu) - (easy-menu-create-keymaps (car custom-help-menu) - (cdr custom-help-menu)))))) - -(if (string-match "XEmacs" emacs-version) - (autoload 'custom-menu-create "cus-edit") - (custom-menu-reset)) - ;;; The End. (provide 'custom)