[Mew-dist 14874] mew-input-config でのチェック

KOIE Hidetaka ( 鯉江英隆 ) hide at example.com
2000年 11月 14日 (火) 14:46:24 JST


Configの入力をよくまちがえるので
強制チェックするようにしてみました。

━━━━━━━━━━━━━━ここから━━━━━━━━━━━━━━
--- mew-minibuf.el.~1~	Mon Oct  9 19:55:28 2000
+++ mew-minibuf.el	Tue Nov 14 14:35:51 2000
@@ -24,8 +24,9 @@ (if mew-input-map
   (define-key mew-input-map "\t"   'mew-input-complete)
 ;;  (define-key mew-input-map "\177" 'backward-delete-char)
 ;;  (define-key mew-input-map "\C-h" 'mew-complete-backscroll)
-  (define-key mew-input-map "\r"   'exit-minibuffer)
-  (define-key mew-input-map "\n"   'exit-minibuffer)
+  (define-key mew-input-map "\r"   'mew-exit-minibuffer)
+  (define-key mew-input-map "\n"   'mew-exit-minibuffer)
+  (define-key mew-input-map ","   'mew-input-comma)
   (define-key mew-input-map "\C-g" 'abort-recursive-edit)
   (define-key mew-input-map "\M-p" 'previous-history-element)
   (define-key mew-input-map "\M-n" 'next-history-element)
@@ -40,6 +41,26 @@ (defun mew-input-complete ()
   (if (and mew-input-complete-function (fboundp mew-input-complete-function))
       (funcall mew-input-complete-function)))
 
+(defvar mew-exit-minibuffer-function nil)
+
+(defun mew-exit-minibuffer ()
+  "Ensure the input meets a condition."
+  (interactive)
+  (if (or (not (and mew-exit-minibuffer-function
+                    (fboundp mew-exit-minibuffer-function)))
+          (funcall mew-exit-minibuffer-function))
+      (exit-minibuffer)))
+
+(defvar mew-input-comma-function nil)
+
+(defun mew-input-comma ()
+  "Ensure the input meets a condition."
+  (interactive)
+  (if (or (not (and mew-input-comma-function
+                    (fboundp mew-input-comma-function)))
+          (funcall mew-input-comma-function))
+      (insert last-command-event)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Mew original completion
@@ -339,15 +360,32 @@ (defun mew-input-type2 (prompt type-list
 ;;; Config
 ;;;
 
+(defun mew-check-config ()
+  (let* ((config (mew-buffer-substring (point-min) (point-max)))
+         (lst (mew-split config ?,)))
+    (setq err (catch 'nomatch
+                (while lst
+                  (if (not (member (car lst) mew-config-cases))
+                      (throw 'nomatch (car lst)))
+                  (setq lst (cdr lst)))))
+    (if err
+        (progn
+          (mew-temp-minibuffer-message (format " [No match: %s]" err))
+          nil)
+      t)))
+
 (defun mew-input-config (default msg)
   (let (config lst ret)
     (if (null default) (setq default mew-config-default))
     (mew-input-clear)
     (setq mew-input-complete-function (function mew-complete-config))
-    (setq config (read-from-minibuffer
-		  (format "%s config value (%s): " msg default)
-		  ""
-		  mew-input-map))
+    (let ((mew-exit-minibuffer-function (function mew-check-config))
+          (mew-input-comma-function (function mew-check-config)))
+      (setq config (read-from-minibuffer
+                    (format "%s config value (%s): " msg default)
+                    ""
+                    mew-input-map))
+      )
     (if (string= config "")
 	default
       (setq lst (mew-split config ?,))
━━━━━━━━━━━━━━ここまで━━━━━━━━━━━━━━

--
KOIE Hidetaka 鯉江英隆 <hide at example.com>



Mew-dist メーリングリストの案内