emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] extend doc strings of priority defcustoms
@ 2011-05-30 18:23 Michael Brand
  2011-05-30 21:10 ` Michael Brand
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Brand @ 2011-05-30 18:23 UTC (permalink / raw)
  To: Org Mode

* org.el (org-default-priority):
document dependency on org-priority-start-cycle-with-default
* org.el (org-priority-start-cycle-with-default):
document dependency on org-default-priority

TINYCHANGE
---
 lisp/org.el |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 498c606..a729440 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2488,14 +2488,18 @@ Must have a larger ASCII number than
`org-highest-priority'."

 (defcustom org-default-priority ?B
   "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.
+Required to be between `org-highest-priority' and `org-lowest-priority'
+if `org-priority-start-cycle-with-default' is non-nil, else it is not
+possible to start cycling on an empty tag."
   :group 'org-priorities
   :type 'character)

 (defcustom org-priority-start-cycle-with-default t
   "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
-command used) one higher or lower that the default priority."
+command used) one higher or lower than the default priority.
+If non-nil see also `org-default-priority'."
   :group 'org-priorities
   :type 'boolean)

-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] extend doc strings of priority defcustoms
  2011-05-30 18:23 [PATCH] extend doc strings of priority defcustoms Michael Brand
@ 2011-05-30 21:10 ` Michael Brand
  2011-05-31 17:52   ` Michael Brand
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Brand @ 2011-05-30 21:10 UTC (permalink / raw)
  To: Org Mode

In the meantime I understand better what happens. I rewrote the doc
strings and added an error message to avoid the wrong error "No
priority cookie found in line" for the case of org-default-priority
out of range. My previous patch is to be replaced by this one:

* org.el (org-default-priority): Document dependency on
org-priority-start-cycle-with-default.
(org-priority-start-cycle-with-default): Document dependency on
org-default-priority.
(org-priority): Error added for case of org-default-priority out of
range.
---
 lisp/org.el |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 498c606..241fa11 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2488,14 +2488,20 @@ Must have a larger ASCII number than
`org-highest-priority'."

 (defcustom org-default-priority ?B
   "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
   :type 'character)

 (defcustom org-priority-start-cycle-with-default t
   "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
-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
   :type 'boolean)

@@ -12306,12 +12312,18 @@ ACTION can be `set', `up', `down', or a character."
 	(if (and (not have) (eq last-command this-command))
 	    (setq new org-lowest-priority)
 	  (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)
 	(if (and (not have) (eq last-command this-command))
 	    (setq new org-highest-priority)
 	  (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")))
       (if (or (< (upcase new) org-highest-priority)
 	      (> (upcase new) org-lowest-priority))
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] extend doc strings of priority defcustoms
  2011-05-30 21:10 ` Michael Brand
@ 2011-05-31 17:52   ` Michael Brand
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Brand @ 2011-05-31 17:52 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

My most recent patch has been applied. Unfortunately it broke the wrap
around when cycling through priorities.

Now I have rewritten the "if" that I obviously did not understand
enough, have corrected the error message, have tested much better and
suggest this additional patch that should definitely improve the
situation.

Michael

[-- Attachment #2: 0001-Priorities-Fix-error-handling-and-improve-docstring.patch --]
[-- Type: application/octet-stream, Size: 3753 bytes --]

From d4db8cca6b9c3c36cedffe9d09ef8a278fb418c2 Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Tue, 31 May 2011 19:39:03 +0200
Subject: [PATCH] Priorities: Fix error handling and improve docstring

* lisp/org.el (org-default-priority): Improve docstring.
(org-priority): Cleanup and correction of throw error when priority is
out of range.
---
 lisp/org.el |   48 ++++++++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 9562b6e..f1c1d3c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2493,7 +2493,9 @@ 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."
+in this range exclusive or inclusive the range boundaries.  Else the
+first step refuses to set the default and the second will fall back
+to (depending on the command used) the highest or lowest priority."
   :group 'org-priorities
   :type 'character)
 
@@ -12288,8 +12290,7 @@ ACTION can be `set', `up', `down', or a character."
       (org-back-to-heading t)
       (if (looking-at org-priority-regexp)
 	  (setq current (string-to-char (match-string 2))
-		have t)
-	(setq current org-default-priority))
+		have t))
       (cond
        ((eq action 'remove)
 	(setq remove t new ?\ ))
@@ -12309,25 +12310,36 @@ ACTION can be `set', `up', `down', or a character."
 	       (error "Priority must be between `%c' and `%c'"
 		      org-highest-priority org-lowest-priority))))
        ((eq action 'up)
-	(if (and (not have) (eq last-command this-command))
-	    (setq new org-lowest-priority)
-	  (setq new (if (and org-priority-start-cycle-with-default (not have))
-			org-default-priority (1- current)))
-	  (when (< (upcase new) org-highest-priority)
-	    (error
-	     "See `org-default-priority' for range limit exceeded here"))))
+	(setq new (if have
+		      (1- current)  ; normal cycling
+		    ;; last priority was empty
+		    (if (eq last-command this-command)
+			org-lowest-priority  ; wrap around empty to lowest
+		      ;; default
+		      (if org-priority-start-cycle-with-default
+			  org-default-priority
+			(1- org-default-priority))))))
        ((eq action 'down)
-	(if (and (not have) (eq last-command this-command))
-	    (setq new org-highest-priority)
-	  (setq new (if (and org-priority-start-cycle-with-default (not have))
-			org-default-priority (1+ current)))
-	  (when (> (upcase new) org-lowest-priority)
-	    (error
-	     "See `org-default-priority' for range limit exceeded here"))))
+	(setq new (if have
+		      (1+ current)  ; normal cycling
+		    ;; last priority was empty
+		    (if (eq last-command this-command)
+			org-highest-priority  ; wrap around empty to highest
+		      ;; default
+		      (if org-priority-start-cycle-with-default
+			  org-default-priority
+			(1+ org-default-priority))))))
        (t (error "Invalid action")))
       (if (or (< (upcase new) org-highest-priority)
 	      (> (upcase new) org-lowest-priority))
-	  (setq remove t))
+	  (if (and (memq action '(up down))
+		   (not have) (not (eq last-command this-command)))
+              ;; `new' is from default priority
+	      (error
+	       "The default can not be set, see `org-default-priority' why")
+            ;; normal cycling: `new' is beyond highest/lowest priority
+            ;; and is wrapped around to the empty priority
+	    (setq remove t)))
       (setq news (format "%c" new))
       (if have
 	  (if remove
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-31 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-30 18:23 [PATCH] extend doc strings of priority defcustoms Michael Brand
2011-05-30 21:10 ` Michael Brand
2011-05-31 17:52   ` Michael Brand

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).