[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-auto-tangle 13aaef275f 42/56: Merge pull request #5 fr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-auto-tangle 13aaef275f 42/56: Merge pull request #5 from zzamboni/org-auto-tangle-default |
Date: |
Mon, 6 Jun 2022 11:58:54 -0400 (EDT) |
branch: elpa/org-auto-tangle
commit 13aaef275fdbea684cd22739dbdde6208ae1eced
Merge: 5da721fff9 f1898c3d79
Author: lispy-dobby <yilkalargawworkneh@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #5 from zzamboni/org-auto-tangle-default
Add org-auto-tangle-default variable
---
README.org | 6 ++++--
org-auto-tangle.el | 32 +++++++++++++++++++++++---------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index 0f26385397..768ddb2981 100644
--- a/README.org
+++ b/README.org
@@ -24,18 +24,20 @@ Simply require the package in you emacs init and hook it
into org-mode.
or you can use use-package
#+begin_src emacs-lisp
-
(use-package org-auto-tangle
:load-path "site-lisp/org-auto-tangle/" ;; this line is necessary only if
you cloned the repo in your site-lisp directory
:defer t
:hook (org-mode . org-auto-tangle-mode))
-
#+end_src
If the minor mode is on, it will try to automatically tangle
your org files if they contain a non nil value for the
~#+auto_tangle:~ option.
+You can configure auto-tangle as the default behavior for all org buffers by
+setting the ~org-auto-tangle-default~ variable to ~t~. In this case, you can
disable
+it for some buffers by setting the ~#+auto_tangle:~ option to ~nil~.
+
* License
This package (i.e. ~org-auto-tangle~) is licensed under the the 2-Clause BSD
License.
diff --git a/org-auto-tangle.el b/org-auto-tangle.el
index 03bb0190db..a6a6fdf9a5 100644
--- a/org-auto-tangle.el
+++ b/org-auto-tangle.el
@@ -48,6 +48,12 @@
(require 'async)
+(defvar org-auto-tangle-default nil
+ "Default behavior of org-auto-tangle.
+
+If nil (default), auto-tangle will only happen on buffers with
+the `#+auto_tangle: t' keyword. If t, auto-tangle will happen on
+all Org buffers unless `#+auto_tangle: nil' is set.")
(defun org-auto-tangle-find-value (buffer)
"Search the `auto_tangle' property in BUFFER and extracts it when found."
@@ -56,7 +62,7 @@
(widen)
(save-excursion
(goto-char (point-min))
- (when (re-search-forward "^#\\+auto_tangle:[ \t]+\\([^ \f\t\n\r\v]+\\)[
\t]*" nil :noerror)
+ (when (re-search-forward "^#\\+auto_tangle: \\(.*\\)" nil :noerror)
(match-string 1))))))
(defun org-auto-tangle-async (file)
@@ -73,21 +79,29 @@
`(lambda (tangle-time)
(message "%s %s seconds",message-string tangle-time)))))
-(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 (eq major-mode '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))))
+(defun org-auto-tangle-tangle-if-needed ()
+ "Call org-auto-tangle-async if needed.
+
+Tangle will happen depending on the value of
+`org-auto-tangle-default' and on the presence and value of the
+`#+auto_tangle' keyword in the current buffer. If present,
+`#+auto_tangle' always overrides `org-auto-tangle-default'."
+ (let ((auto-tangle-kw (org-auto-tangle-find-value)))
+ (when (and (eq major-mode 'org-mode)
+ (or (and auto-tangle-kw
+ (not (string= auto-tangle-kw "nil")))
+ (and (not auto-tangle-kw)
+ org-auto-tangle-default)))
+ (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"
(if org-auto-tangle-mode
- (add-hook 'after-save-hook #'org-auto-tangle-tangle-if-tag-exists
+ (add-hook 'after-save-hook #'org-auto-tangle-tangle-if-needed
nil 'local)
- (remove-hook 'after-save-hook #'org-auto-tangle-tangle-if-tag-exists
'local)))
+ (remove-hook 'after-save-hook #'org-auto-tangle-tangle-if-needed 'local)))
(provide 'org-auto-tangle)
- [nongnu] elpa/org-auto-tangle cebc4bbf73 44/56: Improve auto_tangle regex, (continued)
- [nongnu] elpa/org-auto-tangle cebc4bbf73 44/56: Improve auto_tangle regex, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 50292af50d 50/56: Merge pull request #10 from juergenhoetzel/non-essential, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle aa6afc302f 49/56: Prevent Tramp from prompting for user passwords, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle ad3c332f06 52/56: Merge pull request #13 from fredericgiquel/babel-evaluation, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 8883015f00 09/56: fixed Emacs references by using M-x-checkdoc, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 15884227bb 16/56: got it working again by moving the hook to inner block, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle b9c28533ee 21/56: added a remove-hook if org-auto-tangle-mode is nil, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle c593c5d028 28/56: added local to remove hook, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 7e9842f1cb 24/56: Update README.org, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle c3cbde261f 56/56: Merge pull request #17 from RampedIndent/patch-1, ELPA Syncer, 2022/06/06
- [nongnu] elpa/org-auto-tangle 13aaef275f 42/56: Merge pull request #5 from zzamboni/org-auto-tangle-default,
ELPA Syncer <=