[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mhc:02010] Re: import 時の入力順序について



From: NOGUCHI Yusuke <nogunogu@xxxxxxxxxxxxxxxxx> さん曰く
Subject: [mhc:02009] import 時の入力順序について
Message-ID: <20050114.135326.68541333.nogunogu@xxxxxxxxxxxxxxxxx>
Date: Fri, 14 Jan 2005 13:53:26 +0900 (JST)

> 多分に「好みの問題」と言われてしまいそうですが...

はい、完璧に「好みの問題」ですね :-)

だけど、こういうインタフェースの部分は「自分好み」が一番ですから、
誰でも OK になるように変更可能にする、が正解だと思います。

>   [data] -> [time] -> [location] -> [subject] -> [catetory] -> [alarm]
> とするようにしてみました。

(setq mhc-input-sequences '(date time location subject category alarm))
とすると、そうなります。

# ちょっと雑かなぁとも思うので、次回の現実逃避で見直しておきます。

-- 
白井秀行 (mailto:shirai@xxxxxxxxxxxxx)


Index: mhc.el
===================================================================
RCS file: /cvsroot/mhc/emacs/mhc.el,v
retrieving revision 1.87
diff -u -u -r1.87 mhc.el
--- mhc.el	7 Oct 2004 10:38:00 -0000	1.87
+++ mhc.el	14 Jan 2005 05:53:43 -0000
@@ -550,6 +550,17 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; import, edit, delete, modify
+
+(defcustom mhc-input-sequences '(date time subject location category alarm)
+  "*Sequence of the inputs."
+  :group 'mhc
+  :type '(repeat (choice (const :tag "Date" date)
+			 (const :tag "Time" time)
+			 (const :tag "Subject" subject)
+			 (const :tag "Location" location)
+			 (const :tag "Category" category)
+			 (const :tag "Alarm" alarm))))
+
 (defun mhc-edit (&optional import-buffer)
   "Edit a new schedule.
 If optional argument IMPORT-BUFFER is specified, import its content.
@@ -591,45 +602,56 @@
 					  (cdr import-buffer)
 					import-buffer))
 				     (mhc-parse-buffer)))
-			 (schedule (car (mhc-record-schedules original))))
-		    ;; input date
-		    (setq date
-			  (mhc-input-day "Date: "
-					 current-date
-					 (mhc-guess-date)))
-		    ;; input time
-		    (setq time
-			  (mhc-input-time "Time: "
-					  (mhc-schedule-time-as-string
-					   schedule)
-					  (mhc-guess-time
-					   (mhc-minibuf-candidate-nth-begin))))
-		    ;; input subject
-		    (setq subject
-			  (mhc-input-subject
-			   "Subject: "
-			   (mhc-misc-sub
-			    (or (mhc-record-subject original)
-				(mhc-header-narrowing
-				  (mhc-header-get-value "subject")))
-			    "^\\(Re:\\)? *\\(\\[[^\]]+\\]\\)? *"
-			    "")))
-		    ;; input location
-		    (setq location
-			  (mhc-input-location
-			   "Location: "
-			   (mhc-schedule-location schedule)))
-		    ;; input category
-		    (setq category
-			  (mhc-input-category
-			   "Category: "
-			   (mhc-schedule-categories-as-string schedule)))
-		    ;; input alarm
-		    (if mhc-ask-alarm
-			(setq alarm
-			      (mhc-input-alarm
-			       "Alarm: "
-			       mhc-default-alarm)))
+			 (schedule (car (mhc-record-schedules original)))
+			 (inputs (copy-sequence mhc-input-sequences))
+			 input)
+		    (while (setq input (car inputs))
+		      (setq inputs (delq input inputs))
+		      (cond
+		       ((eq input 'date)
+			;; input date
+			(setq date
+			      (mhc-input-day "Date: "
+					     current-date
+					     (mhc-guess-date))))
+		       ((eq input 'time)
+			;; input time
+			(setq time
+			      (mhc-input-time "Time: "
+					      (mhc-schedule-time-as-string
+					       schedule)
+					      (mhc-guess-time
+					       (mhc-minibuf-candidate-nth-begin)))))
+		       ((eq input 'subject)
+			;; input subject
+			(setq subject
+			      (mhc-input-subject
+			       "Subject: "
+			       (mhc-misc-sub
+				(or (mhc-record-subject original)
+				    (mhc-header-narrowing
+				      (mhc-header-get-value "subject")))
+				"^\\(Re:\\)? *\\(\\[[^\]]+\\]\\)? *"
+				""))))
+		       ((eq input 'location)
+			;; input location
+			(setq location
+			      (mhc-input-location
+			       "Location: "
+			       (mhc-schedule-location schedule))))
+		       ((eq input 'category)
+			;; input category
+			(setq category
+			      (mhc-input-category
+			       "Category: "
+			       (mhc-schedule-categories-as-string schedule))))
+		       ;; input alarm
+		       ((eq input 'alarm)
+			(if mhc-ask-alarm
+			    (setq alarm
+				  (mhc-input-alarm
+				   "Alarm: "
+				   mhc-default-alarm))))))
 		    ;;
 		    (setq priority (mhc-schedule-priority schedule)))
 		;; Answer was no.
@@ -639,13 +661,24 @@
 		(setq succeed nil)
 		(kill-buffer draft-buffer)))
 	  ;; No import (it succeeds).
-	  (setq date (mhc-input-day "Date: " current-date)
-		time (mhc-input-time "Time: ")
-		subject (mhc-input-subject "Subject: ")
-		location (mhc-input-location "Location: ")
-		category (mhc-input-category "Category: "))
-	  (if mhc-ask-alarm
-	      (setq alarm (mhc-input-alarm "Alarm: " mhc-default-alarm))))
+	  (let ((inputs (copy-sequence mhc-input-sequences))
+		input)
+	    (while (setq input (car inputs))
+	      (setq inputs (delq input inputs))
+	      (cond
+	       ((eq input 'date)
+		(setq date (mhc-input-day "Date: " current-date)))
+	       ((eq input 'time)
+		(setq time (mhc-input-time "Time: ")))
+	       ((eq input 'subject)
+		(setq subject (mhc-input-subject "Subject: ")))
+	       ((eq input 'location)
+		(setq location (mhc-input-location "Location: ")))
+	       ((eq input 'category)
+		(setq category (mhc-input-category "Category: ")))
+	       ((eq input 'alarm)
+		(if mhc-ask-alarm
+		    (setq alarm (mhc-input-alarm "Alarm: " mhc-default-alarm))))))))
       ;; Quit.
       (quit
        (and (interactive-p)