emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] Treat :tangle-mode as an octal value not integer


From: Jeremy Cowgar
Subject: [PATCH] Treat :tangle-mode as an octal value not integer
Date: Tue, 28 Sep 2021 10:54:48 -0400

As an org user I would expect :tangle-mode 0660 to produce a file that
has user rw, group rw, other nothing. Instead, what really happens
currently is 0660 is treated as an integer which is actually
3140. This produces unexpected file permissions.

Prior to this patch to have rw,rw,none, one has to convert 0660 octal
into an integer (432) and then specify :tangle-mode 432. This is counter
intuitive and requires multiple steps.

After this patch, one just specifies the octal code as you do with
chmod. :tangle-mode 0660 results in a file that is rw,rw,none.
---
 lisp/ob-tangle.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2dd1d031c..154bd5145 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -246,7 +246,12 @@ matching a regular expression."
                             (get-spec (lambda (name) (cdr (assq name (nth 4 
spec)))))
                             (she-bang (let ((sheb (funcall get-spec :shebang)))
                                         (when (> (length sheb) 0) sheb)))
-                            (tangle-mode (funcall get-spec :tangle-mode)))
+                            (tangle-mode (let ((tmode (funcall get-spec 
:tangle-mode)))
+                                            (when tmode
+                                              ;; convert integer representing 
an octal
+                                              ;; number to its real octal value
+                                              (string-to-number
+                                               (number-to-string tmode) 8)))))
                        (unless (string-equal block-lang lang)
                          (setq lang block-lang)
                          (let ((lang-f (org-src-get-lang-mode lang)))
-- 
2.30.2




reply via email to

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