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

[mhc:02093] Re: patch for X-SC-Priority



野口です。

X-SC-Priority まわりを色々いじっていて思うところがありましたので、提案
いたします。

現在の使用では X-SC-Priority の値は 0〜100 の間で入力・設定するように
なっているようなのですが、粒度が細かすぎて私にはかえって使いにくく感じ
ました。また、summary での表示も設定値がそのまま見えてしまうのも直感的
にわかりにくいように思いました。

個人的には、 high, middle, low の3段階で設定・表示できれば十分でしたの
で、添付のように変更してみました。
(現状のmhc でも 0〜49=>low, 50〜79=>middle, 80〜=>highと3段階で face
を変えていると理解しています)

変数 mhc-summary-display-priority-schema を以下のように設定することで、
設定・表示方法を変更します

 value        → 値をそのまま設定・表示 (これまで通り,デフォルト値)
 three-level → High, Middle, Low の3段階で設定・表示
 nine-level   → A1,A2,A3,B1,B2,B3,C1,C2,C3の9段階で設定・表示


添付分には、[mhc:02090]と[mhc:02092]で提案した patch も含まれております。

以上、ご検討いただければ幸いです。


なお仕様は、iCalendar の RFC (http://www.ietf.org/rfc/rfc2445.txt) の下記
部分を参考にしています。

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
4.8.1.9 Priority

   Property Name: PRIORITY

   Purpose: The property defines the relative priority for a calendar
   component.

   Value Type: INTEGER

   Property Parameters: Non-standard property parameters can be
   specified on this property.

   Conformance: The property can be specified in a "VEVENT" or "VTODO"
   calendar component.

   Description: The priority is specified as an integer in the range
   zero to nine. A value of zero (US-ASCII decimal 48) specifies an
   undefined priority. A value of one (US-ASCII decimal 49) is the
   highest priority. A value of two (US-ASCII decimal 50) is the
   second highest priority. Subsequent numbers specify a decreasing
   ordinal priority. A value of nine (US-ASCII decimal 58) is the
   lowest priority.

   A CUA with a three-level priority scheme of "HIGH", "MEDIUM" and
   "LOW" is mapped into this property such that a property value in
   the range of one (US-ASCII decimal 49) to four (US-ASCII decimal
   52) specifies "HIGH" priority. A value of five (US-ASCII decimal
   53) is the normal or "MEDIUM" priority. A value in the range of six
   (US- ASCII decimal 54) to nine (US-ASCII decimal 58) is "LOW"
   priority.

   A CUA with a priority schema of "A1", "A2", "A3", "B1", "B2", ...,
   "C3" is mapped into this property such that a property value of one
   (US-ASCII decimal 49) specifies "A1", a property value of two (US-
   ASCII decimal 50) specifies "A2", a property value of three
   (US-ASCII decimal 51) specifies "A3", and so forth up to a property
   value of 9 (US-ASCII decimal 58) specifies "C3".

   Other integer values are reserved for future use.

   Within a "VEVENT" calendar component, this property specifies a
   priority for the event. This property may be useful when more than
   one event is scheduled for a given time period.

   Within a "VTODO" calendar component, this property specified a
   priority for the to-do. This property is useful in prioritizing
   multiple action items for a given time period.

   Format Definition: The property is specified by the following
   notation:

     priority   = "PRIORITY" prioparam ":" privalue CRLF
     ;Default is zero

     prioparam  = *(";" xparam)

     privalue   = integer       ;Must be in the range [0..9]
        ; All other values are reserved for future use

   The following is an example of a property with the highest
   priority:

     PRIORITY:1

   The following is an example of a property with a next highest
   priority:

     PRIORITY:2

   Example: The following is an example of a property with no
   priority.
   This is equivalent to not specifying the "PRIORITY" property:

     PRIORITY:0
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

diff -c /tmp/mhc/emacs/mhc-minibuf.el mhc/mhc-minibuf.el
*** /tmp/mhc/emacs/mhc-minibuf.el	Wed Sep  8 18:12:10 2004
--- mhc/mhc-minibuf.el	Sun Apr 10 22:56:43 2005
***************
*** 333,338 ****
--- 333,389 ----
  	(beep)))))
  
  
