emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Accept more :tangle-mode specification forms
@ 2021-09-30 18:14 Timothy
  2021-10-01  1:24 ` Tom Gillespie
  2021-10-05 14:45 ` Timothy
  0 siblings, 2 replies; 14+ messages in thread
From: Timothy @ 2021-09-30 18:14 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]

Hello,

Currently, the only way to set a file mode when tangling seems to be 
:tangle-mode (identity #o755)

In a [prior thread], Jeremy proposed that :tangle-mode should convert octal
number strings to the required decimal form. I think we should go further, and
so have prepared the attached patch based on a snippet I shared in the thread.

To quote the docstring of the new function I’m introducing, this patch now
accepts the following :tangle-mode forms:
• an integer (returned without modification)
• “#o755” (elisp-style octal)
• “0755” (c style octal)
• “755” (chmod style octal)
• “rwxrw-r–” (ls style specification)
• “a=rw,u+x” (chmod style)
• “rwx” (interpreted as “u=rwx”)

Why be so permissive? I’d refer you to my reasoning in the prior thread:

I think there are a few arguably “sensible” formats that a user could reasonably
assume, and if we can support most of them without introducing ambiguity in
parsing or interpretation (and I think we can), can’t we make everyone happy?

All the best,
Timothy


[prior thread] <https://list.orgmode.org/20210928145448.245883-1-jeremy@cowgar.com/>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-tangle-Accept-more-tangle-mode-forms.patch --]
[-- Type: text/x-patch, Size: 3691 bytes --]

From 5087de0d70151c33d66eb13dda84d78a361d7053 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Fri, 1 Oct 2021 02:02:22 +0800
Subject: [PATCH] ob-tangle: Accept more :tangle-mode forms

* lisp/ob-tangle.el (org-babel-tangle): Accept many more forms for
:tangle-mode, including octal strings (#o755, 0755, 755), ls forms (rwx,
rw-r--r--), and chmod forms (a=rw,u+x).  The interpretation of the input
is now handled by the new function `org-babel-interpret-file-mode' which
references the new variable `org-babel-tangle-default-mode' when
considering relative mode forms.
---
 lisp/ob-tangle.el | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2dd1d031c..28a235429 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -140,6 +140,14 @@ (defcustom org-babel-process-comment-text 'org-remove-indentation
   :version "24.1"
   :type 'function)
 
+(defcustom org-babel-tangle-default-mode #o544
+  "The default mode used for tangled files, as an integer.
+The default value 356 correspands to the octal #o544, which is
+read-write permissions for the user, read-only for everyone else."
+  :group 'org-babel
+  :version "9.6"
+  :type 'integer)
+
 (defun org-babel-find-file-noselect-refresh (file)
   "Find file ensuring that the latest changes on disk are
 represented in the file."
@@ -255,7 +263,7 @@ (defun org-babel-tangle (&optional arg target-file lang-re)
 		        (when she-bang
 			  (unless tangle-mode (setq tangle-mode #o755)))
 		        (when tangle-mode
-			  (add-to-list 'modes tangle-mode))
+			  (add-to-list 'modes (org-babel-interpret-file-mode tangle-mode)))
 		        ;; Possibly create the parent directories for file.
 		        (let ((m (funcall get-spec :mkdirp)))
 			  (and m fnd (not (string= m "no"))
@@ -298,6 +306,38 @@ (defun org-babel-tangle (&optional arg target-file lang-re)
 	   path-collector))
 	path-collector))))
 
+(defun org-babel-interpret-file-mode (mode)
+  "Determine the integer representation of a file MODE specification.
+The following forms are currently recognised:
+- an integer (returned without modification)
+- \"#o755\" (elisp-style octal)
+- \"0755\" (c style octal)
+- \"755\" (chmod style octal)
+- \"rwxrw-r--\" (ls style specification)
+- \"a=rw,u+x\" (chmod style) *
+- \"rwx\" (interpreted as \"u=rwx\") *
+
+* The interpretation of these forms relies on `file-modes-symbolic-to-number',
+  and uses `org-babel-tangle-default-mode' as the base mode."
+  (cond
+   ((integerp mode) mode)
+   ((not (stringp mode))
+    (error "File mode %S not recognised as a valid format." mode))
+   ((string-match-p "^0?[0-7][0-7][0-7]$" mode)
+    (string-to-number mode 8))
+   ((string-match-p "^#o[0-7][0-7][0-7]$" mode)
+    (string-to-number (substring mode 2) 8))
+   ((string-match-p "^[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\(,[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\)*$" mode)
+    (file-modes-symbolic-to-number mode org-babel-tangle-default-mode))
+   ((string-match-p "^[rwx-]\\{3\\}$" mode)
+    (file-modes-symbolic-to-number (concat "u=" mode) org-babel-tangle-default-mode))
+   ((string-match-p "^[rwx-]\\{9\\}$" mode)
+    (file-modes-symbolic-to-number (concat  "u=" (substring mode 0 3)
+                                            ",g=" (substring mode 3 6)
+                                            ",a=" (substring mode 6 9))
+                                   0))
+   (t (error "File mode %S not recognised as a valid format." mode))))
+
 (defun org-babel-tangle-clean ()
   "Remove comments inserted by `org-babel-tangle'.
 Call this function inside of a source-code file generated by
-- 
2.33.0


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-09-30 18:14 [PATCH] Accept more :tangle-mode specification forms Timothy
@ 2021-10-01  1:24 ` Tom Gillespie
  2021-10-01  6:59   ` Timothy
  2021-10-01  8:39   ` Christian Moe
  2021-10-05 14:45 ` Timothy
  1 sibling, 2 replies; 14+ messages in thread
From: Tom Gillespie @ 2021-10-01  1:24 UTC (permalink / raw)
  To: Timothy; +Cc: Org Mode List

I strongly oppose this patch. It adds far too much complexity to the
org grammar. Representation of numbers is an extremely nasty part of
nearly every language, and I suggest that org steer well clear of
trying to formalize this. With an eye to future portability I suggest
that no special cases be given to something as important for security
as tangle mode without very careful consideration. Emacs lisp closures
have clear semantics in Org and the number syntax is clear. If users
are concerned about the verbosity of (identity #o0600) they could go
with the sorter (or #o0600). Best,
Tom


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01  1:24 ` Tom Gillespie
@ 2021-10-01  6:59   ` Timothy
  2021-10-01  8:00     ` Stefan Nobis
  2021-10-01  8:39   ` Christian Moe
  1 sibling, 1 reply; 14+ messages in thread
From: Timothy @ 2021-10-01  6:59 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 2738 bytes --]

Hi Tom,

Thanks for giving me your thoughts on this. I have a few thoughts in response :)

> I strongly oppose this patch. It adds far too much complexity to the
> org grammar. Representation of numbers is an extremely nasty part of
> nearly every language, and I suggest that org steer well clear of
> trying to formalize this.

I’m not quite sure I see your point here, as I don’t see how this affects the
grammar of Org at all. The :attribute value syntax is unaffected, this just
changes how a particular :attribute’s value is interpreted. Attribute specific
interpretation is normal, with “:file ~/hello” you expect `~' to be interpreted as
`$HOME', but were I to give “:session ~/hello” I would not expect `~' to be
expanded etc.

Similarly, with regard to the representation of numbers, I’m not sure that
applies here, as the value is still a string not a number, it’s just
interpreted. Arguably, we’re not even representing numbers here but representing
file permissions which are currently abstracted by a numerical representation.

> With an eye to future portability I suggest that no special cases be given to
> [snipped for later] tangle mode without very careful consideration.

Mmmm, we defiantly want to think about what options we allow for, but I don’t
think that precludes us from accepting more than one common permissions
representations.

> [the snip]: something as important for security as tangle mode

Thank you for considering potential security implications, this is something
that I didn’t consider when writing the patch, but if we allow for a confusing
format that could deceive people into tangling files in modes they didn’t
realise they were tangling to.

I think there are two relevant points here
⁃ If we only allow very widely-understood, standard representations, I think the
  risk of people misunderstanding a :tangle-mode value is acceptably low
⁃ If you consider things this way, since arbitrary lisp closures are currently
  permitted, one can already trivially create a much more misleading
  :tangle-mode value with the current code.

> Emacs lisp closures have clear semantics in Org and the number syntax is clear

See my earlier comments on the semantics being unaffected, and this not being a
number syntax.

> If users are concerned about the verbosity of (identity #o0600) they could go
> with the sorter (or #o0600).

Perhaps, but I personally find it easier to interpret “rwxr-xr–” for example
than “(or #o754)”, and I feel quite confident in guessing that
a. I’m not alone
b. Nobody that understands “#o754” will have difficult understanding “rwxr-xr–”

All the best,
Timothy

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01  6:59   ` Timothy
@ 2021-10-01  8:00     ` Stefan Nobis
  2021-10-01 10:05       ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Nobis @ 2021-10-01  8:00 UTC (permalink / raw)
  To: emacs-orgmode

Timothy <tecosaur@gmail.com> writes:

> Thank you for considering potential security implications

BTW: Security-wise I would argue to even forbid the integer case. From
my view next to nobody uses and is used to the decimal codes of file
modes. So this decimal integer representation is the most error prone,
I would say. The more explicit (like "rwx-r-x-r--" etc.) the better.

I would also tend to only support something like "#o755" and forbid
"755" as well as "0755", just to be more explicit and to avoid
misinterpretation.

But all in all I support your patch and your arguments for the change.
Currently, I also do not really see why this attribute value (just a
string if the integer case is forbidden) will make the Org syntax more
complex.

-- 
Until the next mail...,
Stefan.


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01  1:24 ` Tom Gillespie
  2021-10-01  6:59   ` Timothy
@ 2021-10-01  8:39   ` Christian Moe
  1 sibling, 0 replies; 14+ messages in thread
From: Christian Moe @ 2021-10-01  8:39 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: Org Mode List, Timothy


Tom Gillespie writes:

> I strongly oppose this patch. It adds far too much complexity to the
> org grammar.  Representation of numbers is an extremely nasty part of
> nearly every language, and I suggest that org steer well clear of
> trying to formalize this.

I'd like to understand these objections better. Aren't you overstating
what is at issue? The patch allows a single keyword option,
:tangle-mode, to accept a few different ways of setting file
permissions. I'm not sure that amounts to formalizing representation of
numbers in Org, or even modifying Org grammar as such. (And I can't
think of other parts of Org where this would be relevant, so I wouldn't
expect demands for further feature creep.)

> With an eye to future portability I suggest
> that no special cases be given to something as important for security
> as tangle mode without very careful consideration.

When you say portability, what are you thinking about? If you're talking
about tangling Org-Babel code with other processors than Emacs Org-mode,
this seems like fairly trivial functionality to reproduce. In fact,
wouldn't this be easier than the current arrangements, which would
require the processor to be able to evaluate an arbitrary Emacs Lisp
expression outside Emacs?

What is the added security problem here, given that file permissions can
already be set by tangle mode?

I suppose that the greater complexity of the patch provides maintainers
with somewhat more opportunities for making code errors. And the greater
choice of representations perhaps gives the user more opportunities for
making user errors (though speaking strictly for myself, I'm more likely
to make those errors calculating octals than using the more intuitive
representations Timothy is helpfully making available). But these
problems seem marginal to me. Are there others?

> Emacs lisp closures have clear semantics in Org and the number syntax
> is clear. If users are concerned about the verbosity of (identity
> #o0600) they could go with the sorter (or #o0600).

But why would anyone want to write a lisp closure a number literal would
suffice? It's not what a user would expect.

Yours,
Christian


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01  8:00     ` Stefan Nobis
@ 2021-10-01 10:05       ` Eric S Fraga
  2021-10-01 10:29         ` tomas
  0 siblings, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2021-10-01 10:05 UTC (permalink / raw)
  To: emacs-orgmode

> BTW: Security-wise I would argue to even forbid the integer case. 

Completely agree with this.  If you look at the chmod(1) man page, only
symbolic and octal cases are described.  These are the options most
people will be comfortable with as a result.

> I would also tend to only support something like "#o755" and forbid
> "755" as well as "0755", just to be more explicit and to avoid
> misinterpretation.

Here I disagree; again, in the manual, the notation used, as an example,
is 0755.  I see no need for the #o syntax personally.  This is
especially true if we don't allow integer (i.e. base 10) values.  

-- 
: Eric S Fraga via Emacs 28.0.50, Org 9.5-g9a4a24
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01 10:05       ` Eric S Fraga
@ 2021-10-01 10:29         ` tomas
  2021-10-01 18:04           ` Tom Gillespie
  0 siblings, 1 reply; 14+ messages in thread
From: tomas @ 2021-10-01 10:29 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]

On Fri, Oct 01, 2021 at 11:05:17AM +0100, Eric S Fraga wrote:

[...]

> > I would also tend to only support something like "#o755" and forbid
> > "755" as well as "0755", just to be more explicit and to avoid
> > misinterpretation.
> 
> Here I disagree; again, in the manual, the notation used, as an example,
> is 0755.  I see no need for the #o syntax personally.  This is
> especially true if we don't allow integer (i.e. base 10) values.  

Chiming in, I might be the culprit (in this thread) for the #o755
idea: I proposed it only because I was seeing that the argument
was being interpreted as (a decimal representation of) an int, and
thought it to be a good idea to stay compatible to Elisp notation.

Since then, the movement was rather towards consistency with the
shell and coreutils (which also makes sense, perhaps more [1]).

I wouldn't mix both :)

Cheers

[1] If you get over the wart that there is a little embedded
   domain specific language in the arg of this one specific
   keyword. I can also understand Tom Gillespie's hesitations,
   since he's trying to formalise the grammar.

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01 10:29         ` tomas
@ 2021-10-01 18:04           ` Tom Gillespie
  2021-10-01 18:14             ` Timothy
  0 siblings, 1 reply; 14+ messages in thread
From: Tom Gillespie @ 2021-10-01 18:04 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: tomas, mail, TEC

> I'd like to understand these objections better. Aren't you overstating
what is at issue?

Yes, after hitting send I realized I overstated my position a bit.
In the meantime the comments in this thread are encouraging,
however I have finally figured out what I was really trying to say.

tl;dr file permission modes are not universal and should thus not
be part of the Org implementation, Org itself knows nothing about
files or permissions, it is the system that Org is running in/on.
Therefore, so long as we make it abundantly clear that the
value for :tangle-mode is not expected to be portable and that
it is always up to the user to ensure correct behavior, then we
are ok. I'm not happy about this conclusion from a security
perspective, but it isn't really worse than the situation we have
right now.


As many have pointed out, the grammar itself will not be affected.
However, other parts of the spec will. In general my objective is to
try to reduce the number of special cases that an org implementation
has to know about and delegate them to something else.

However in this case it is a bit tricky because of the security implications
and due to the fact that octal modes for file permissions are NOT universal
and should not be expected to be universal!

I actually think that my gut reaction was correct, but was expressed
in the wrong way.

Unix file modes are not universal and should thus not be encoded as
part of a portable document format. This means that it is up to the
user to know what representation is suitable.

Right now that representation is delegated to Emacs, because Emacs
handles file permissions for Org, and Emac's language for modes is
octal.

There are some octal modes that do not translate on Windows, and cannot
be correctly set. There will (hopefully) be some happy day in the future
where there is an operating system that will run Org babel where octal
file modes do not exist at all!

Therefore I suggest that we do not enshrine a particularly obscure way
of expressing file modes into Org itself. Right now Org is confined to
Emacs' representations, which in a sense protects Org from becoming
too ossified by bad designs of the past --- Emacs can keep all that
for us!

If we want a more user friendly syntax for this I would suggest that we do
something like what has been done for Org babel :results, i.e. like
:tangle-mode read write execute, unfortunately that does not compose
well at all with user, group, and other and becomes exceedingly verbose.


Final conclusion, after all that rambling, is that I'd actually be ok with
any of the solutions proposed, so long as it is clear that :tangle-mode
will always be implementation dependent, and may or may not be
meaningful depending on which operating system you are using.
Unfortunate for security, but I don't see any way around tha. The
best we could do for security would be for implementations to
test the file modes after tangling to ensure that they match,
which is more important I think.

That said, reducing the number of forms as Eric suggests would
be a happy medium.

Best!
Tom


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-01 18:04           ` Tom Gillespie
@ 2021-10-01 18:14             ` Timothy
  0 siblings, 0 replies; 14+ messages in thread
From: Timothy @ 2021-10-01 18:14 UTC (permalink / raw)
  To: Tom Gillespie; +Cc: tomas, emacs-orgmode, mail

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

Hi Tom,

Thanks for going through the replies so far and refining your thoughts.

> *snip a whole bunch of comments*

I think I’m of the same mind as you that if we try to mentally separate Org the
markup format and Org the emacs mode, the format should not specify the
interpretation of the :tangle-mode value.

I think the best way to have it would be,
⁃ Org the format, :tangle-mode takes a value representing the file permissions
  the tangled file should have. Optional: here are some common examples that
  might be recognised
⁃ Org the emacs mode, :tangle-mode’s value is interpreted like so (…)

> That said, reducing the number of forms as Eric suggests would
> be a happy medium.

Indeed, I’ve basically supported every form I could think of. I’m currently
inclined to cut it down to:
• 755
• “rwxrw-r–” (`ls -l' style)
• chmod style with `org-babel-tangle-default-mode' and `file-modes-symbolic-to-number'

Maybe with (if anybody says they would like this)
• #o755 (elisp octal)
• 0755 (C octal)
• “rwx” = user perm, bit-or’d with `org-babel-tangle-default-mode' for the rest
  (i.e. `org-babel-tangle-default-mode', but not exceeding the user perm)

All the best,
Timothy

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-09-30 18:14 [PATCH] Accept more :tangle-mode specification forms Timothy
  2021-10-01  1:24 ` Tom Gillespie
@ 2021-10-05 14:45 ` Timothy
  2021-10-05 15:54   ` unknown@email.com
                     ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Timothy @ 2021-10-05 14:45 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

Hi  Everyone,

It feels like we’re near a patch that would be good to merge. I would very much
like to get feedback on what I proposed in my reply to Tom though (see below).

>> That said, reducing the number of forms as Eric suggests would
>> be a happy medium.
>
> Indeed, I’ve basically supported every form I could think of. I’m currently
> inclined to cut it down to:
> • 755
> • “rwxrw-r–” (`ls -l’ style)
> • chmod style with `org-babel-tangle-default-mode’ and `file-modes-symbolic-to-number’
>
> Maybe with (if anybody says they would like this)
> • #o755 (elisp octal)
> • 0755 (C octal)
> • “rwx” = user perm, bit-or’d with `org-babel-tangle-default-mode’ for the rest
>   (i.e. `org-babel-tangle-default-mode’, but not exceeding the user perm)

All the best,
Timothy

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-05 14:45 ` Timothy
@ 2021-10-05 15:54   ` unknown@email.com
  2021-10-05 16:13     ` Timothy
  2021-10-05 16:06   ` tomas
  2021-10-06 11:59   ` Max Nikulin
  2 siblings, 1 reply; 14+ messages in thread
From: unknown@email.com @ 2021-10-05 15:54 UTC (permalink / raw)
  To: emacs-orgmode

Timothy <tecosaur@gmail.com> writes:

> It feels like we’re near a patch that would be good to merge. I would very much
> like to get feedback on what I proposed in my reply to Tom though (see below).
>
>> Maybe with (if anybody says they would like this)
>> • #o755 (elisp octal)
>> • 0755 (C octal)
>> • “rwx” = user perm, bit-or’d with `org-babel-tangle-default-mode’ for the rest

I think this is a good idea and don't see any problems (or other
suggestions) with the proposed formats.

The existing (identity #o0755) will still function, correct?
i.e. backward compatibility.

--
Jeremy Cowgar


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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-05 14:45 ` Timothy
  2021-10-05 15:54   ` unknown@email.com
@ 2021-10-05 16:06   ` tomas
  2021-10-06 11:59   ` Max Nikulin
  2 siblings, 0 replies; 14+ messages in thread
From: tomas @ 2021-10-05 16:06 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

On Tue, Oct 05, 2021 at 10:45:59PM +0800, Timothy wrote:
> Hi  Everyone,
> 
> It feels like we’re near a patch that would be good to merge. I would very much
> like to get feedback on what I proposed in my reply to Tom though (see below).

OK. Since I made some noises, I feel compelled to feed back :)

> >> That said, reducing the number of forms as Eric suggests would
> >> be a happy medium.
> >
> > Indeed, I’ve basically supported every form I could think of. I’m currently
> > inclined to cut it down to:
> > • 755
> > • “rwxrw-r–” (`ls -l’ style)
> > • chmod style with `org-babel-tangle-default-mode’ and `file-modes-symbolic-to-number’

This looks perfect to me.

> > Maybe with (if anybody says they would like this)
> > • #o755 (elisp octal)
> > • 0755 (C octal)
> > • “rwx” = user perm, bit-or’d with `org-babel-tangle-default-mode’ for the rest
> >   (i.e. `org-babel-tangle-default-mode’, but not exceeding the user perm)

I wouldn't miss those, having the above. Less is more, IMHO.

Thanks for your work, and for the way you do it. You rock!

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-05 15:54   ` unknown@email.com
@ 2021-10-05 16:13     ` Timothy
  0 siblings, 0 replies; 14+ messages in thread
From: Timothy @ 2021-10-05 16:13 UTC (permalink / raw)
  To: unknown@email.com; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

Hi  Jeremy,

> I think this is a good idea and don’t see any problems (or other
> suggestions) with the proposed formats.
>
> The existing (identity #o0755) will still function, correct?
> i.e. backward compatibility.

It should yes. I’ll double check before I actually push the commit.

All the best,
Timothy

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

* Re: [PATCH] Accept more :tangle-mode specification forms
  2021-10-05 14:45 ` Timothy
  2021-10-05 15:54   ` unknown@email.com
  2021-10-05 16:06   ` tomas
@ 2021-10-06 11:59   ` Max Nikulin
  2 siblings, 0 replies; 14+ messages in thread
From: Max Nikulin @ 2021-10-06 11:59 UTC (permalink / raw)
  To: emacs-orgmode

On 05/10/2021 21:45, Timothy wrote:
>>
>> Indeed, I’ve basically supported every form I could think of. I’m currently
>> inclined to cut it down to:
>> • 755
>> • “rwxrw-r–” (`ls -l’ style)
>> • chmod style with `org-babel-tangle-default-mode’ and `file-modes-symbolic-to-number’
>>
>> Maybe with (if anybody says they would like this)
>> • #o755 (elisp octal)
>> • 0755 (C octal)
>> • “rwx” = user perm, bit-or’d with `org-babel-tangle-default-mode’ for the rest
>>    (i.e. `org-babel-tangle-default-mode’, but not exceeding the user perm)

My opinion (discussion should not mean that I insist) is that since the 
following is currently working

#+begin_src bash :tangle yes :tangle-mode 755
   echo "Hello"
#+end_src

naked numbers (strings looking like numbers) should be forbidden. 
`org-lint' should report such lines and it should be at least warning 
for `org-babel-tagle'.

It is safer to define macros (namely macros, not just functions) that 
check argument type, e.g.

(filemode-octal "755") ; OK
(filemode-octal #o755) ; OK
(filemode-octal 755) ; Error

Maybe they should return not just raw number but e.g. tagged pair
(#o755 . 'filemode)

The point is that it should be hard to pass decimal or hex number 
(though it might be possible through a function generating tagged cons).

It is better to be a bit more verbose and explicit than to allow weird 
hard to notice later errors. Problem cases are too close to valid ones 
with current behavior.




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

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

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 18:14 [PATCH] Accept more :tangle-mode specification forms Timothy
2021-10-01  1:24 ` Tom Gillespie
2021-10-01  6:59   ` Timothy
2021-10-01  8:00     ` Stefan Nobis
2021-10-01 10:05       ` Eric S Fraga
2021-10-01 10:29         ` tomas
2021-10-01 18:04           ` Tom Gillespie
2021-10-01 18:14             ` Timothy
2021-10-01  8:39   ` Christian Moe
2021-10-05 14:45 ` Timothy
2021-10-05 15:54   ` unknown@email.com
2021-10-05 16:13     ` Timothy
2021-10-05 16:06   ` tomas
2021-10-06 11:59   ` Max Nikulin

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 NNTP newsgroup(s).