Mercurial > emacs
comparison lisp/cus-edit.el @ 51362:0b5cb555fd17
(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'.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 31 May 2003 15:23:00 +0000 |
parents | caaa4fda6808 |
children | a2b5bb57e1c9 |
comparison
equal
deleted
inserted
replaced
51361:3bd89ae152d0 | 51362:0b5cb555fd17 |
---|---|
1 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages | 1 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages |
2 ;; | 2 ;; |
3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1996,97,1999,2000,01,02,2003 Free Software Foundation, Inc. |
4 ;; | 4 ;; |
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
7 ;; Keywords: help, faces | 7 ;; Keywords: help, faces |
8 | 8 |
1187 :group 'custom-buffer) | 1187 :group 'custom-buffer) |
1188 | 1188 |
1189 ;; If we pass BUFFER to `bury-buffer', the buffer isn't removed from | 1189 ;; If we pass BUFFER to `bury-buffer', the buffer isn't removed from |
1190 ;; the window. | 1190 ;; the window. |
1191 (defun custom-bury-buffer (buffer) | 1191 (defun custom-bury-buffer (buffer) |
1192 (bury-buffer)) | 1192 (with-current-buffer buffer |
1193 (bury-buffer))) | |
1193 | 1194 |
1194 (defcustom custom-buffer-done-function 'custom-bury-buffer | 1195 (defcustom custom-buffer-done-function 'custom-bury-buffer |
1195 "*Function called to remove a Custom buffer when the user is done with it. | 1196 "*Function called to remove a Custom buffer when the user is done with it. |
1196 Called with one argument, the buffer to remove." | 1197 Called with one argument, the buffer to remove." |
1197 :type '(choice (function-item :tag "Bury buffer" custom-bury-buffer) | 1198 :type '(choice (function-item :tag "Bury buffer" custom-bury-buffer) |
1203 (defcustom custom-buffer-indent 3 | 1204 (defcustom custom-buffer-indent 3 |
1204 "Number of spaces to indent nested groups." | 1205 "Number of spaces to indent nested groups." |
1205 :type 'integer | 1206 :type 'integer |
1206 :group 'custom-buffer) | 1207 :group 'custom-buffer) |
1207 | 1208 |
1209 (defun custom-get-fresh-buffer (name) | |
1210 "Get a fresh new buffer with name NAME. | |
1211 If the buffer already exist, clean it up to be like new." | |
1212 (let ((buf (get-buffer name))) | |
1213 (if (null buf) | |
1214 (get-buffer-create name) | |
1215 (with-current-buffer buf | |
1216 (kill-all-local-variables) | |
1217 (erase-buffer) | |
1218 (let ((ols (overlay-lists))) | |
1219 (dolist (ol (nconc (car ols) (cdr ols))) | |
1220 (delete-overlay ol))) | |
1221 buf)))) | |
1222 | |
1208 ;;;###autoload | 1223 ;;;###autoload |
1209 (defun custom-buffer-create (options &optional name description) | 1224 (defun custom-buffer-create (options &optional name description) |
1210 "Create a buffer containing OPTIONS. | 1225 "Create a buffer containing OPTIONS. |
1211 Optional NAME is the name of the buffer. | 1226 Optional NAME is the name of the buffer. |
1212 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where | 1227 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
1213 SYMBOL is a customization option, and WIDGET is a widget for editing | 1228 SYMBOL is a customization option, and WIDGET is a widget for editing |
1214 that option." | 1229 that option." |
1215 (unless name (setq name "*Customization*")) | 1230 (pop-to-buffer (custom-get-fresh-buffer (or name "*Customization*"))) |
1216 (kill-buffer (get-buffer-create name)) | |
1217 (pop-to-buffer (get-buffer-create name)) | |
1218 (custom-buffer-create-internal options description)) | 1231 (custom-buffer-create-internal options description)) |
1219 | 1232 |
1220 ;;;###autoload | 1233 ;;;###autoload |
1221 (defun custom-buffer-create-other-window (options &optional name description) | 1234 (defun custom-buffer-create-other-window (options &optional name description) |
1222 "Create a buffer containing OPTIONS. | 1235 "Create a buffer containing OPTIONS. |
1223 Optional NAME is the name of the buffer. | 1236 Optional NAME is the name of the buffer. |
1224 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where | 1237 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
1225 SYMBOL is a customization option, and WIDGET is a widget for editing | 1238 SYMBOL is a customization option, and WIDGET is a widget for editing |
1226 that option." | 1239 that option." |
1227 (unless name (setq name "*Customization*")) | 1240 (unless name (setq name "*Customization*")) |
1228 (kill-buffer (get-buffer-create name)) | |
1229 (let ((window (selected-window)) | 1241 (let ((window (selected-window)) |
1230 (pop-up-windows t) | 1242 (pop-up-windows t) |
1231 (special-display-buffer-names nil) | 1243 (special-display-buffer-names nil) |
1232 (special-display-regexps nil) | 1244 (special-display-regexps nil) |
1233 (same-window-buffer-names nil) | 1245 (same-window-buffer-names nil) |
1234 (same-window-regexps nil)) | 1246 (same-window-regexps nil)) |
1235 (pop-to-buffer (get-buffer-create name)) | 1247 (pop-to-buffer (custom-get-fresh-buffer name)) |
1236 (custom-buffer-create-internal options description) | 1248 (custom-buffer-create-internal options description) |
1237 (select-window window))) | 1249 (select-window window))) |
1238 | 1250 |
1239 (defcustom custom-reset-button-menu nil | 1251 (defcustom custom-reset-button-menu nil |
1240 "If non-nil, only show a single reset button in customize buffers. | 1252 "If non-nil, only show a single reset button in customize buffers. |
1390 "Create a tree browser for the customize hierarchy." | 1402 "Create a tree browser for the customize hierarchy." |
1391 (interactive) | 1403 (interactive) |
1392 (unless group | 1404 (unless group |
1393 (setq group 'emacs)) | 1405 (setq group 'emacs)) |
1394 (let ((name "*Customize Browser*")) | 1406 (let ((name "*Customize Browser*")) |
1395 (kill-buffer (get-buffer-create name)) | 1407 (pop-to-buffer (custom-get-fresh-buffer name))) |
1396 (pop-to-buffer (get-buffer-create name))) | |
1397 (custom-mode) | 1408 (custom-mode) |
1398 (widget-insert "\ | 1409 (widget-insert "\ |
1399 Square brackets show active fields; type RET or click mouse-1 | 1410 Square brackets show active fields; type RET or click mouse-1 |
1400 on an active field to invoke its action. | 1411 on an active field to invoke its action. |
1401 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n") | 1412 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n") |
2438 "Restore the saved value for the variable being edited by WIDGET. | 2449 "Restore the saved value for the variable being edited by WIDGET. |
2439 The value that was current before this operation | 2450 The value that was current before this operation |
2440 becomes the backup value, so you can get it again." | 2451 becomes the backup value, so you can get it again." |
2441 (let* ((symbol (widget-value widget)) | 2452 (let* ((symbol (widget-value widget)) |
2442 (set (or (get symbol 'custom-set) 'set-default)) | 2453 (set (or (get symbol 'custom-set) 'set-default)) |
2443 (comment-widget (widget-get widget :comment-widget)) | |
2444 (value (get symbol 'saved-value)) | 2454 (value (get symbol 'saved-value)) |
2445 (comment (get symbol 'saved-variable-comment))) | 2455 (comment (get symbol 'saved-variable-comment))) |
2446 (cond ((or value comment) | 2456 (cond ((or value comment) |
2447 (put symbol 'variable-comment comment) | 2457 (put symbol 'variable-comment comment) |
2448 (custom-variable-backup-value widget) | 2458 (custom-variable-backup-value widget) |
2462 This operation eliminates any saved setting for the variable, | 2472 This operation eliminates any saved setting for the variable, |
2463 restoring it to the state of a variable that has never been customized. | 2473 restoring it to the state of a variable that has never been customized. |
2464 The value that was current before this operation | 2474 The value that was current before this operation |
2465 becomes the backup value, so you can get it again." | 2475 becomes the backup value, so you can get it again." |
2466 (let* ((symbol (widget-value widget)) | 2476 (let* ((symbol (widget-value widget)) |
2467 (set (or (get symbol 'custom-set) 'set-default)) | 2477 (set (or (get symbol 'custom-set) 'set-default))) |
2468 (comment-widget (widget-get widget :comment-widget))) | |
2469 (if (get symbol 'standard-value) | 2478 (if (get symbol 'standard-value) |
2470 (progn | 2479 (progn |
2471 (custom-variable-backup-value widget) | 2480 (custom-variable-backup-value widget) |
2472 (funcall set symbol (eval (car (get symbol 'standard-value))))) | 2481 (funcall set symbol (eval (car (get symbol 'standard-value))))) |
2473 (error "No standard setting known for %S" symbol)) | 2482 (error "No standard setting known for %S" symbol)) |
2584 (defun custom-face-edit-deactivate (widget) | 2593 (defun custom-face-edit-deactivate (widget) |
2585 "Make face widget WIDGET inactive for user modifications." | 2594 "Make face widget WIDGET inactive for user modifications." |
2586 (unless (widget-get widget :inactive) | 2595 (unless (widget-get widget :inactive) |
2587 (let ((tag (custom-face-edit-attribute-tag widget)) | 2596 (let ((tag (custom-face-edit-attribute-tag widget)) |
2588 (from (copy-marker (widget-get widget :from))) | 2597 (from (copy-marker (widget-get widget :from))) |
2589 (to (widget-get widget :to)) | |
2590 (value (widget-value widget)) | 2598 (value (widget-value widget)) |
2591 (inhibit-read-only t) | 2599 (inhibit-read-only t) |
2592 (inhibit-modification-hooks t)) | 2600 (inhibit-modification-hooks t)) |
2593 (save-excursion | 2601 (save-excursion |
2594 (goto-char from) | 2602 (goto-char from) |
3725 (requests (get symbol 'custom-requests)) | 3733 (requests (get symbol 'custom-requests)) |
3726 (now (not (or (custom-variable-p symbol) | 3734 (now (not (or (custom-variable-p symbol) |
3727 (and (not (boundp symbol)) | 3735 (and (not (boundp symbol)) |
3728 (not (eq (get symbol 'force-value) | 3736 (not (eq (get symbol 'force-value) |
3729 'rogue)))))) | 3737 'rogue)))))) |
3730 (comment (get symbol 'saved-variable-comment)) | 3738 (comment (get symbol 'saved-variable-comment))) |
3731 sep) | |
3732 ;; Check `requests'. | 3739 ;; Check `requests'. |
3733 (dolist (request requests) | 3740 (dolist (request requests) |
3734 (when (and (symbolp request) (not (featurep request))) | 3741 (when (and (symbolp request) (not (featurep request))) |
3735 (message "Unknown requested feature: %s" request) | 3742 (message "Unknown requested feature: %s" request) |
3736 (setq requests (delq request requests)))) | 3743 (setq requests (delq request requests)))) |