From 49606f5f0aec8510edb95153627a4d40f28e5289 Mon Sep 17 00:00:00 2001 From: Emmet Date: Mon, 28 Aug 2023 20:52:58 -0500 Subject: [PATCH] Org inline macros --- user/app/doom-emacs/config.el | 18 ++++++++++++++++++ user/app/doom-emacs/doom.org | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index 263c021..ff25fa5 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -489,6 +489,24 @@ same directory as the org-buffer and insert a link to this file." ; :desc "Simple print region in web browser" ; "r" 'org-simple-print-region) +;; Display macros inline in buffers +(add-to-list 'font-lock-extra-managed-props 'display) + +(font-lock-add-keywords + 'org-mode + '(("\\({{{[a-zA-Z#%)(_-+0-9]+}}}\\)" 0 + `(face nil display + ,(format "%s" + (let* ((input-str (match-string 0)) + (el (with-temp-buffer + (insert input-str) + (goto-char (point-min)) + (org-element-context))) + (text (org-macro-expand el org-macro-templates))) + (if text + text + input-str))))))) + ;;;------ Org roam configuration ------;;; (require 'org-roam) (require 'org-roam-dailies) diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index 7e18095..bf4b7b2 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -583,6 +583,27 @@ exit ; :desc "Simple print region in web browser" ; "r" 'org-simple-print-region) +#+END_SRC +*** Org Inline Macros +#+BEGIN_SRC emacs-lisp :tangle config.el +;; Display macros inline in buffers +(add-to-list 'font-lock-extra-managed-props 'display) + +(font-lock-add-keywords + 'org-mode + '(("\\({{{[a-zA-Z#%)(_-+0-9]+}}}\\)" 0 + `(face nil display + ,(format "%s" + (let* ((input-str (match-string 0)) + (el (with-temp-buffer + (insert input-str) + (goto-char (point-min)) + (org-element-context))) + (text (org-macro-expand el org-macro-templates))) + (if text + text + input-str))))))) + #+END_SRC ** Org Roam Configuration *** Standard Org Roam Configuration