aboutsummaryrefslogtreecommitdiff
path: root/pearl.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-02 20:27:38 -0500
committerCraig Jennings <c@cjennings.net>2026-06-02 20:27:38 -0500
commitfac5c2973b4d6e028c203a4bad0ba104178e1349 (patch)
tree4ba944ac46d17c45fd66375a71406b447ea174f2 /pearl.el
parent9a145f30ff49a0141f342ea775e8f1a5b5899ae6 (diff)
downloadpearl-fac5c2973b4d6e028c203a4bad0ba104178e1349.tar.gz
pearl-fac5c2973b4d6e028c203a4bad0ba104178e1349.zip
fix(priority): error on an out-of-range cookie instead of silent None
pearl--priority-number-at-point matched only [#A-D], so a cookie outside that range (a hand-typed [#E], say) didn't match and fell through to 0 (None). On save that silently pushed None to Linear and cleared the issue's priority, with no error and no sign anything was wrong. It now matches any [#A-Z] and, when the letter isn't A-D, signals a user-error naming the valid range (A=Urgent, B=High, C=Medium, D=Low, or no cookie for None), so a stray cookie surfaces before any push rather than quietly wiping the priority. Linear has exactly five priorities, so A-D plus no-cookie is the whole range.
Diffstat (limited to 'pearl.el')
-rw-r--r--pearl.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/pearl.el b/pearl.el
index 58e5bd3..ae02f1f 100644
--- a/pearl.el
+++ b/pearl.el
@@ -5042,12 +5042,22 @@ decided later."
(defun pearl--priority-number-at-point ()
"Return the Linear priority (0-4) implied by the heading cookie at point.
-A/B/C/D map to Urgent/High/Medium/Low (1-4); no cookie is None (0)."
+A/B/C/D map to Urgent/High/Medium/Low (1-4); no cookie is None (0). A cookie
+present but outside A-D (e.g. \\='[#E]\\=') is not a Linear priority: it signals
+a `user-error' rather than silently mapping to None, which would clear the
+issue's priority on save. Linear has exactly five priorities, so A-D plus
+no-cookie is the whole range."
(save-excursion
(org-back-to-heading t)
(let ((case-fold-search nil))
- (if (re-search-forward "\\[#\\([A-D]\\)\\]" (line-end-position) t)
- (cdr (assoc (match-string 1) '(("A" . 1) ("B" . 2) ("C" . 3) ("D" . 4))))
+ (if (re-search-forward "\\[#\\([A-Z]\\)\\]" (line-end-position) t)
+ (let ((letter (match-string 1)))
+ (or (cdr (assoc letter '(("A" . 1) ("B" . 2) ("C" . 3) ("D" . 4))))
+ (user-error
+ (concat "Priority cookie [#%s] is not a Linear priority; "
+ "use A-D (A=Urgent, B=High, C=Medium, D=Low) "
+ "or no cookie for None")
+ letter)))
0))))
(defun pearl--priority-dirty-p ()