Re: Possible to set block switches "globally"?

2024-07-10 Thread Ihor Radchenko
Ihor Radchenko  writes:

>> I tried searching for where switches are parsed in the code, but
>> couldn't find much. Could you provide me with some pointers and files I
>> should be looking at?
>
> `org-element-src-block-parser' and `org-element-example-block-parser'.

Hi João,
It has been a while since the last message in this thread.
May I know if you are still working on this?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Possible to set block switches "globally"?

2024-05-04 Thread Tom Gillespie
> I think that we can take names from the parser internals:

I had a similar thought immediately after I sent my previous email.

>  :number-lines
>  :preserve-indent
>  :retain-labels
>  :use-labels
>  :label-fmt

I thought that we might be able to combine :retain-labels
and :use-labels, but now I understand that :use-labels
is as opposed to line numbers. So think think that
using them as is is probably the best approach.

Defaults are effectively
:number-lines no
:preserve-indent (identity org-src-preserve-indentation)
:retain-labels yes
:use-labels yes
:label-fmt (or)



Re: Possible to set block switches "globally"?

2024-05-04 Thread Ihor Radchenko
João Pedro  writes:

>> :number-lines (yes|no|continue) as João proposes
>> :indent   (preserve|align|???) not sure about naming
>> :labels  (link|keep|remove|remove-whitespace)
>> :label-format  regexp-string
>
> Yeah, as Ihor pointed out I did forget about -i, though I'm not really
> sure what that does.

I think that we can take names from the parser internals:

 :number-lines
 :preserve-indent
 :retain-labels
 :use-labels
 :label-fmt

:preserve-indent is a per-block setting of
`org-src-preserve-indentation' variable.

> I tried searching for where switches are parsed in the code, but
> couldn't find much. Could you provide me with some pointers and files I
> should be looking at?

`org-element-src-block-parser' and `org-element-example-block-parser'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Possible to set block switches "globally"?

2024-05-03 Thread João Pedro
Em sexta, 03/05/2024 às 10:12 (-07), Tom Gillespie  escreveu:

> Hi,
>Thanks for getting things going on this again João.

No problem! I've been meaning to get my feet wet on some Org-mode
hacking for a while now.

> Based on what is in org-element-example-block-parser
> and org-element-src-block-parser I think
>
> :number-lines (yes|no|continue) as João proposes
> :indent   (preserve|align|???) not sure about naming
> :labels  (link|keep|remove|remove-whitespace)
> :label-format  regexp-string

Yeah, as Ihor pointed out I did forget about -i, though I'm not really
sure what that does.

