aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-11-10 03:18:52 -0500
committerMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-11-10 03:18:52 -0500
commit2b920002cf8776891074f18fabc683667c7b4319 (patch)
tree5aa7a4499e14d222f17924e125e41af8a88eac00
parentHide some org-related modes from the modeline (diff)
downloadmmosmacs-2b920002cf8776891074f18fabc683667c7b4319.tar.gz
mmosmacs-2b920002cf8776891074f18fabc683667c7b4319.tar.bz2
mmosmacs-2b920002cf8776891074f18fabc683667c7b4319.zip
Make org-agenda time-grid look more consistent
When using different types of logged entries, the time-grid shows them in different formats. For example, with CLOCK: entries it shows a (-) before the timestamp, and with :LOGBOOK: State changes it shows the state. None of them are aligned, and the time-grid stops being a "grid". It doesn't make sense and my ADHD can't handle it and I hate it.
-rw-r--r--init.el124
1 files changed, 122 insertions, 2 deletions
diff --git a/init.el b/init.el
index 318e58d..4575df6 100644
--- a/init.el
+++ b/init.el
@@ -1222,8 +1222,8 @@
1222;; Custom Agenda views 1222;; Custom Agenda views
1223(use-package org-agenda 1223(use-package org-agenda
1224 :config 1224 :config
1225 (setq org-agenda-prefix-format '((agenda . " %-11s %-13:t %-12:c ") 1225 (setq org-agenda-prefix-format '((agenda . " %-27s %-13:t %-12:c ") ;" %-11s %-13:t %-12:c "
1226 (todo . " %-11s %-13:t %-12:c ")) 1226 (todo . " %-27s %-13:t %-12:c "))
1227 org-agenda-custom-commands 1227 org-agenda-custom-commands
1228 '(("o" "Agenda Overview" 1228 '(("o" "Agenda Overview"
1229 ((agenda "" ((org-agenda-span 'day) 1229 ((agenda "" ((org-agenda-span 'day)
@@ -1249,6 +1249,126 @@
1249 :todo "NEXT") 1249 :todo "NEXT")
1250 (:discard (:anything t))))))))))) 1250 (:discard (:anything t)))))))))))
1251 1251
1252;; Make all time-grid entries, including ones from :LOGBOOK:, look the same
1253(defun org-agenda-get-progress ()
1254 "Return the logged TODO entries for agenda display."
1255 (with-no-warnings (defvar date))
1256 (let* ((props (list 'mouse-face 'highlight
1257 'org-not-done-regexp org-not-done-regexp
1258 'org-todo-regexp org-todo-regexp
1259 'org-complex-heading-regexp org-complex-heading-regexp
1260 'help-echo
1261 (format "mouse-2 or RET jump to org file %s"
1262 (abbreviate-file-name buffer-file-name))))
1263 (items (if (consp org-agenda-show-log-scoped)
1264 org-agenda-show-log-scoped
1265 (if (eq org-agenda-show-log-scoped 'clockcheck)
1266 '(clock)
1267 org-agenda-log-mode-items)))
1268 (parts
1269 (delq nil
1270 (list
1271 (when (memq 'closed items) (concat "\\<" org-closed-string))
1272 (when (memq 'clock items) (concat "\\<" org-clock-string))
1273 (when (memq 'state items)
1274 (format "- +State \"%s\".*?" org-todo-regexp)))))
1275 (parts-re (if parts (mapconcat #'identity parts "\\|")
1276 (error "`org-agenda-log-mode-items' is empty")))
1277 (regexp (concat
1278 "\\(" parts-re "\\)"
1279 " *\\["
1280 (regexp-quote
1281 (substring
1282 (format-time-string
1283 (org-time-stamp-format)
1284 (org-encode-time ; DATE bound by calendar
1285 0 0 0 (nth 1 date) (car date) (nth 2 date)))
1286 1 11))))
1287 (org-agenda-search-headline-for-time nil)
1288 marker hdmarker priority category level tags closedp type
1289 statep clockp state ee txt extra timestr rest clocked inherited-tags
1290 effort effort-minutes)
1291 (goto-char (point-min))
1292 (while (re-search-forward regexp nil t)
1293 (catch :skip
1294 (org-agenda-skip)
1295 (setq marker (org-agenda-new-marker (match-beginning 0))
1296 closedp (equal (match-string 1) org-closed-string)
1297 statep (equal (string-to-char (match-string 1)) ?-)
1298 clockp (not (or closedp statep))
1299 state (and statep (match-string 2))
1300 category (org-get-category (match-beginning 0))
1301 timestr (buffer-substring (match-beginning 0) (line-end-position))
1302 effort (save-match-data (or (get-text-property (point) 'effort)
1303 (org-entry-get (point) org-effort-property))))
1304 (setq effort-minutes (when effort (save-match-data (org-duration-to-minutes effort))))
1305 (when (string-match "\\]" timestr)
1306 ;; substring should only run to end of time stamp
1307 (setq rest (substring timestr (match-end 0))
1308 timestr (substring timestr 0 (match-end 0)))
1309 (if (and (not closedp) (not statep)
1310 (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*?\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)"
1311 rest))
1312 (progn (setq timestr (concat (substring timestr 0 -1)
1313 "-" (match-string 1 rest) "]"))
1314 (setq clocked (match-string 2 rest)))
1315 ;; THIS IS CHANGED from a single dash "-" to "CLOCKED"
1316 (setq clocked "CLOCKED")))
1317 (save-excursion
1318 (setq extra
1319 (cond
1320 ((not org-agenda-log-mode-add-notes) nil)
1321 (statep
1322 (and (looking-at ".*\\\\\n[ \t]*\\([^-\n \t].*?\\)[ \t]*$")
1323 (match-string 1)))
1324 (clockp
1325 (and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
1326 (match-string 1)))))
1327 (if (not (re-search-backward org-outline-regexp-bol nil t))
1328 (throw :skip nil)
1329 (goto-char (match-beginning 0))
1330 (setq hdmarker (org-agenda-new-marker)
1331 inherited-tags
1332 (or (eq org-agenda-show-inherited-tags 'always)
1333 (and (listp org-agenda-show-inherited-tags)
1334 (memq 'todo org-agenda-show-inherited-tags))
1335 (and (eq org-agenda-show-inherited-tags t)
1336 (or (eq org-agenda-use-tag-inheritance t)
1337 (memq 'todo org-agenda-use-tag-inheritance))))
1338 tags (org-get-tags nil (not inherited-tags))
1339 level (make-string (org-reduced-level (org-outline-level)) ? ))
1340 (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
1341 (setq txt (match-string 1))
1342 ;; MAYBE DELETE NEXT 5 LINES
1343 (when extra
1344 (if (string-match "\\([ \t]+\\)\\(:[^ \n\t]*?:\\)[ \t]*$" txt)
1345 (setq txt (concat (substring txt 0 (match-beginning 1))
1346 " - " extra " " (match-string 2 txt)))
1347 (setq txt (concat txt " - " extra))))
1348 (setq txt (org-agenda-format-item
1349 (cond
1350 ;; CHANGES ARE HERE
1351 (closedp (concat "Closed: " (spaces-string 12)))
1352 (statep (concat "State: " state (spaces-string (- 12 (length state)))))
1353 (t (concat "Clocked: " clocked (spaces-string (- 12 (length clocked))))))
1354 ;; END CHANGES
1355 (org-add-props txt nil
1356 'effort effort
1357 'effort-minutes effort-minutes)
1358 level category tags timestr)))
1359 (setq type (cond (closedp "closed")
1360 (statep "state")
1361 (t "clock")))
1362 (setq priority 100000)
1363 (org-add-props txt props
1364 'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done
1365 'urgency priority 'priority priority 'level level
1366 'effort effort 'effort-minutes effort-minutes
1367 'type type 'date date
1368 'undone-face 'org-warning 'done-face 'org-agenda-done)
1369 (push txt ee))
1370 (goto-char (line-end-position))))
1371 (nreverse ee)))
1252 1372
1253;; Update agenda periodically every `mm/refresh-agenda-time-seconds' seconds. 1373;; Update agenda periodically every `mm/refresh-agenda-time-seconds' seconds.
1254;; This was taken from https://emacs.stackexchange.com/a/68767/38877 1374;; This was taken from https://emacs.stackexchange.com/a/68767/38877