summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfpi2020-02-13 10:35:31 +0100
committerfpi2020-02-23 18:07:13 +0100
commit91f45b204f064cb7df88968c84e35748163f6c4b (patch)
treee10c064f923616b96b0a60de9dab95fa43ac5509
parentShow agenda items without time on top of current day (diff)
Add org-edna for todo dependency management
Diffstat (limited to '')
-rw-r--r--emacs-init.org69
1 files changed, 69 insertions, 0 deletions
diff --git a/emacs-init.org b/emacs-init.org
index 14c13aa..009a116 100644
--- a/emacs-init.org
+++ b/emacs-init.org
@@ -1741,6 +1741,72 @@ Use imagemagick and standalone class for latex preview.
;;(setq org-reveal-root "http://cdn.jsdelivr.net/reveal.js/3.0.0/")
#+END_SRC
+*** Org-edna
+=Org-edna= is a great tool to manage =TODO= dependencies. I mainly use
+it to mark tasks as =NEXT= after switching another task to =DONE=. The
+functions below are taken from Josh's Emacs Config over at [[https://github.com/mm--/dot-emacs/blob/master/jmm-org-config.org][Github]]. He
+wrote wrote a =edna-finder= which allows link descriptions and a nice
+hydra to manage the various =org-edna= properties. I call it in my
+[[id:22750e48-aaee-4f60-bdce-1d511ebe3375][context aware hydra]] when on an org headline. For more functions and
+explanations checkout his config.
+#+begin_src emacs-lisp
+(use-package org-edna
+ :ensure t
+ :after org
+ :defer t
+ :config
+ (org-edna-load)
+ (defun org-edna-finder/link-ids (&rest ids)
+ "Find a list of headlines with given IDs.
+
+Unlike `org-edna-finder/ids', IDS here can be links of the form \"[[id:UUID][Headline]]\" (in quotes).
+This allows for easier readability of targets."
+ (mapcar (lambda (id) (save-window-excursion
+ (org-open-link-from-string id)
+ (point-marker)))
+ ids))
+ (defun jmm/org-edna-set-trigger-and-point (triggervalue)
+ "Set the TRIGGER property to TRIGGERVALUE. Move the point to
+the newly set value. Open the PROPERTIES drawer."
+ (let ((property "TRIGGER"))
+ (org-entry-put (point) property triggervalue)
+ (org-back-to-heading t)
+ (let* ((beg (point))
+ (range (org-get-property-block beg 'force))
+ (end (cdr range))
+ (case-fold-search t))
+ (goto-char (1- (car range))) ;Need to go one character back to get property-drawer element
+ (let ((element (org-element-at-point)))
+ (when (eq (org-element-type element) 'property-drawer)
+ (org-flag-drawer nil element)))
+ (goto-char (car range))
+ (re-search-forward (org-re-property property nil t) end t))))
+ (defun jmm/org-edna-chain-next ()
+ "Set TRIGGER to chain next"
+ (interactive)
+ (jmm/org-edna-set-trigger-and-point "next-sibling todo!(NEXT) chain!(\"TRIGGER\")"))
+ (defun jmm/org-pop-stored-link ()
+ "Get the string for the previously stored link, then remove it from `org-stored-links'"
+ (let* ((firstlink (car org-stored-links))
+ (link (car firstlink))
+ (desc (cadr firstlink)))
+ (setq org-stored-links (delq (assoc link org-stored-links)
+ org-stored-links))
+ (org-make-link-string link desc)))
+ (defun jmm/org-edna-link (&optional rest)
+ "Set TRIGGER to chain next. With option"
+ (interactive)
+ (jmm/org-edna-set-trigger-and-point
+ (format "link-ids(\"%s\")%s" (jmm/org-pop-stored-link) (if rest (concat " " rest) ""))))
+ (defhydra jmm/org-edna-hydra (:color blue)
+ "Org Edna"
+ ("l" jmm/org-edna-link "Link")
+ ("L" (jmm/org-edna-link "todo!(NEXT)") "Link NEXT")
+ ("n" (jmm/org-edna-set-trigger-and-point "next-sibling todo!(NEXT)") "Next sibling NEXT")
+ ("N" (jmm/org-edna-set-trigger-and-point "next-sibling todo!(NEXT) chain!(\"TRIGGER\")") "Chain next-sibling NEXT")
+ ("p" (jmm/org-edna-set-trigger-and-point "parent todo!(DONE)") "Parent DONE")
+ ("q" nil "cancel")))
+#+end_src
*** Org-Capture
Templates
#+BEGIN_SRC emacs-lisp
@@ -2761,6 +2827,9 @@ For now I use this bad code.
(or (bolp) (newline)))))
#+END_SRC
** Context aware hydra
+:PROPERTIES:
+:ID: 22750e48-aaee-4f60-bdce-1d511ebe3375
+:END:
[[https://dfeich.github.io/www/org-mode/emacs/2018/05/10/context-hydra.html][dfeich]] has a nice post on this. Basically it launches a specific hydra
based on the current mode and context around point.
#+BEGIN_SRC emacs-lisp