aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2025-08-29 10:55:21 +0200
committerMattias EngdegÄrd2025-08-29 10:55:21 +0200
commitbebba6be3da6544ec5d8051d74a976dcd52314ef (patch)
tree811033bd720557017ebdb3fee03702c88e08a3c2
parentbba28b744c0f3fda20d66d0a054917db2c0a2529 (diff)
downloademacs-bebba6be3da6544ec5d8051d74a976dcd52314ef.tar.gz
emacs-bebba6be3da6544ec5d8051d74a976dcd52314ef.zip
Fix org-habit bug related to string mutation
* lisp/org/org-habit.el (org-habit-build-graph): Rewrite without using string mutation (using vectors instead), fixing a bug where org-habit-completed-glyph and org-habit-today-glyph wouldn't display properly if in the U+0080..00FF range, discovered by the more restricted string mutation. Reported by Daniel Mendler in https://lists.gnu.org/archive/html/emacs-orgmode/2025-08/msg00224.html
-rw-r--r--lisp/org/org-habit.el24
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/org/org-habit.el b/lisp/org/org-habit.el
index 38975682152..010c9daa00e 100644
--- a/lisp/org/org-habit.el
+++ b/lisp/org/org-habit.el
@@ -333,7 +333,8 @@ current time."
333 (start (time-to-days starting)) 333 (start (time-to-days starting))
334 (now (time-to-days current)) 334 (now (time-to-days current))
335 (end (time-to-days ending)) 335 (end (time-to-days ending))
336 (graph (make-string (1+ (- end start)) ?\s)) 336 (graph (make-vector (1+ (- end start)) ?\s))
337 (props nil)
337 (index 0) 338 (index 0)
338 last-done-date) 339 last-done-date)
339 (while (and done-dates (< (car done-dates) start)) 340 (while (and done-dates (< (car done-dates) start))
@@ -411,17 +412,20 @@ current time."
411 (not (eq face 'org-habit-overdue-face)) 412 (not (eq face 'org-habit-overdue-face))
412 (not markedp)) 413 (not markedp))
413 (setq face (cdr faces))) 414 (setq face (cdr faces)))
414 (put-text-property index (1+ index) 'face face graph) 415 (push (list index (1+ index) 'face face) props)
415 (put-text-property index (1+ index) 416 (push (list index (1+ index)
416 'help-echo 417 'help-echo
417 (concat (format-time-string 418 (concat (format-time-string
418 (org-time-stamp-format) 419 (org-time-stamp-format)
419 (time-add starting (days-to-time (- start (time-to-days starting))))) 420 (time-add starting (days-to-time (- start (time-to-days starting)))))
420 (if donep " DONE" "")) 421 (if donep " DONE" "")))
421 graph)) 422 props))
422 (setq start (1+ start) 423 (setq start (1+ start)
423 index (1+ index))) 424 index (1+ index)))
424 graph)) 425 (let ((graph-str (concat graph)))
426 (dolist (p props)
427 (put-text-property (nth 0 p) (nth 1 p) (nth 2 p) (nth 3 p) graph-str))
428 graph-str)))
425 429
426(defun org-habit-insert-consistency-graphs (&optional line) 430(defun org-habit-insert-consistency-graphs (&optional line)
427 "Insert consistency graph for any habitual tasks." 431 "Insert consistency graph for any habitual tasks."