diff lisp/custom/custom-edit.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 859a2309aef8
children 4103f0995bd7
line wrap: on
line diff
--- a/lisp/custom/custom-edit.el	Mon Aug 13 08:50:06 2007 +0200
+++ b/lisp/custom/custom-edit.el	Mon Aug 13 08:50:29 2007 +0200
@@ -1,10 +1,10 @@
 ;;; custom-edit.el --- Tools for customization Emacs.
 ;;
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: help, faces
-;; Version: 1.30
+;; Version: 1.40
 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
 
 ;;; Commentary:
@@ -156,6 +156,7 @@
   (setq major-mode 'custom-mode
 	mode-name "Custom")
   (use-local-map custom-mode-map)
+  (easy-menu-add custom-mode-menu)
   (make-local-variable 'custom-options)
   (run-hooks 'custom-mode-hook))
 
@@ -361,9 +362,15 @@
   (widget-insert " ")
   (widget-create 'push-button
 		 :tag "Reset"
-		 :help-echo "Push me to undo all modifications.."
+		 :help-echo "Push me to undo all modifications."
 		 :action (lambda (widget &optional event)
 			   (custom-reset event)))
+  (widget-insert " ")
+  (widget-create 'push-button
+		 :tag "Done"
+		 :help-echo "Push me to bury the buffer."
+		 :action (lambda (widget &optional event)
+			   (bury-buffer)))
   (widget-insert "\n")
   (widget-setup))
 
@@ -700,8 +707,14 @@
 
 (defun custom-redraw (widget)
   "Redraw WIDGET with current settings."
-  (widget-value-set widget (widget-value widget))
-  (custom-redraw-magic widget))
+  (let ((pos (point))
+	(from (marker-position (widget-get widget :from)))
+	(to (marker-position (widget-get widget :to))))
+    (save-excursion
+      (widget-value-set widget (widget-value widget))
+      (custom-redraw-magic widget))
+    (when (and (>= pos from) (<= pos to))
+      (goto-char pos))))
 
 (defun custom-redraw-magic (widget)
   "Redraw WIDGET state with current settings."
@@ -860,20 +873,20 @@
 		       (if (condition-case nil
 			       (equal value (eval (car tmp)))
 			     (error nil))
-			   'saved
-			 'set))
+			   'set
+			 'changed))
 		      ((setq tmp (get symbol 'saved-value))
 		       (if (condition-case nil
 			       (equal value (eval (car tmp)))
 			     (error nil))
 			   'saved
-			 'set))
+			 'changed))
 		      ((setq tmp (get symbol 'factory-value))
 		       (if (condition-case nil
 			       (equal value (eval (car tmp)))
 			     (error nil))
 			   'factory
-			 'set))
+			 'changed))
 		      (t 'rogue))))
     (widget-put widget :custom-state state)))
 
@@ -898,7 +911,8 @@
 	(widget-put widget :custom-state 'unknown)
 	(custom-redraw widget))
     (let* ((completion-ignore-case t)
-	   (answer (widget-choose (symbol-name (widget-get widget :value))
+	   (answer (widget-choose (capitalize
+				   (symbol-name (widget-get widget :value)))
 				  custom-variable-menu
 				  event)))
       (if answer
@@ -932,7 +946,7 @@
 	   (set symbol (eval (setq val (widget-value child))))
 	   (put symbol 'customized-value (list val)))
 	  (t
-	   (set symbol (widget-value child))
+	   (set symbol (setq val (widget-value child)))
 	   (put symbol 'customized-value (list (custom-quote val)))))
     (custom-variable-state-set widget)
     (custom-redraw-magic widget)))
@@ -1139,7 +1153,7 @@
 	(custom-redraw widget))
     (let* ((completion-ignore-case t)
 	   (symbol (widget-get widget :value))
-	   (answer (widget-choose (symbol-name symbol)
+	   (answer (widget-choose (capitalize (symbol-name symbol))
 				  custom-face-menu event)))
       (if answer
 	  (funcall answer widget)))))
@@ -1362,7 +1376,8 @@
 	(widget-put widget :custom-state 'unknown)
 	(custom-redraw widget))
     (let* ((completion-ignore-case t)
-	   (answer (widget-choose (symbol-name (widget-get widget :value))
+	   (answer (widget-choose (capitalize
+				   (symbol-name (widget-get widget :value)))
 				  custom-group-menu
 				  event)))
       (if answer