Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved automatic tangling logic in Emacs.org #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Emacs.org
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,11 @@ This snippet adds a hook to =org-mode= buffers so that =efs/org-babel-tangle-con

#+begin_src emacs-lisp

;; Automatically tangle our Emacs.org config file when we save it
(defun efs/org-babel-tangle-config ()
(when (string-equal (file-name-directory (buffer-file-name))
(expand-file-name user-emacs-directory))
;; Dynamic scoping to the rescue
(let ((org-confirm-babel-evaluate nil))
(org-babel-tangle))))

(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'efs/org-babel-tangle-config)))
;; Automatically tangle any org file in our emacs directory when we save it.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it I updated the comment to reflect the changes you at some point did to the code (before it was just Emacs.org, now it is all org files in user emacs directory).

(add-hook 'org-mode-hook (lambda ()
(when (string-equal (file-name-directory (buffer-file-name)) (expand-file-name user-emacs-directory))
(add-hook 'after-save-hook (lambda ()
(let ((org-confirm-babel-evaluate nil)) (org-babel-tangle)))))))

#+end_src

Expand Down