+ (defvar mhc-priority-hist nil)
+ (defun mhc-input-priority (&optional prompt default)
+   (interactive)
+   (let (pri)
+     (catch 'ok
+       (while t
+ 	(setq pri (read-from-minibuffer 
+ 		   (concat (or prompt "Priority: ") 
+ ;			   "(from 0 to 100, or none) ")
+ 			   (cond
+ 			    ((eq mhc-summary-display-priority-schema 'three-level)
+ 			     "([Hh]igh, [Mm]iddle, [Ll]ow) ")
+ 			    ((eq mhc-summary-display-priority-schema 'nine-level)
+ 			     "(a1-3, b1-3, c1-3) ")
+ 			    (t
+ 			     "(from 0 to 100, or none) ")))
+ 		   (or default "")
+ 		   nil nil mhc-priority-hist 0))
+ 	(message pri)
+ 	(cond 
+ 	 ((string-match "^[0-9]+" pri)
+ 	  (throw 'ok (string-to-number pri)))
+ 	 ((string= "" pri)
+ 	  (throw 'ok nil))
+ 	 ((string-match "^[Hh]" pri)
+ 	  (throw 'ok 80))
+ 	 ((string-match "^[Mm]" pri)
+ 	  (throw 'ok 50))
+ 	 ((string-match "^[Ll]" pri)
+ 	  (throw 'ok 1))
+ 	 ((string-match "^[Aa]1" pri)
+ 	  (throw 'ok 90))
+ 	 ((string-match "^[Aa]2" pri)
+ 	  (throw 'ok 80))
+ 	 ((string-match "^[Aa]3" pri)
+ 	  (throw 'ok 70))
+ 	 ((string-match "^[Bb]1" pri)
+ 	  (throw 'ok 60))
+ 	 ((string-match "^[Bb]2" pri)
+ 	  (throw 'ok 50))
+ 	 ((string-match "^[Bb]3" pri)
+ 	  (throw 'ok 40))
+ 	 ((string-match "^[Cc]1" pri)
+ 	  (throw 'ok 30))
+ 	 ((string-match "^[Cc]2" pri)
+ 	  (throw 'ok 20))
+ 	 ((string-match "^[Cc]3" pri)
+ 	  (throw 'ok 1))
+ 	 (t
+ 	  (beep)))))))
+ 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; input x-sc- schedule data from minibuffer.
diff -c /tmp/mhc/emacs/mhc-summary.el mhc/mhc-summary.el
*** /tmp/mhc/emacs/mhc-summary.el	Thu Oct  7 19:06:35 2004
--- mhc/mhc-summary.el	Sun Apr 10 23:07:11 2005
***************
*** 277,282 ****
--- 277,289 ----
      (gnus-group-mode   . mhc-gnus)
      (gnus-summary-mode . mhc-gnus)))
  
+ (defcustom mhc-summary-display-priority-schema 'value
+   "*Valueable to set your favorite displaying priority SCHEMA."
+   :group 'mhc
+   :type '(radio (const :tag "Value" value)
+ 		(const :tag "Three-level" three-level)
+ 		(const :tag "Nine-level" nine-level)))
+ 
  ;; Internal Variables which are bound while inserting line:
  (defvar mhc-tmp-day-face nil "a face for the day.")
  (defvar mhc-tmp-dayinfo  nil "a dayinfo for the day.")
***************
*** 327,333 ****
  	(if (and (mhc-use-icon-p) (mhc-icon-exists-p "conflict"))
  	    (list "conflict") 'mhc-summary-face-conflict))
      (?p (if mhc-tmp-priority
! 	    (format "[%d]" mhc-tmp-priority))
  	'face (cond 
  	       ((null mhc-tmp-priority) nil)
  	       ((>= mhc-tmp-priority 80) 'mhc-summary-face-sunday)
--- 334,358 ----
  	(if (and (mhc-use-icon-p) (mhc-icon-exists-p "conflict"))
  	    (list "conflict") 'mhc-summary-face-conflict))
      (?p (if mhc-tmp-priority
! 	    (cond
! 	     ((eq mhc-summary-display-priority-schema 'three-level)
! 	      (cond
! 	       ((>= mhc-tmp-priority 80) (format "[HIGH] "))
! 	       ((>= mhc-tmp-priority 50) (format "[MIDDLE] "))
! 	       (t                        (format "[LOW] "))))
! 	     ((eq mhc-summary-display-priority-schema 'nine-level)
! 	      (cond 
! 	       ((>= mhc-tmp-priority 90) (format "[A1] "))
! 	       ((>= mhc-tmp-priority 80) (format "[A2] "))
! 	       ((>= mhc-tmp-priority 70) (format "[A3] "))
! 	       ((>= mhc-tmp-priority 60) (format "[B1] "))
! 	       ((>= mhc-tmp-priority 50) (format "[B2] "))
! 	       ((>= mhc-tmp-priority 40) (format "[B3] "))
! 	       ((>= mhc-tmp-priority 30) (format "[C1] "))
! 	       ((>= mhc-tmp-priority 20) (format "[C2] "))
! 	       (t                        (format "[C3] "))))
! 	     (t
! 	      (format "[%d] " mhc-tmp-priority))))
  	'face (cond 
  	       ((null mhc-tmp-priority) nil)
  	       ((>= mhc-tmp-priority 80) 'mhc-summary-face-sunday)
***************
*** 397,404 ****
      (?l (mhc-summary/line-location-string)
  	'face 'mhc-summary-face-location)
      (?p (if mhc-tmp-priority
! 	    (format "%5s" (format "[%d]" mhc-tmp-priority))
! 	  "     ")
  	'face (cond 
  	       ((null mhc-tmp-priority) nil)
  	       ((>= mhc-tmp-priority 80) 'mhc-summary-face-sunday)
--- 422,447 ----
      (?l (mhc-summary/line-location-string)
  	'face 'mhc-summary-face-location)
      (?p (if mhc-tmp-priority
! 	    (cond
! 	     ((eq mhc-summary-display-priority-schema 'three-level)
! 	      (cond
! 	       ((>= mhc-tmp-priority 80) (format "%9s" "[HIGH] "))
! 	       ((>= mhc-tmp-priority 50) (format "%9s" "[MIDDLE] "))
! 	       (t                        (format "%9s" "[LOW] "))))
! 	     ((eq mhc-summary-display-priority-schema 'nine-level)
! 	      (cond 
! 	       ((>= mhc-tmp-priority 90) (format "%9s" "[A1] "))
! 	       ((>= mhc-tmp-priority 80) (format "%9s" "[A2] "))
! 	       ((>= mhc-tmp-priority 70) (format "%9s" "[A3] "))
! 	       ((>= mhc-tmp-priority 60) (format "%9s" "[B1] "))
! 	       ((>= mhc-tmp-priority 50) (format "%9s" "[B2] "))
! 	       ((>= mhc-tmp-priority 40) (format "%9s" "[B3] "))
! 	       ((>= mhc-tmp-priority 30) (format "%9s" "[C1] "))
! 	       ((>= mhc-tmp-priority 20) (format "%9s" "[C2] "))
! 	       (t                        (format "%9s" "[C3] "))))
! 	     (t
! 	      (format "%9s" (format "[%d]" mhc-tmp-priority))))
! 	  "        ")
  	'face (cond 
  	       ((null mhc-tmp-priority) nil)
  	       ((>= mhc-tmp-priority 80) 'mhc-summary-face-sunday)
diff -c /tmp/mhc/emacs/mhc-vars.el mhc/mhc-vars.el
*** /tmp/mhc/emacs/mhc-vars.el	Mon Oct 13 15:46:23 2003
--- mhc/mhc-vars.el	Sun Apr 10 12:46:59 2005
***************
*** 132,137 ****
--- 132,142 ----
    :group 'mhc
    :type 'boolean)
  
+ (defcustom mhc-ask-priority nil
+   "*If non-nil value, ask the priority value in making draft."
+   :group 'mhc
+   :type 'boolean)
+ 
  (provide 'mhc-vars)
  
  ;;; Copyright Notice:
diff -c /tmp/mhc/emacs/mhc.el mhc/mhc.el
*** /tmp/mhc/emacs/mhc.el	Fri Jan 14 21:07:54 2005
--- mhc/mhc.el	Sun Apr 10 22:38:09 2005
***************
*** 551,557 ****
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; 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)
--- 551,558 ----
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; import, edit, delete, modify
  
! (defcustom mhc-input-sequences 
!   '(date time subject location category alarm priority)
    "*Sequence of the inputs."
    :group 'mhc
    :type '(repeat (choice (const :tag "Date" date)
***************
*** 559,565 ****
  			 (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.
--- 560,572 ----
  			 (const :tag "Subject" subject)
  			 (const :tag "Location" location)
  			 (const :tag "Category" category)
! 			 (const :tag "Alarm" alarm)
! 			 (const :tag "Priority" priority))))
! 
! (defcustom mhc-do-register-xsc-next nil
!   ""
!   :group 'mhc
!   :type 'boolean)
  
  (defun mhc-edit (&optional import-buffer)
    "Edit a new schedule.
***************
*** 572,578 ****
    (let ((draft-buffer (generate-new-buffer mhc-draft-buffer-name))
  	(current-date (or (mhc-current-date) (mhc-calendar-get-date)))
  	(succeed t)
! 	msgp date time subject location category priority alarm)
      (and (interactive-p)
  	 (mhc-window-push))
      (set-buffer draft-buffer)
--- 579,586 ----
    (let ((draft-buffer (generate-new-buffer mhc-draft-buffer-name))
  	(current-date (or (mhc-current-date) (mhc-calendar-get-date)))
  	(succeed t)
! 	msgp date time subject location category priority alarm
! 	(next-entry-list ()))
      (and (interactive-p)
  	 (mhc-window-push))
      (set-buffer draft-buffer)
***************
*** 651,659 ****
  			    (setq alarm
  				  (mhc-input-alarm
  				   "Alarm: "
! 				   mhc-default-alarm))))))
  		    ;;
! 		    (setq priority (mhc-schedule-priority schedule)))
  		;; Answer was no.
  		(message "") ; flush minibuffer.
  		(and (interactive-p)
--- 659,694 ----
  			    (setq alarm
  				  (mhc-input-alarm
  				   "Alarm: "
! 				   mhc-default-alarm))))
! 		       ;; input priority
! 		       ((eq input 'priority)
! 			(if mhc-ask-priority
! 			    (setq priority 
! 				  (mhc-input-priority
! 				   "Priority: "
! 				   nil))))))
! 		    (if mhc-do-register-xsc-next
! 			(while (y-or-n-p 
! 				"More Schedule (date,time,location)? ")
! 			  (let (date-tmp time-tmp loc-tmp)
! 			    (setq date-tmp
! 				  (mhc-input-day "Date: "
! 						 current-date
! 						 (mhc-guess-date)))
! 			    (setq time-tmp
! 				  (mhc-input-time "Time: "
! 						  (mhc-schedule-time-as-string
! 						   schedule)
! 						  (mhc-guess-time
! 						   (mhc-minibuf-candidate-nth-begin))))
! 			    (setq loc-tmp
! 				 (mhc-input-location "Location: "
! 				  (mhc-schedule-location schedule)))
! 			    (setq next-entry-list 
! 				  (cons (list date-tmp time-tmp loc-tmp) next-entry-list)))))
  		    ;;
! ;		    (setq priority (mhc-schedule-priority schedule))
! 		    )
  		;; Answer was no.
  		(message "") ; flush minibuffer.
  		(and (interactive-p)
***************
*** 678,684 ****
  		(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)
--- 713,731 ----
  		(setq category (mhc-input-category "Category: ")))
  	       ((eq input 'alarm)
  		(if mhc-ask-alarm
! 		    (setq alarm (mhc-input-alarm "Alarm: " mhc-default-alarm))))
! 	       ((eq input 'priority)
! 		(if mhc-ask-priority
! 		    (setq priority (mhc-input-priority "Priority: "))))))
! 	    (if mhc-do-register-xsc-next
! 		(while (y-or-n-p "More Schedule (date,time,location)? ")
! 		  (let (date-tmp time-tmp loc-tmp)
! 		    (progn 
! 		      (setq date-tmp (mhc-input-day "Date: " current-date))
! 		      (setq time-tmp (mhc-input-time "Time: "))
! 		      (setq loc-tmp (mhc-input-location "Location: "))
! 		      (setq next-entry-list (cons (list date-tmp time-tmp loc-tmp) next-entry-list))))))
! 	    ))
        ;; Quit.
        (quit
         (and (interactive-p)
***************
*** 723,732 ****
  			 (if begin (mhc-time-to-string begin) "")
  			 (if end (concat "-" (mhc-time-to-string end)) "")))
  		    "")
  		  "\nX-SC-Category: "
  		  (mapconcat (function capitalize) category " ")
  		  "\nX-SC-Priority: " (if priority
! 					  (number-to-string priority)
  					"")
  		  "\nX-SC-Cond: "
  		  "\nX-SC-Duration: "
--- 770,808 ----
  			 (if begin (mhc-time-to-string begin) "")
  			 (if end (concat "-" (mhc-time-to-string end)) "")))
  		    "")
+ 		  )
+ 	  (if next-entry-list
+ 	      (let (date time location)
+ 		(while next-entry-list
+ 		  (setq date (car (car next-entry-list)))
+ 		  (setq time (car (cdr (car next-entry-list))))
+ 		  (setq location (car (cdr (cdr (car next-entry-list)))))
+ 		  (insert 
+ 		   "\nX-SC-Next: "
+ 		   "\nX-SC-Location: " location
+ 		   "\nX-SC-Day: "
+ 		   (mapconcat
+ 		    (lambda (day)
+ 		      (mhc-date-format day "%04d%02d%02d" yy mm dd))
+ 		    date " ")
+ 		   "\nX-SC-Time: "
+ 		   (if time
+ 		       (let ((begin (car time))
+ 			     (end (nth 1 time)))
+ 			 (concat
+ 			  (if begin (mhc-time-to-string begin) "")
+ 			  (if end (concat "-" (mhc-time-to-string end)) "")))
+ 		     "")
+ 		   )
+ 		  (setq next-entry-list (cdr next-entry-list)))
+ 	      ))
+ 	  (insert
  		  "\nX-SC-Category: "
  		  (mapconcat (function capitalize) category " ")
  		  "\nX-SC-Priority: " (if priority
! 					  (if (stringp priority)
! 					      priority
! 					    (number-to-string priority))
  					"")
  		  "\nX-SC-Cond: "
  		  "\nX-SC-Duration: "