emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Treat :tangle-mode as an octal value not integer
@ 2021-09-28 14:54 Jeremy Cowgar
  2021-09-29  6:39 ` tomas
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Jeremy Cowgar @ 2021-09-28 14:54 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Jeremy Cowgar

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



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-11-18 12:06 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 14:54 [PATCH] Treat :tangle-mode as an octal value not integer Jeremy Cowgar
2021-09-29  6:39 ` tomas
2021-09-29  6:55   ` Jeremy Cowgar
2021-09-29  7:21     ` tomas
2021-09-29  7:52     ` dkrm
2021-09-29  8:22       ` tomas
2021-09-29  9:29         ` Gyro Funch
2021-09-29 11:07           ` tomas
2021-09-29 13:17             ` Jeremy Cowgar
2021-09-29 13:55               ` tomas
2021-09-29  7:10   ` Greg Minshall
2021-09-29 11:35 ` Bastien
2021-09-29 13:48 ` Timothy
2021-09-29 14:26   ` tomas
2021-09-29 14:58     ` Timothy
2021-09-29 15:13       ` Jeremy Cowgar
2021-09-30 18:13         ` Timothy
2021-09-29 15:14       ` tomas
2021-09-29 17:18     ` Greg Minshall
2021-09-29 18:15       ` tomas
2021-11-18 12:04       ` Timothy

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).