emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-auto-tangle 70e5e3d131 13/56: move the whole thing int


From: ELPA Syncer
Subject: [nongnu] elpa/org-auto-tangle 70e5e3d131 13/56: move the whole thing into a minor mode
Date: Mon, 6 Jun 2022 11:58:52 -0400 (EDT)

branch: elpa/org-auto-tangle
commit 70e5e3d1318c2bf78fbd91df44f311af0e9d4e68
Author: Unknown <domatropic@localhost.localdomain>
Commit: Unknown <domatropic@localhost.localdomain>

    move the whole thing into a minor mode
---
 org-auto-tangle.el | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/org-auto-tangle.el b/org-auto-tangle.el
index 781c8452d4..2391f0e925 100644
--- a/org-auto-tangle.el
+++ b/org-auto-tangle.el
@@ -54,11 +54,6 @@
 (require 'async)
 
 
-(defcustom org-auto-tangle-tangle-on-save t
-  "Enables the parsing of auto-tanlge option for org files."
-  :type 'boolean
-  :group 'auto-tangle)
-
 (defun org-auto-tangle-find-value (buffer)
   "Search the `auto_tangle' property in BUFFER and extracts it when found."
   (with-current-buffer buffer
@@ -84,16 +79,18 @@
        (message (concat ,message-string
                         (format "%s seconds" tangle-time)))))))
 
-
-
-(add-hook 'org-mode-hook
-          (lambda ()
-           (when org-auto-tangle-tangle-on-save
-             (add-hook 'after-save-hook
-                       (lambda () (when (and (org-auto-tangle-find-value 
(current-buffer))
-                                             (not (string= 
(org-auto-tangle-find-value(current-buffer)) "nil")))
-                                     (org-auto-tangle-async 
(buffer-file-name))))
-                       nil 'local))))
+(define-minor-mode org-auto-tangle-mode
+  "Automatically tangle org-mode files with the option #+auto_tangle: t."
+  :lighter "org-auto-tangle"
+
+  (add-hook 'org-mode-hook
+            (lambda ()
+             (when org-auto-tangle-mode
+               (add-hook 'after-save-hook
+                         (lambda () (when (and (org-auto-tangle-find-value 
(current-buffer))
+                                               (not (string= 
(org-auto-tangle-find-value(current-buffer)) "nil")))
+                                       (org-auto-tangle-async 
(buffer-file-name))))
+                         nil 'local)))))
 
 (provide 'org-auto-tangle)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]