Org: Automatically add CUSTOM_ID (WIP)
This commit is contained in:
parent
255983c9fe
commit
92a9640f27
19
init.org
19
init.org
|
@ -3949,6 +3949,25 @@ preceded by another heading) and after headings."
|
|||
:hook (org-mode . org-superstar-mode))
|
||||
#+END_SRC
|
||||
|
||||
*** Automatically add CUSTOM_ID property
|
||||
Probably best run in =before-save-hook=. Considerations -
|
||||
1. making human-readable CUSTOM_IDs by reusing heading titles
|
||||
2. maintaining CUSTOM_ID uniqueness
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun my-org-set-custom-id ()
|
||||
(let (headings)
|
||||
(org-map-region
|
||||
(lambda ()
|
||||
(let ((heading (org-element-at-point)))
|
||||
(unless (org-element-property "CUSTOM_ID" heading)
|
||||
(cl-pushnew (org-element-property :title heading) headings))))
|
||||
(point-min)
|
||||
(point-max))
|
||||
(reverse headings)))
|
||||
(add-hook 'org-insert-heading-hook #'my-org-set-custom-id)
|
||||
#+END_SRC
|
||||
|
||||
** markdown-mode :editing:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package markdown-mode
|
||||
|
|
Loading…
Reference in New Issue