Skip to content

Commit

Permalink
Agenda tags format.
Browse files Browse the repository at this point in the history
Define a custom variable, dashboard-agenda-tags-format and a function
dashboard-agenda-formatted-tags to format the agenda tags.
  • Loading branch information
ricardoricho committed Feb 26, 2023
1 parent 221ee4b commit 679c826
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ Deadline or Scheduling time will be formatted using
~dashboard-agenda-time-string-format~ and the keywords (TODO, DONE)
respect [[https://orgmode.org/worg/doc.html#org-agenda-todo-keyword-format][org-agenda-todo-keyword-format]].

*** Agenda tags

To customize the tags format there is a variable
~dashboard-agenda-tags-format~. This variable could be any function that
receives the tags directly from ~org-get-tags~. By default
~dashboard-agenda-tags-format~ is set to ~identity~. To hide the
tags set the variable to ~ignore~: ~(setq dashboard-agenda-tags-format ignore)~
or to ~nil~.

** Faces

Expand Down
16 changes: 15 additions & 1 deletion dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,15 @@ each agenda entry."
:type 'string
:group 'dashboard)

(defcustom dashboard-agenda-tags-format 'identity
"Function to format the org agenda tags.
Any custom function would receives the tags from `org-get-tags'"
:type '(choice
(const :tag "Show tags" identity)
(const :tag "Hide tags" ignore)
(function :tag "Custom function"))
:group 'dashboard)

(defun dashboard-agenda-entry-format ()
"Format agenda entry to show it on dashboard.
Also,it set text properties that latter are used to sort entries and perform different actions."
Expand All @@ -1167,7 +1176,7 @@ Also,it set text properties that latter are used to sort entries and perform dif
(dashboard-agenda--formatted-headline)
(org-outline-level)
(org-get-category)
(org-get-tags)))
(dashboard-agenda--formatted-tags)))
(todo-state (org-get-todo-state))
(item-priority (org-get-priority (org-get-heading t t t t)))
(todo-index (and todo-state
Expand Down Expand Up @@ -1207,6 +1216,11 @@ If not height is found on FACE or `dashboard-items-face' use `default'."
(dashboard-agenda--entry-timestamp (point)))))
(format-time-string dashboard-agenda-time-string-format time)))

(defun dashboard-agenda--formatted-tags ()
"Apply `dashboard-agenda-tags-format' to org-element tags."
(when dashboard-agenda-tags-format
(funcall dashboard-agenda-tags-format (org-get-tags))))

(defun dashboard-due-date-for-agenda ()
"Return due-date for agenda period."
(if dashboard-week-agenda
Expand Down

0 comments on commit 679c826

Please sign in to comment.