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

Fix the issue of before-save-hook being added globally #24

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Because of the way GitHub renders Org documents and links, it's not possible to

+ Tolerate whitespace before drawer opening/closing lines. ([[https://github.com/alphapapa/org-make-toc/pull/15][#15]], [[https://github.com/alphapapa/org-make-toc/issues/17][#17]]. Thanks to [[https://github.com/progfolio][Nicholas Vollmer]].)
+ Link-type function called with position as argument. (Fixes occasional bugs with heading IDs.)
+ Mode ~org-make-toc-mode~ now adds to the ~before-save-hook~ in the local buffer rather than globally. ([[https://github.com/alphapapa/org-make-toc/pull/24][#24]]. Thanks to [[https://github.com/akirak][Akira Komamura]].)

** 0.5

Expand Down
5 changes: 3 additions & 2 deletions org-make-toc.el
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ With prefix argument ARG, turn on if positive, otherwise off."
:init-value nil
(unless (derived-mode-p 'org-mode)
(user-error "Not an Org buffer"))
(funcall (if org-make-toc-mode #'add-hook #'remove-hook)
'before-save-hook #'org-make-toc)
(if org-make-toc-mode
(add-hook 'before-save-hook #'org-make-toc nil t)
(remove-hook 'before-save-hook #'org-make-toc t))
(message (format "org-make-toc-mode %s."
(if org-make-toc-mode
"enabled"
Expand Down