comparison lisp/cus-edit.el @ 19040:c0dc58ad2d47

Synched with 1.9954.
author Per Abrahamsen <abraham@dina.kvl.dk>
date Wed, 30 Jul 1997 12:04:50 +0000
parents 904dcdbb8576
children 200ff7e7d620
comparison
equal deleted inserted replaced
19039:193352043c50 19040:c0dc58ad2d47
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: help, faces 6 ;; Keywords: help, faces
7 ;; Version: 1.9951 7 ;; Version: 1.9954
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
1426 (face (nth 2 entry)) 1426 (face (nth 2 entry))
1427 (category (widget-get parent :custom-category)) 1427 (category (widget-get parent :custom-category))
1428 (text (or (and (eq category 'group) 1428 (text (or (and (eq category 'group)
1429 (nth 4 entry)) 1429 (nth 4 entry))
1430 (nth 3 entry))) 1430 (nth 3 entry)))
1431 (lisp (eq (widget-get parent :custom-form) 'lisp)) 1431 (form (widget-get parent :custom-form))
1432 children) 1432 children)
1433 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text) 1433 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
1434 (setq text (concat (match-string 1 text) 1434 (setq text (concat (match-string 1 text)
1435 (symbol-name category) 1435 (symbol-name category)
1436 (match-string 2 text)))) 1436 (match-string 2 text))))
1455 (insert ": ") 1455 (insert ": ")
1456 (let ((start (point))) 1456 (let ((start (point)))
1457 (if (eq custom-magic-show 'long) 1457 (if (eq custom-magic-show 'long)
1458 (insert text) 1458 (insert text)
1459 (insert (symbol-name state))) 1459 (insert (symbol-name state)))
1460 (when lisp 1460 (cond ((eq form 'lisp)
1461 (insert " (lisp)")) 1461 (insert " (lisp)"))
1462 ((eq form 'mismatch)
1463 (insert " (mismatch)")))
1462 (put-text-property start (point) 'face 'custom-state-face)) 1464 (put-text-property start (point) 'face 'custom-state-face))
1463 (insert "\n")) 1465 (insert "\n"))
1464 (when (and (eq category 'group) 1466 (when (and (eq category 'group)
1465 (not (and (eq custom-buffer-style 'links) 1467 (not (and (eq custom-buffer-style 'links)
1466 (> (widget-get parent :custom-level) 1)))) 1468 (> (widget-get parent :custom-level) 1))))
1477 :button-face face 1479 :button-face face
1478 :button-prefix "" 1480 :button-prefix ""
1479 :button-suffix "" 1481 :button-suffix ""
1480 :help-echo "Change the state." 1482 :help-echo "Change the state."
1481 :format (if hidden "%t" "%[%t%]") 1483 :format (if hidden "%t" "%[%t%]")
1482 :tag (if lisp 1484 :tag (if (memq form '(lisp mismatch))
1483 (concat "(" magic ")") 1485 (concat "(" magic ")")
1484 (concat "[" magic "]"))) 1486 (concat "[" magic "]")))
1485 children) 1487 children)
1486 (insert " ")) 1488 (insert " "))
1487 (widget-put widget :children children))) 1489 (widget-put widget :children children)))
1601 (cond ((symbolp load) 1603 (cond ((symbolp load)
1602 (condition-case nil 1604 (condition-case nil
1603 (require load) 1605 (require load)
1604 (error nil))) 1606 (error nil)))
1605 ;; Don't reload a file already loaded. 1607 ;; Don't reload a file already loaded.
1606 ((member load preloaded-file-list)) 1608 ((and (boundp 'preloaded-file-list)
1609 (member load preloaded-file-list)))
1607 ((assoc load load-history)) 1610 ((assoc load load-history))
1608 ((assoc (locate-library load) load-history)) 1611 ((assoc (locate-library load) load-history))
1609 (t 1612 (t
1610 (condition-case nil 1613 (condition-case nil
1611 ;; Without this, we would load cus-edit recursively. 1614 ;; Without this, we would load cus-edit recursively.
1787 (setq state 'hidden))) 1790 (setq state 'hidden)))
1788 ;; If we don't know the state, see if we need to edit it in lisp form. 1791 ;; If we don't know the state, see if we need to edit it in lisp form.
1789 (when (eq state 'unknown) 1792 (when (eq state 'unknown)
1790 (unless (widget-apply conv :match value) 1793 (unless (widget-apply conv :match value)
1791 ;; (widget-apply (widget-convert type) :match value) 1794 ;; (widget-apply (widget-convert type) :match value)
1792 (setq form 'lisp))) 1795 (setq form 'mismatch)))
1793 ;; Now we can create the child widget. 1796 ;; Now we can create the child widget.
1794 (cond ((eq custom-buffer-style 'tree) 1797 (cond ((eq custom-buffer-style 'tree)
1795 (insert prefix (if last " `--- " " |--- ")) 1798 (insert prefix (if last " `--- " " |--- "))
1796 (push (widget-create-child-and-convert 1799 (push (widget-create-child-and-convert
1797 widget 'custom-browse-variable-tag) 1800 widget 'custom-browse-variable-tag)
1811 widget 'visibility 1814 widget 'visibility
1812 :help-echo "Show the value of this option." 1815 :help-echo "Show the value of this option."
1813 :action 'custom-toggle-parent 1816 :action 'custom-toggle-parent
1814 nil) 1817 nil)
1815 buttons)) 1818 buttons))
1816 ((eq form 'lisp) 1819 ((memq form '(lisp mismatch))
1817 ;; In lisp mode edit the saved value when possible. 1820 ;; In lisp mode edit the saved value when possible.
1818 (let* ((value (cond ((get symbol 'saved-value) 1821 (let* ((value (cond ((get symbol 'saved-value)
1819 (car (get symbol 'saved-value))) 1822 (car (get symbol 'saved-value)))
1820 ((get symbol 'standard-value) 1823 ((get symbol 'standard-value)
1821 (car (get symbol 'standard-value))) 1824 (car (get symbol 'standard-value)))
1954 (memq (widget-get widget :custom-state) 1957 (memq (widget-get widget :custom-state)
1955 '(modified set changed saved rogue))))) 1958 '(modified set changed saved rogue)))))
1956 ("---" ignore ignore) 1959 ("---" ignore ignore)
1957 ("Don't show as Lisp expression" custom-variable-edit 1960 ("Don't show as Lisp expression" custom-variable-edit
1958 (lambda (widget) 1961 (lambda (widget)
1959 (not (eq (widget-get widget :custom-form) 'edit)))) 1962 (eq (widget-get widget :custom-form) 'lisp)))
1960 ("Show as Lisp expression" custom-variable-edit-lisp 1963 ("Show as Lisp expression" custom-variable-edit-lisp
1961 (lambda (widget) 1964 (lambda (widget)
1962 (not (eq (widget-get widget :custom-form) 'lisp))))) 1965 (eq (widget-get widget :custom-form) 'edit))))
1963 "Alist of actions for the `custom-variable' widget. 1966 "Alist of actions for the `custom-variable' widget.
1964 Each entry has the form (NAME ACTION FILTER) where NAME is the name of 1967 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
1965 the menu entry, ACTION is the function to call on the widget when the 1968 the menu entry, ACTION is the function to call on the widget when the
1966 menu is selected, and FILTER is a predicate which takes a `custom-variable' 1969 menu is selected, and FILTER is a predicate which takes a `custom-variable'
1967 widget as an argument, and returns non-nil if ACTION is valid on that 1970 widget as an argument, and returns non-nil if ACTION is valid on that
2008 (cond ((eq state 'hidden) 2011 (cond ((eq state 'hidden)
2009 (error "Cannot set hidden variable.")) 2012 (error "Cannot set hidden variable."))
2010 ((setq val (widget-apply child :validate)) 2013 ((setq val (widget-apply child :validate))
2011 (goto-char (widget-get val :from)) 2014 (goto-char (widget-get val :from))
2012 (error "%s" (widget-get val :error))) 2015 (error "%s" (widget-get val :error)))
2013 ((eq form 'lisp) 2016 ((memq form '(lisp mismatch))
2014 (funcall set symbol (eval (setq val (widget-value child)))) 2017 (funcall set symbol (eval (setq val (widget-value child))))
2015 (put symbol 'customized-value (list val))) 2018 (put symbol 'customized-value (list val)))
2016 (t 2019 (t
2017 (funcall set symbol (setq val (widget-value child))) 2020 (funcall set symbol (setq val (widget-value child)))
2018 (put symbol 'customized-value (list (custom-quote val))))) 2021 (put symbol 'customized-value (list (custom-quote val)))))
2030 (cond ((eq state 'hidden) 2033 (cond ((eq state 'hidden)
2031 (error "Cannot set hidden variable.")) 2034 (error "Cannot set hidden variable."))
2032 ((setq val (widget-apply child :validate)) 2035 ((setq val (widget-apply child :validate))
2033 (goto-char (widget-get val :from)) 2036 (goto-char (widget-get val :from))
2034 (error "%s" (widget-get val :error))) 2037 (error "%s" (widget-get val :error)))
2035 ((eq form 'lisp) 2038 ((memq form '(lisp mismatch))
2036 (put symbol 'saved-value (list (widget-value child))) 2039 (put symbol 'saved-value (list (widget-value child)))
2037 (funcall set symbol (eval (widget-value child)))) 2040 (funcall set symbol (eval (widget-value child))))
2038 (t 2041 (t
2039 (put symbol 2042 (put symbol
2040 'saved-value (list (custom-quote (widget-value 2043 'saved-value (list (custom-quote (widget-value
2479 2482
2480 ;;; The `hook' Widget. 2483 ;;; The `hook' Widget.
2481 2484
2482 (define-widget 'hook 'list 2485 (define-widget 'hook 'list
2483 "A emacs lisp hook" 2486 "A emacs lisp hook"
2487 :value-to-internal (lambda (widget value)
2488 (if (symbolp value)
2489 (list value)
2490 value))
2491 :match (lambda (widget value)
2492 (or (symbolp value)
2493 (widget-editable-list-match widget value)))
2484 :convert-widget 'custom-hook-convert-widget 2494 :convert-widget 'custom-hook-convert-widget
2485 :tag "Hook") 2495 :tag "Hook")
2486 2496
2487 (defun custom-hook-convert-widget (widget) 2497 (defun custom-hook-convert-widget (widget)
2488 ;; Handle `:custom-options'. 2498 ;; Handle `:custom-options'.
2584 2594
2585 (defun custom-group-value-create (widget) 2595 (defun custom-group-value-create (widget)
2586 "Insert a customize group for WIDGET in the current buffer." 2596 "Insert a customize group for WIDGET in the current buffer."
2587 (let* ((state (widget-get widget :custom-state)) 2597 (let* ((state (widget-get widget :custom-state))
2588 (level (widget-get widget :custom-level)) 2598 (level (widget-get widget :custom-level))
2589 (indent (widget-get widget :indent)) 2599 ;; (indent (widget-get widget :indent))
2590 (prefix (widget-get widget :custom-prefix)) 2600 (prefix (widget-get widget :custom-prefix))
2591 (buttons (widget-get widget :buttons)) 2601 (buttons (widget-get widget :buttons))
2592 (tag (widget-get widget :tag)) 2602 (tag (widget-get widget :tag))
2593 (symbol (widget-value widget)) 2603 (symbol (widget-value widget))
2594 (members (custom-group-members symbol 2604 (members (custom-group-members symbol