Skip to content

Instantly share code, notes, and snippets.

@dmgerman
Last active October 24, 2024 04:45
Show Gist options
  • Save dmgerman/b75dd1c68636482121b3491e0b351f17 to your computer and use it in GitHub Desktop.
Save dmgerman/b75dd1c68636482121b3491e0b351f17 to your computer and use it in GitHub Desktop.
Org Agenda Custom
(defun dmg-agenda-section-test (parm)
"Generate a custom section to be inserted into the agenda. Takes an optional PARM parameter."
(message "Parm --------------[%S]" parm)
(let (
(original-pt (point))
(inhibit-read-only t)
)
(goto-char (point-max))
(let (
(pt (point))
)
(insert (format "\n%s\n\n" (propertize "My own test section" 'face 'org-agenda-structure)))
;; where it all goes
(insert
(format "\n- Parm to the function [%S]\n- time of the day [%S]\n" parm
(format-time-string "%Y%M%D %M:%S")))
(insert "\nThis is the end of the world as we know it.\n\n
- [[http://github.com]]
- [[http://turingmachine.org][dmg]]
\n")
;; example of autoalignning a table
(let ((pt0 (point)))
(insert "| a | b |\n|-\n| [[file:/tmp/][/tmp]] | adfasdffdasfasdfdasfasf |\n\n")
;; we need to replace the links in the entire section
(save-excursion
(goto-char pt)
(while (org-activate-links (point-max))
(goto-char (match-end 0))))
;; align the table
(goto-char pt0)
(org-table-align)
)
(goto-char original-pt)
)
)
)
(setq org-agenda-custom-commands nil)
(setq org-agenda-custom-commands
'(
("N" "Next"
(
(tags "TODO=\"TODO\"")
(dmg-agenda-section-test "This is a test")
))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment