Skip to content

Conversation

Martinsos
Copy link

@Martinsos Martinsos commented Oct 30, 2024

First of all, thanks for amazing effort in creating System Crafters: I am just going through the "emacs from scratch" old playlist and I find it incredibly useful and enjoyable.

I opened this PR because I was curious if we can do automatic tangling in more efficient way. If I am correct, the current logic in this repo (and from the video number 7) is somewhat inefficient, in a way that it will register after-save-hook for every buffer opened with org-mode, and then it will, in that hook, check again and again if that buffer is Emacs.org or not.
However, couldn't we instead do that check just once per buffer, at the moment when we are making a decision if we should register after-save-hook for that buffer or not? That way we register after-save-hook only for Emacs.org buffer (we have to make it a local hook though, that is why additional nil t params in the add-hook call).

I hope the suggestion is clear, if not, I believe the code in this PR should clear it up.

Thanks!

(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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant