Last active
February 29, 2020 14:09
-
-
Save apraga/3945a9f27ced9a182d4bf46eafb20ba4 to your computer and use it in GitHub Desktop.
Some functions to manage org-mode files with om.el
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'om) | |
(defun mark-late-todo() | |
;; Marke special TODO (here LATE) as done in a subtree. | |
;; Update the buffer directly but you need the cursor on the top of the subtree. | |
;; Given | |
;; #+TODO: TODO(t) LATE(l) | DONE(d) CANCELLED(c) | |
;; * TODO Root node | |
;; ** LATE this node | |
;; *** TODO subnode | |
;; | |
;; It returns | |
;; | |
;; * TODO Root node | |
;; ** DONE this node | |
;; *** TODO subnode | |
(om-update-this-subtree* | |
(om-match-map '(:many (:todo-keyword "LATE")) | |
(lambda (hl) | |
(om-set-property :todo-keyword "DONE" hl)) it)) | |
) | |
;; Increment a number by 1 | |
(defun increment-number(n) | |
(number-to-string (1+ (string-to-number n))) | |
) | |
;; INcrement 2 node properties | |
;; TODO: check the properties exists (otherwise it fails) | |
;; | |
;; * TODO Root node | |
;; :PROPERTIES: | |
;; :COLLEGE: 1 | |
;; :ECNI: 1 | |
;; :END: | |
;; | |
;; It returns | |
;; | |
;; * TODO Root node | |
;; :PROPERTIES: | |
;; :COLLEGE: 2 | |
;; :ECNI: 2 | |
;; :END: | |
(defun increment-reviews() | |
(om-update-this-headline* | |
(->> (om-headline-map-node-property "COLLEGE" (function increment-number) it) | |
(om-headline-map-node-property "ECNI" (function increment-number))) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment