Skip to content

Commit

Permalink
added a remove-hook if org-auto-tangle-mode is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
yilkalargaw committed Jan 25, 2021
1 parent 817e418 commit b9c2853
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions org-auto-tangle.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@

(defun org-auto-tangle-tangle-if-tag-exists ()
"Check if the #+auto_tangle option exists and call org-auto-tangle-async if it exists."
(when (and (org-auto-tangle-find-value (current-buffer))
(when (and (string= (buffer-local-value 'major-mode (current-buffer)) "org-mode")
(org-auto-tangle-find-value (current-buffer))
(not (string= (org-auto-tangle-find-value(current-buffer)) "nil")))
(org-auto-tangle-async (buffer-file-name))))

(define-minor-mode org-auto-tangle-mode
"Automatically tangle org-mode files with the option #+auto_tangle: t."
:lighter " org-a-t"

(when org-auto-tangle-mode
(add-hook 'org-mode-hook
(add-hook 'after-save-hook
(org-auto-tangle-tangle-if-tag-exists)
nil 'local))))
(if org-auto-tangle-mode
(add-hook 'after-save-hook 'org-auto-tangle-tangle-if-tag-exists
nil 'local)
(remove-hook 'after-save-hook 'org-auto-tangle-tangle-if-tag-exists)))

(provide 'org-auto-tangle)

Expand Down

0 comments on commit b9c2853

Please sign in to comment.