Use auto-id package
This commit is contained in:
parent
82252dbb27
commit
3fb9362383
19
init.org
19
init.org
|
@ -3963,23 +3963,10 @@ preceded by another heading) and after headings."
|
||||||
:hook (org-mode . org-superstar-mode))
|
:hook (org-mode . org-superstar-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Automatically add CUSTOM_ID property
|
*** auto-id
|
||||||
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
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun my-org-set-custom-id ()
|
(use-package auto-id
|
||||||
(let (headings)
|
:load-path "/media/data/anon/Documents/Text Files/programming/elisp/auto-id/")
|
||||||
(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
|
#+END_SRC
|
||||||
|
|
||||||
** markdown-mode :editing:
|
** markdown-mode :editing:
|
||||||
|
|
Loading…
Reference in New Issue