diff lisp/custom/wid-edit.el @ 159:3bb7ccffb0c0 r20-3b6

Import from CVS: tag r20-3b6
author cvs
date Mon, 13 Aug 2007 09:41:43 +0200
parents 6b37e6ddd302
children 28f395d8dc7a
line wrap: on
line diff
--- a/lisp/custom/wid-edit.el	Mon Aug 13 09:40:48 2007 +0200
+++ b/lisp/custom/wid-edit.el	Mon Aug 13 09:41:43 2007 +0200
@@ -2666,6 +2666,41 @@
   :prompt-history 'widget-variable-prompt-value-history
   :tag "Variable")
 
+(when (featurep 'mule)
+  (defvar widget-coding-system-prompt-value-history nil
+    "History of input to `widget-coding-system-prompt-value'.")
+  
+  (define-widget 'coding-system 'symbol
+    "A MULE coding-system."
+    :format "%{%t%}: %v"
+    :tag "Coding system"
+    :prompt-history 'widget-coding-system-prompt-value-history
+    :prompt-value 'widget-coding-system-prompt-value
+    :action 'widget-coding-system-action)
+  
+  (defun widget-coding-system-prompt-value (widget prompt value unbound)
+    ;; Read coding-system from minibuffer.
+    (intern
+     (completing-read (format "%s (default %s) " prompt value)
+		      (mapcar (function
+			       (lambda (sym)
+				 (list (symbol-name sym))
+				 ))
+			      (coding-system-list)))))
+
+  (defun widget-coding-system-action (widget &optional event)
+    ;; Read a file name from the minibuffer.
+    (let ((answer
+	   (widget-coding-system-prompt-value
+	    widget
+	    (widget-apply widget :menu-tag-get)
+	    (widget-value widget)
+	    t)))
+      (widget-value-set widget answer)
+      (widget-apply widget :notify widget event)
+      (widget-setup)))
+  )
+
 (define-widget 'sexp 'editable-field
   "An arbitrary lisp expression."
   :tag "Lisp expression"