From 9c1fe06d26b69d851930052da68ec1dd3920b3b2 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 7 Feb 2024 06:34:06 +0100 Subject: [PATCH] docs(Emacs org): better auto tangling of my config files --- docs/.dir-locals.el | 3 +-- docs/emacs/packages/org.org | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/.dir-locals.el b/docs/.dir-locals.el index 95c3727..a1a020d 100644 --- a/docs/.dir-locals.el +++ b/docs/.dir-locals.el @@ -2,5 +2,4 @@ ;;; For more information see (info "(emacs) Directory Variables") ((org-mode . ((org-list-allow-alphabetical . nil) - (org-confirm-babel-evaluate . nil) - (eval . (add-hook 'after-save-hook #'org-babel-tangle))))) + (org-confirm-babel-evaluate . nil)))) diff --git a/docs/emacs/packages/org.org b/docs/emacs/packages/org.org index b087bb6..248d74d 100644 --- a/docs/emacs/packages/org.org +++ b/docs/emacs/packages/org.org @@ -1245,6 +1245,18 @@ which is really nice! However, most of my configuration will be stolen (org-present-mode-quit . my/org-present-quit))) #+end_src +** Tangle config org files on save +Something really, really useful is tangling all my configuration files +on save. For this, a dedicated function will do the trick. +#+begin_src emacs-lisp +(defun my/tangle-config-file () + (when (and (eq major-mode 'org-mode) + (f-ancestor-of-p (f-full "~/.nosync/org/config") default-directory)) + (org-babel-tangle))) + +(add-hook 'after-save-hook #'my/tangle-config-file) +#+end_src + ** Visual Configuration While most modes of Emacs are dedicated to development, and therefore are much more comfortable with a fixed-pitch font, more literary modes