소스 검색

Improve documentation and error handling with priorities

* lisp/org.el (org-default-priority):
(org-priority-start-cycle-with-default): Improve docstring.
(org-priority): Throw error when priority is out of range.

Patch by Michael Brand.
Carsten Dominik 14 년 전
부모
커밋
257ce858e7
1개의 변경된 파일16개의 추가작업 그리고 4개의 파일을 삭제
  1. 16 4
      lisp/org.el

+ 16 - 4
lisp/org.el

@@ -2488,14 +2488,20 @@ Must have a larger ASCII number than `org-highest-priority'."
 
 
 (defcustom org-default-priority ?B
 (defcustom org-default-priority ?B
   "The default priority of TODO items.
   "The default priority of TODO items.
-This is the priority an item get if no explicit priority is given."
+This is the priority an item gets if no explicit priority is given.
+When starting to cycle on an empty priority the first step in the cycle
+depends on `org-priority-start-cycle-with-default'.  The resulting first
+step priority must not exceed the range from `org-highest-priority' to
+`org-lowest-priority' which means that `org-default-priority' has to be
+in this range exclusive or inclusive the range boundaries."
   :group 'org-priorities
   :group 'org-priorities
   :type 'character)
   :type 'character)
 
 
 (defcustom org-priority-start-cycle-with-default t
 (defcustom org-priority-start-cycle-with-default t
   "Non-nil means start with default priority when starting to cycle.
   "Non-nil means start with default priority when starting to cycle.
 When this is nil, the first step in the cycle will be (depending on the
 When this is nil, the first step in the cycle will be (depending on the
-command used) one higher or lower that the default priority."
+command used) one higher or lower than the default priority.
+See also `org-default-priority'."
   :group 'org-priorities
   :group 'org-priorities
   :type 'boolean)
   :type 'boolean)
 
 
@@ -12306,12 +12312,18 @@ ACTION can be `set', `up', `down', or a character."
 	(if (and (not have) (eq last-command this-command))
 	(if (and (not have) (eq last-command this-command))
 	    (setq new org-lowest-priority)
 	    (setq new org-lowest-priority)
 	  (setq new (if (and org-priority-start-cycle-with-default (not have))
 	  (setq new (if (and org-priority-start-cycle-with-default (not have))
-			org-default-priority (1- current)))))
+			org-default-priority (1- current)))
+	  (when (< (upcase new) org-highest-priority)
+	    (error
+	     "See `org-default-priority' for range limit exceeded here"))))
        ((eq action 'down)
        ((eq action 'down)
 	(if (and (not have) (eq last-command this-command))
 	(if (and (not have) (eq last-command this-command))
 	    (setq new org-highest-priority)
 	    (setq new org-highest-priority)
 	  (setq new (if (and org-priority-start-cycle-with-default (not have))
 	  (setq new (if (and org-priority-start-cycle-with-default (not have))
-			org-default-priority (1+ current)))))
+			org-default-priority (1+ current)))
+	  (when (> (upcase new) org-lowest-priority)
+	    (error
+	     "See `org-default-priority' for range limit exceeded here"))))
        (t (error "Invalid action")))
        (t (error "Invalid action")))
       (if (or (< (upcase new) org-highest-priority)
       (if (or (< (upcase new) org-highest-priority)
 	      (> (upcase new) org-lowest-priority))
 	      (> (upcase new) org-lowest-priority))