summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/documents.el77
1 files changed, 77 insertions, 0 deletions
diff --git a/lisp/documents.el b/lisp/documents.el
index 6341c98..3fa83dc 100644
--- a/lisp/documents.el
+++ b/lisp/documents.el
@@ -281,6 +281,12 @@ Visits LINK, or if LINK names a subdirectory of
(org-agenda-overriding-header "Needs Processing:"))))
((org-agenda-compact-blocks t)
(org-agenda-overriding-columns-format "%TODO %EFFORT %ITEM %CATEGORY %TAGS"))))))
+ (setq org-agenda-prefix-format
+ '((agenda . " %i %-12:c%?-12t%s %l")
+ (todo . "%b")
+ (tags . " %i %-12:c")
+ (search . " %i %-12:c")))
+
;; Track the date and time that tasks are marked as DONE.
(setq org-log-done 'time)
@@ -294,6 +300,77 @@ Visits LINK, or if LINK names a subdirectory of
(not (org-entry-get nil "CREATED")))
(org-entry-put nil "CREATED" (format-time-string (cdr org-time-stamp-formats)))))
+ ;; The following is a hack to have more flexibility in how agenda lines are
+ ;; displayed. Specifically, the following will configure Org such that each
+ ;; line in the agenda reads:
+ ;;
+ ;; [effort] | [leaf] | [breadcrumbs except leaf] | [tags]
+ ;;
+ ;; Where `|' represents some appropriate padding.
+ :init
+ (setq org-agenda-breadcrumbs-separator "")
+
+ :config
+ (defvar org-agenda-line-indent 8)
+ (defvar org-agenda-line-parent-hint-length 48)
+ (defvar org-agenda-line-tags-hint-length 20)
+ (defun org-agenda-line-strip-tags (x)
+ "Split `x' into a list of (`rest' `tags-string')"
+ (if (string-match ":.*:" x)
+ (let ((beg (string-match ":.*:" x))
+ (end (match-end 0)))
+ (list (substring x 0 beg) (substring x beg end)))
+ nil))
+ (defun org-agenda-line-content-region (x)
+ "Return `(beginning end)' for the content of `x' excluding trailing whitespace"
+ (list (- (length x) (length (string-trim-left x)))
+ (length (string-trim-right x))))
+ (defun org-agenda-line-format-components (effort components)
+ "Format the given information into an Agenda line, as described above"
+ (let* ((left-padding (- (window-width)
+ org-agenda-line-indent
+ org-agenda-line-parent-hint-length
+ org-agenda-line-tags-hint-length))
+ (parent-hint (if (= 1 (length components))
+ ""
+ (maybe-elide
+ (concat "("
+ (string-join (cl-subseq components 0 (- 1)) " -> ")
+ ")")
+ org-agenda-line-parent-hint-length))))
+ (format "%s%s%s%s"
+ (string-pad effort org-agenda-line-indent)
+ ;; The following two subexpressions would be one if `string-pad'
+ ;; took the visual width into account (it doesn't, padding based
+ ;; on the number of characters in the string rather than the
+ ;; number of characters displayed.)
+ (car (last components))
+ (string-pad "" (- left-padding (org-string-width (car (last components)))))
+ parent-hint)))
+ (defun org-agenda-line-reformat-breadcrumbs (x)
+ "Entry-point for `org-agenda-line-format-components' that handles whitespace"
+ (let* ((pos (get-text-property 0 'org-marker x))
+ (effort (org-entry-get pos "EFFORT"))
+ (region (content-region x))
+ (region-beg (car region))
+ (region-end (cadr region))
+ (actual (substring x region-beg region-end))
+ ;; n.b. the unusual  character originates from above, where we set
+ ;; `org-agenda-breadcrumbs-separator'.
+ (components (split-string actual "")))
+ (concat
+ (substring x 0 region-beg)
+ (format-components effort components)
+ (substring x region-end (length x)))))
+ (defun org-agenda-line-format-item (x)
+ "`filter-return' to re-format Org agenda line items"
+ (if (not (string-match "Habits:" x))
+ (if-let ((pieces (strip-tags x)))
+ (concat (reformat-breadcrumbs (car pieces)) (cadr pieces))
+ (reformat-breadcrumbs x))
+ x))
+ (advice-add 'org-agenda-format-item :filter-return #'org-agenda-line-format-item)
+
;; Patch in an offset for tag alignment. (Without this, they will warp in a
;; way which I do not like.)
:config/el-patch

© 2015 - 2026 Jakob L. Kreuze