all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Possible to set block switches "globally"?
@ 2024-04-29  2:07 João Pedro
  0 siblings, 0 replies; 10+ messages in thread
From: João Pedro @ 2024-04-29  2:07 UTC (permalink / raw)
  To: emacs-orgmode

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)

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

* Possible to set block switches "globally"?
@ 2024-04-29  2:07 João Pedro
  2024-04-29 17:34 ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: João Pedro @ 2024-04-29  2:07 UTC (permalink / raw)
  To: emacs-orgmode

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)

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

* Re: Possible to set block switches "globally"?
  2024-04-29  2:07 João Pedro
@ 2024-04-29 17:34 ` Ihor Radchenko
  2024-05-02 19:16   ` João Pedro
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2024-04-29 17:34 UTC (permalink / raw)
  To: João Pedro; +Cc: emacs-orgmode, Tom Gillespie

João Pedro <jpedrodeamorim@gmail.com> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Possible to set block switches "globally"?
  2024-04-29 17:34 ` Ihor Radchenko
@ 2024-05-02 19:16   ` João Pedro
  2024-05-03 12:17     ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: João Pedro @ 2024-05-02 19:16 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode, Tom Gillespie

Em segunda, 29/04/2024 às 17:34 (GMT), Ihor Radchenko <yantar92@posteo.net> 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)

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

* Re: Possible to set block switches "globally"?
  2024-05-02 19:16   ` João Pedro
@ 2024-05-03 12:17     ` Ihor Radchenko
  2024-05-03 17:12       ` Tom Gillespie
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-03 12:17 UTC (permalink / raw)
  To: João Pedro; +Cc: emacs-orgmode, Tom Gillespie

João Pedro <jpedrodeamorim@gmail.com> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Possible to set block switches "globally"?
  2024-05-03 12:17     ` Ihor Radchenko
@ 2024-05-03 17:12       ` Tom Gillespie
  2024-05-04  3:04         ` João Pedro
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Gillespie @ 2024-05-03 17:12 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: João Pedro, emacs-orgmode

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


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

* Re: Possible to set block switches "globally"?
  2024-05-03 17:12       ` Tom Gillespie
@ 2024-05-04  3:04         ` João Pedro
  2024-05-04 12:19           ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: João Pedro @ 2024-05-04  3:04 UTC (permalink / raw)
  To: Tom Gillespie, Ihor Radchenko; +Cc: emacs-orgmode

Em sexta, 03/05/2024 às 10:12 (-07), Tom Gillespie <tgbugs@gmail.com> 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)

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

* Re: Possible to set block switches "globally"?
  2024-05-04  3:04         ` João Pedro
@ 2024-05-04 12:19           ` Ihor Radchenko
  2024-05-04 20:57             ` Tom Gillespie
  2024-07-10  7:32             ` Ihor Radchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-04 12:19 UTC (permalink / raw)
  To: João Pedro; +Cc: Tom Gillespie, emacs-orgmode

João Pedro <jpedrodeamorim@gmail.com> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Possible to set block switches "globally"?
  2024-05-04 12:19           ` Ihor Radchenko
@ 2024-05-04 20:57             ` Tom Gillespie
  2024-07-10  7:32             ` Ihor Radchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Gillespie @ 2024-05-04 20:57 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: João Pedro, emacs-orgmode

> 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)


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

* Re: Possible to set block switches "globally"?
  2024-05-04 12:19           ` Ihor Radchenko
  2024-05-04 20:57             ` Tom Gillespie
@ 2024-07-10  7:32             ` Ihor Radchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-07-10  7:32 UTC (permalink / raw)
  To: João Pedro; +Cc: Tom Gillespie, emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2024-07-10  7:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29  2:07 Possible to set block switches "globally"? João Pedro
  -- strict thread matches above, loose matches on Subject: below --
2024-04-29  2:07 João Pedro
2024-04-29 17:34 ` Ihor Radchenko
2024-05-02 19:16   ` João Pedro
2024-05-03 12:17     ` Ihor Radchenko
2024-05-03 17:12       ` Tom Gillespie
2024-05-04  3:04         ` João Pedro
2024-05-04 12:19           ` Ihor Radchenko
2024-05-04 20:57             ` Tom Gillespie
2024-07-10  7:32             ` Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.