From fac5c2973b4d6e028c203a4bad0ba104178e1349 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 2 Jun 2026 20:27:38 -0500 Subject: 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. --- pearl.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pearl.el') 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 () -- cgit v1.2.3