Jean Louis <[email protected]> writes: > * Khalid Rafi <[email protected]> [2025-12-28 05:49]: >> >> How can I track numerical habits such as reading a number of pages of >> books? I have only found time-bound repeaters in manual. Not this case. > > * Numerical Habit Tracker: Reading > :PROPERTIES: > :HABIT: ReadingPages > :TARGET: 20 > :UNIT: pages > :TOTAL: 0 > :END: > > ** Log Entry > :PROPERTIES: > :DATE: [2025-12-31 Wed] > :PAGES: 0 > :END: > > #+BEGIN_SRC emacs-lisp > ;; Quasi-automated system to increment pages read per session > (defun org-increment-pages-read (n) > "Add N pages to the HABIT tracker." > (interactive "nPages read: ") > (let* ((entry (org-entry-get nil "TOTAL")) > (current (string-to-number entry)) > (new-total (+ current n))) > (org-entry-put nil "TOTAL" (number-to-string new-total)) > (org-set-property "PAGES" (number-to-string n)) > (org-schedule nil "+0d") ;; fake scheduling for daily logging > (message "Updated TOTAL pages read: %d" new-total))) > ;; Usage: call M-x org-increment-pages-read and type number of pages > #+END_SRC > > ** Automatic Sum > #+BEGIN_SRC emacs-lisp > ;; If you want to sum all PAGES from children automatically > (defun org-sum-pages-read () > "Sum all :PAGES: properties in subtree." > (interactive) > (let ((sum 0)) > (org-map-entries > (lambda () > (let ((n (string-to-number (org-entry-get nil "PAGES")))) > (setq sum (+ sum n))))) > (message "Total pages in subtree: %d" sum))) > #+END_SRC > > ** Graphical Output (Optional) > > ** Graphical Output: Pages Read Over Time > #+BEGIN_SRC gnuplot :file "pages_read.png" :results silent > set datafile separator "," > set terminal png size 600,400 > set output "pages_read.png" > set title "Pages Read Over Time" > set xlabel "Day" > set ylabel "Pages" > set grid > plot "pages_data.csv" using 1:2 with linespoints lt rgb "blue" lw 2 pt 7 > title "Pages" > #+END_SRC > > [[file:pages_read.png]] > > All that Org machinery to count pages… meanwhile a bookmark quietly > gets the job done, no Emacs required. > > The Org Mode in attachment will work on any desktop—even one without > electricity, though results may vary with candlelight.
Thanks for whatever you've given. But, as someone coming from the Loop Habit Tracker (the Android app) to Org mode, I was looking for its very basic habit tracking features in Org mode. Is what I'm looking for unavailable in the default org-habit module? It would be surprising if Org mode can't do that considering it's so customizable! -- Khalid Rafi Sent with Emacs
