Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)


What links here:

Org mode elisp extract filtered properties of headings & save as JSON

Define a predicate that decides whether a property should be kept:

(defun should-keep-p (e)
  (or (string= "ITEM" (car e)) ;; the heading contents
      (string-match-p "^x" (car e)))) ;; starts with x

Define a function that processes a single org entry (heading):

(defun process-entry ()
  (let ((entry-props (let ((org-trust-scanner-tags t)) (org-entry-properties))) ; retrieve properties for the entry
        (priority (nth 3 (org-heading-components)))) ; retrieve priority for the entry
    (append (seq-filter should-keep-p entry-props) ; filter the properties
            `(("PRIORITY" . ,priority)))))         ; and add the priority

Then process every entry with process-entry and encode it as json:

(json-encode (org-map-entries process-entry))

Usually the functions would be defined as lambdas in a let and called with funcall.