summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-01-02 23:15:49 -0600
committerCase Duckworth2021-01-02 23:15:49 -0600
commit130815ce0c0b3eac9707114b0ed5080f3941802c (patch)
treeb5e7193df0fa998ca9f964e40e4712b5ccd0c1a5
parentMake anchors in Org more useful (diff)
downloademacs-130815ce0c0b3eac9707114b0ed5080f3941802c.tar.gz
emacs-130815ce0c0b3eac9707114b0ed5080f3941802c.zip
Get rid of “Useful HTML Anchors” section
It clobbered all my org-mode stuff!!
-rw-r--r--config.org41
1 files changed, 0 insertions, 41 deletions
diff --git a/config.org b/config.org index 93e136d..65dc47a 100644 --- a/config.org +++ b/config.org
@@ -1488,47 +1488,6 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m
1488 (add-hook 'emacs-lisp-mode-hook #'org-link-minor-mode) 1488 (add-hook 'emacs-lisp-mode-hook #'org-link-minor-mode)
1489 #+end_src 1489 #+end_src
1490 1490
1491*** Useful HTML Anchors
1492
1493 #+begin_src emacs-lisp
1494 (defun my/ensure-headline-ids (&rest _)
1495 "Ensure better headlines for Org trees.
1496
1497 Use CUSTOM_ID property, or barring that, a \"fixed\" title.
1498
1499 All non-alphanumeric characters are cleverly replaced with ‘-’.
1500
1501 If multiple trees end-up with the same id property, issue a
1502 message and undo any property insertion thus far.
1503
1504 E.g., ↯ We'll go on a ∀∃⇅ adventure
1505 ↦ We'll-go-on-a-adventure
1506 "
1507 (interactive)
1508 (let ((ids))
1509 (org-map-entries
1510 (lambda ()
1511 (org-with-point-at (point)
1512 (let ((id (org-entry-get nil "CUSTOM_ID")))
1513 (unless id
1514 (thread-last (nth 4 (org-heading-components))
1515 (s-replace-regexp "[^[:alnum:]']" "-")
1516 (s-replace-regexp "-+" "-")
1517 (s-chop-prefix "-")
1518 (s-chop-suffix "-")
1519 (setq id))
1520 (if (not (member id ids))
1521 (push id ids)
1522 (message-box "Oh no, a repeated id!\n\n\t%s" id)
1523 (undo)
1524 (setq quit-flag t))
1525 (org-entry-put nil "CUSTOM_ID" id))))))))
1526
1527 ;; Whenever html & md export happens, ensure we have headline ids.
1528 (advice-add 'org-html-export-to-html :before 'my/ensure-headline-ids)
1529 (advice-add 'org-md-export-to-markdown :before 'my/ensure-headline-ids)
1530 #+end_src
1531
1532** Git 1491** Git
1533 1492
1534#+begin_src emacs-lisp 1493#+begin_src emacs-lisp