[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-auto-tangle 109e39f3df 02/56: coded an initial version
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-auto-tangle 109e39f3df 02/56: coded an initial version of org-auto-tangle |
Date: |
Mon, 6 Jun 2022 11:58:50 -0400 (EDT) |
branch: elpa/org-auto-tangle
commit 109e39f3df2b2f864c5ab8346178d2955993553c
Author: lispy-dobby <yilkalargawworkneh@gmail.com>
Commit: lispy-dobby <yilkalargawworkneh@gmail.com>
coded an initial version of org-auto-tangle
---
org-auto-tangle.el | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/org-auto-tangle.el b/org-auto-tangle.el
new file mode 100644
index 0000000000..544bafafe9
--- /dev/null
+++ b/org-auto-tangle.el
@@ -0,0 +1,97 @@
+;;; org-auto-tangle --- Basically it automatically tangles an org file based
on an org option
+
+;; Author: Yilkal Argaw
+;; URL: https://github.com/yilkalargaw/auto-tangle
+;; Version: 0.0.1
+
+;; This file is not part of GNU Emacs
+
+;; Copyright <2021> <Yilkal Argaw>
+;;
+;; Redistribution and use in source and binary forms, with or without
+;; modification, are permitted provided that the following conditions are
+;; met:
+;;
+;;
+;; 1. Redistributions of source code must retain the above copyright
+;; notice, this list of conditions and the following disclaimer.
+;;
+;;
+;; 2. Redistributions in binary form must reproduce the above copyright
+;; notice, this list of conditions and the following disclaimer in the
+;; documentation and/or other materials provided with the distribution.
+
+;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+;; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+;; USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+;; OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+;; SUCH DAMAGE.
+
+
+;;; Commentary:
+;; It is common to want to tangle org files everytime you save your changes,
+;; especially for common tangled init files. So this program allows you to
+;; do so using #+auto_tangle option in an org file. It also does so
asynchronously
+;; so it does let you emacs session hang
+
+;;; Usage:
+
+;; - Add #+auto_tangle:t to your tangled org file
+;; - Make changes to the emacs file and save your changes
+
+
+;;; Code:
+
+(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)
+
+(add-hook 'org-mode-hook
+ (lambda ()
+ (when auto-tangle-tangle-on-save
+ (defun org-auto-tangle-find-value (buffer)
+ "Search the `auto_tangle' property in BUFFER and extracts it
when found."
+ (with-current-buffer buffer
+ (save-restriction
+ (widen)
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward "^#\\+auto_tangle: \\(.*\\)" nil
:noerror)
+ (match-string 1))))))
+
+
+ (defun org-auto-tangle-async (file)
+ "Invoke `org-babel-tangle-file' asynchronously."
+ (message "Tangling %s..." (buffer-file-name))
+ (async-start
+ (let ((args (list file)))
+ `(lambda ()
+ (require 'org)
+ (let ((start-time (current-time)))
+ (apply #'org-babel-tangle-file ',args)
+ (format "%.2f" (float-time (time-since start-time))))))
+ (let ((message-string (format "Tangling %S completed after "
file)))
+ `(lambda (tangle-time)
+ (message (concat ,message-string
+ (format "%s seconds" tangle-time)))))))
+
+ (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)
+
+;;; org-auto-tangle.el ends here
- [nongnu] branch elpa/org-auto-tangle created (now c3cbde261f), ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 0dd6563ef7 01/56: added a .gitignore file., ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 4f023809be 04/56: added License.org, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 817e41897b 20/56: moved trailing bracket, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle ff1a331e37 08/56: minor changes to satisfy pkg-lint, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle ddc2dd65ee 18/56: added space to lighter and removed changed to a shorter one, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 109e39f3df 02/56: coded an initial version of org-auto-tangle,
ELPA Syncer <=
- [nongnu] elpa/org-auto-tangle a92a19a760 03/56: added README.org, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 2fd7145e4a 29/56: removed the nil from remove hook, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 5cc389669d 27/56: removed concat function and instead used formatted functions, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 9d47eabdc5 26/56: removed trailing bracket, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 310489018f 30/56: Fix URL, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle bafad8a79b 33/56: Merge pull request #3 from kamoii/patch-2, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle ed36045140 31/56: Fix README, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 2982fc8449 35/56: updated the commentary section, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 54dc42d581 36/56: updated the ```Usage:``` section, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 820cdd19e6 37/56: used a more consice major mode check, ELPA Syncer, 2022/06/06