> Defaults would be :number-lines no, :indent align,
> :labels remove-whitespace and :label-format would
> inherit from the default.
>
> The remove-whitespace option would remove the label
> itself along with any whitespace leading up to it, this
> avoids the user needing to specify the leading whitespace
> in :label-format. The remove option by itself is retained
> in the event that someone has aligned their labels and
> wants to retain the whitespace. This may be too complex
> though and remove-whitespace is not needed because
> :label-format can be modified as needed.
>
> Header arguments need to have a single value, so I think
> we should split :labels and :label-format, that way users
> can also specify :label-format without having to specify
> :labels first (otherwise there is ambiguity about what a single
> argument :labels means.

Sure, makes sense to separate it.

I tried searching for where switches are parsed in the code, but
couldn't find much. Could you provide me with some pointers and files I
should be looking at?

Cheers,

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Re: Possible to set block switches "globally"?

2024-05-03 Thread Tom Gillespie
Hi,
   Thanks for getting things going on this again João.

Based on what is in org-element-example-block-parser
and org-element-src-block-parser I think

:number-lines (yes|no|continue) as João proposes
:indent   (preserve|align|???) not sure about naming
:labels  (link|keep|remove|remove-whitespace)
:label-format  regexp-string

Defaults would be :number-lines no, :indent align,
:labels remove-whitespace and :label-format would
inherit from the default.

The remove-whitespace option would remove the label
itself along with any whitespace leading up to it, this
avoids the user needing to specify the leading whitespace
in :label-format. The remove option by itself is retained
in the event that someone has aligned their labels and
wants to retain the whitespace. This may be too complex
though and remove-whitespace is not needed because
:label-format can be modified as needed.

Header arguments need to have a single value, so I think
we should split :labels and :label-format, that way users
can also specify :label-format without having to specify
:labels first (otherwise there is ambiguity about what a single
argument :labels means.

Best,
Tom



Re: Possible to set block switches "globally"?

2024-05-03 Thread Ihor Radchenko
João Pedro  writes:

> All right so if I understand correctly, we'd like to deprecate switches
> from the parser and introduce :key val pairs for each switch, but no one
> has gotten to it yet?

Yes

> If that's the case, I'd propose something like
>
> - (-|+)n => :number-lines (yes|*no*|continue)
> ^ +n
> - -r => :labels (link|keep|*remove*) ("label string")?
>  ^ -k ^ -l "label string"
>
> and could give it a try. What do you think?

Looks reasonable.
Although you forgot -i :)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Possible to set block switches "globally"?

2024-05-02 Thread João Pedro
Em segunda, 29/04/2024 às 17:34 (GMT), Ihor Radchenko  
escreveu:

> Yes. This is the plan.
>
> Citing earlier syntax discussion in
> https://list.orgmode.org/orgmode/877d08bkze.fsf@localhost/
>
> > Can we drop switch support? This seems like a fairly good idea. The 
> functionality can simply be shifted to
> > ARGUMENTS with the well-established :key val forms.
> > “For the love of all that is sane” — Tom G

All right so if I understand correctly, we'd like to deprecate switches
from the parser and introduce :key val pairs for each switch, but no one
has gotten to it yet?

If that's the case, I'd propose something like

- (-|+)n => :number-lines (yes|*no*|continue)
^ +n
- -r => :labels (link|keep|*remove*) ("label string")?
 ^ -k ^ -l "label string"

and could give it a try. What do you think?

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Re: Possible to set block switches "globally"?

2024-04-29 Thread Ihor Radchenko
João Pedro  writes:

> Is there a way to set =src= and =example= switches (as documented in
> "(org) Literal Examples"[0]) file- or heading-wide?

There is currently no way to do it.

> Ideally, I would be able to set those as a file properties like that, or
> per heading under the =:PROPERTIES:= drawer.

Yes. This is the plan.

Citing earlier syntax discussion in
https://list.orgmode.org/orgmode/877d08bkze.fsf@localhost/

> Can we drop switch support? This seems like a fairly good idea. The 
functionality can simply be shifted to
> ARGUMENTS with the well-established :key val forms.
> “For the love of all that is sane” — Tom G

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Possible to set block switches "globally"?

2024-04-28 Thread João Pedro
Hi Org-mode!

Is there a way to set =src= and =example= switches (as documented in
"(org) Literal Examples"[0]) file- or heading-wide? I tried using

#+property: header-args:emacs-lisp -n -r

but they aren't really header arguments and that doesn't get picked up
as it should (it does, but as if `-n' is a key and `-r' is a value for a
header argument).

Ideally, I would be able to set those as a file properties like that, or
per heading under the =:PROPERTIES:= drawer.

[0] https://orgmode.org/manual/Literal-Examples.html

Thanks in advance,

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Possible to set block switches "globally"?

2024-04-28 Thread João Pedro
Hi Org-mode!

Is there a way to set =src= and =example= switches (as documented in
"(org) Literal Examples"[0]) file- or heading-wide? I tried using

#+property: header-args:emacs-lisp -n -r

but they aren't really header arguments and that doesn't get picked up
as it should (it does, but as if `-n' is a key and `-r' is a value for a
header argument).

Ideally, I would be able to set those as a file properties like that, or
per heading under the =:PROPERTIES:= drawer.

Thanks in advance,

[0] https://orgmode.org/manual/Literal-Examples.html

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)