1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-29 11:02:01 +00:00

(custom-get-fresh-buffer): New fun.

(custom-buffer-create, custom-buffer-create-other-window)
(customize-browse): Use it instead of killing buffers.
(custom-bury-buffer): Obey the argument.
(custom-variable-reset-saved, custom-variable-reset-standard):
Remove unused var `comment-widget'.
(custom-face-edit-deactivate): Remove unused var `to'.
(custom-save-variables): Remove unused var `sep'.
This commit is contained in:
Stefan Monnier 2003-05-31 15:23:00 +00:00
parent f118d83b79
commit 40627755be

View File

@ -1,6 +1,6 @@
;;; cus-edit.el --- tools for customizing Emacs and Lisp packages ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
;; ;;
;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. ;; Copyright (C) 1996,97,1999,2000,01,02,2003 Free Software Foundation, Inc.
;; ;;
;; Author: Per Abrahamsen <abraham@dina.kvl.dk> ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
;; Maintainer: FSF ;; Maintainer: FSF
@ -1189,7 +1189,8 @@ links: groups have links to subgroups."
;; If we pass BUFFER to `bury-buffer', the buffer isn't removed from ;; If we pass BUFFER to `bury-buffer', the buffer isn't removed from
;; the window. ;; the window.
(defun custom-bury-buffer (buffer) (defun custom-bury-buffer (buffer)
(bury-buffer)) (with-current-buffer buffer
(bury-buffer)))
(defcustom custom-buffer-done-function 'custom-bury-buffer (defcustom custom-buffer-done-function 'custom-bury-buffer
"*Function called to remove a Custom buffer when the user is done with it. "*Function called to remove a Custom buffer when the user is done with it.
@ -1205,6 +1206,20 @@ Called with one argument, the buffer to remove."
:type 'integer :type 'integer
:group 'custom-buffer) :group 'custom-buffer)
(defun custom-get-fresh-buffer (name)
"Get a fresh new buffer with name NAME.
If the buffer already exist, clean it up to be like new."
(let ((buf (get-buffer name)))
(if (null buf)
(get-buffer-create name)
(with-current-buffer buf
(kill-all-local-variables)
(erase-buffer)
(let ((ols (overlay-lists)))
(dolist (ol (nconc (car ols) (cdr ols)))
(delete-overlay ol)))
buf))))
;;;###autoload ;;;###autoload
(defun custom-buffer-create (options &optional name description) (defun custom-buffer-create (options &optional name description)
"Create a buffer containing OPTIONS. "Create a buffer containing OPTIONS.
@ -1212,9 +1227,7 @@ Optional NAME is the name of the buffer.
OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
SYMBOL is a customization option, and WIDGET is a widget for editing SYMBOL is a customization option, and WIDGET is a widget for editing
that option." that option."
(unless name (setq name "*Customization*")) (pop-to-buffer (custom-get-fresh-buffer (or name "*Customization*")))
(kill-buffer (get-buffer-create name))
(pop-to-buffer (get-buffer-create name))
(custom-buffer-create-internal options description)) (custom-buffer-create-internal options description))
;;;###autoload ;;;###autoload
@ -1225,14 +1238,13 @@ OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
SYMBOL is a customization option, and WIDGET is a widget for editing SYMBOL is a customization option, and WIDGET is a widget for editing
that option." that option."
(unless name (setq name "*Customization*")) (unless name (setq name "*Customization*"))
(kill-buffer (get-buffer-create name))
(let ((window (selected-window)) (let ((window (selected-window))
(pop-up-windows t) (pop-up-windows t)
(special-display-buffer-names nil) (special-display-buffer-names nil)
(special-display-regexps nil) (special-display-regexps nil)
(same-window-buffer-names nil) (same-window-buffer-names nil)
(same-window-regexps nil)) (same-window-regexps nil))
(pop-to-buffer (get-buffer-create name)) (pop-to-buffer (custom-get-fresh-buffer name))
(custom-buffer-create-internal options description) (custom-buffer-create-internal options description)
(select-window window))) (select-window window)))
@ -1392,8 +1404,7 @@ Un-customize all values in this buffer. They get their standard settings."
(unless group (unless group
(setq group 'emacs)) (setq group 'emacs))
(let ((name "*Customize Browser*")) (let ((name "*Customize Browser*"))
(kill-buffer (get-buffer-create name)) (pop-to-buffer (custom-get-fresh-buffer name)))
(pop-to-buffer (get-buffer-create name)))
(custom-mode) (custom-mode)
(widget-insert "\ (widget-insert "\
Square brackets show active fields; type RET or click mouse-1 Square brackets show active fields; type RET or click mouse-1
@ -2440,7 +2451,6 @@ The value that was current before this operation
becomes the backup value, so you can get it again." becomes the backup value, so you can get it again."
(let* ((symbol (widget-value widget)) (let* ((symbol (widget-value widget))
(set (or (get symbol 'custom-set) 'set-default)) (set (or (get symbol 'custom-set) 'set-default))
(comment-widget (widget-get widget :comment-widget))
(value (get symbol 'saved-value)) (value (get symbol 'saved-value))
(comment (get symbol 'saved-variable-comment))) (comment (get symbol 'saved-variable-comment)))
(cond ((or value comment) (cond ((or value comment)
@ -2464,8 +2474,7 @@ restoring it to the state of a variable that has never been customized.
The value that was current before this operation The value that was current before this operation
becomes the backup value, so you can get it again." becomes the backup value, so you can get it again."
(let* ((symbol (widget-value widget)) (let* ((symbol (widget-value widget))
(set (or (get symbol 'custom-set) 'set-default)) (set (or (get symbol 'custom-set) 'set-default)))
(comment-widget (widget-get widget :comment-widget)))
(if (get symbol 'standard-value) (if (get symbol 'standard-value)
(progn (progn
(custom-variable-backup-value widget) (custom-variable-backup-value widget)
@ -2586,7 +2595,6 @@ Also change :reverse-video to :inverse-video."
(unless (widget-get widget :inactive) (unless (widget-get widget :inactive)
(let ((tag (custom-face-edit-attribute-tag widget)) (let ((tag (custom-face-edit-attribute-tag widget))
(from (copy-marker (widget-get widget :from))) (from (copy-marker (widget-get widget :from)))
(to (widget-get widget :to))
(value (widget-value widget)) (value (widget-value widget))
(inhibit-read-only t) (inhibit-read-only t)
(inhibit-modification-hooks t)) (inhibit-modification-hooks t))
@ -3727,8 +3735,7 @@ or (if there were none) at the end of the buffer."
(and (not (boundp symbol)) (and (not (boundp symbol))
(not (eq (get symbol 'force-value) (not (eq (get symbol 'force-value)
'rogue)))))) 'rogue))))))
(comment (get symbol 'saved-variable-comment)) (comment (get symbol 'saved-variable-comment)))
sep)
;; Check `requests'. ;; Check `requests'.
(dolist (request requests) (dolist (request requests)
(when (and (symbolp request) (not (featurep request))) (when (and (symbolp request) (not (featurep request)))