Org inline macros

This commit is contained in:
Emmet 2023-08-28 20:52:58 -05:00
parent eb43b570a1
commit 49606f5f0a
2 changed files with 39 additions and 0 deletions

View file

@ -489,6 +489,24 @@ same directory as the org-buffer and insert a link to this file."
; :desc "Simple print region in web browser" ; :desc "Simple print region in web browser"
; "r" 'org-simple-print-region) ; "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 ------;;; ;;;------ Org roam configuration ------;;;
(require 'org-roam) (require 'org-roam)
(require 'org-roam-dailies) (require 'org-roam-dailies)

View file

@ -583,6 +583,27 @@ exit
; :desc "Simple print region in web browser" ; :desc "Simple print region in web browser"
; "r" 'org-simple-print-region) ; "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 #+END_SRC
** Org Roam Configuration ** Org Roam Configuration
*** Standard Org Roam Configuration *** Standard Org Roam Configuration