emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Multi-line macros (again)
@ 2016-10-07 11:30 Jarmo Hurri
  2016-10-09  9:25 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Jarmo Hurri @ 2016-10-07 11:30 UTC (permalink / raw)
  To: emacs-orgmode


Greetings.

I think I have discussed multiline Org macros here before. But I bumped
into the issue again.

One of the most useful properties of LaTeX is \newcommand, which allows
you to reuse document structures. I really, _really_ miss this feature
in Org. Org has #+MACRO, but it is limited to a single line. That is
very inconvenient for any larger structures.

I was thinking (awfully sorry, will stop soon). Could we have multiline
macros, something like

#+BEGIN_MACRO name
#+END_MACRO

where everything between the begin and end would be expanded just like
(single line) macros are right now. With newlines included in the
expansion.

How about it?

Jarmo

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

* Re: Multi-line macros (again)
  2016-10-07 11:30 Multi-line macros (again) Jarmo Hurri
@ 2016-10-09  9:25 ` Nicolas Goaziou
  2016-10-12  9:56   ` Rasmus
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2016-10-09  9:25 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Hello,

Jarmo Hurri <jarmo.hurri@iki.fi> writes:

> One of the most useful properties of LaTeX is \newcommand, which allows
> you to reuse document structures. I really, _really_ miss this feature
> in Org. Org has #+MACRO, but it is limited to a single line. That is
> very inconvenient for any larger structures.

Of course, macro are inconvenient for complex structures. They are not
the right tool for the job. You could use Babel for that, e.g.,

  #+name: template
  #+header: :var x="" y=""
  #+header: :results silent
  #+begin_src org
  $x
  $y
  #+end_src

  #+call: template("line 1", "line 2") :results replace

  #+RESULTS:
  line 1
  line 2

> Could we have multiline macros, something like
>
> #+BEGIN_MACRO name
> #+END_MACRO

For the record, I think that block syntax is largely overloaded. I'd
rather not introduce a new type of block without a really good reason.

Anyway, is there anything wrong with Babel, as suggested above?

Regards,

-- 
Nicolas Goaziou

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

* Re: Multi-line macros (again)
  2016-10-09  9:25 ` Nicolas Goaziou
@ 2016-10-12  9:56   ` Rasmus
  2016-10-12 10:22     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Rasmus @ 2016-10-12  9:56 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Jarmo Hurri <jarmo.hurri@iki.fi> writes:
>
>> One of the most useful properties of LaTeX is \newcommand, which allows
>> you to reuse document structures. I really, _really_ miss this feature
>> in Org. Org has #+MACRO, but it is limited to a single line. That is
>> very inconvenient for any larger structures.
>
> Of course, macro are inconvenient for complex structures. They are not
> the right tool for the job. You could use Babel for that, e.g.,
>
>   #+name: template
>   #+header: :var x="" y=""
>
>   #+header: :results silent
>   #+begin_src org
>
>   $x
>   $y
>   #+end_src
>
>   #+call: template("line 1", "line 2") :results replace
>
>   #+RESULTS:
>   line 1
>   line 2
>
>> Could we have multiline macros, something like
>>
>> #+BEGIN_MACRO name
>> #+END_MACRO
>
> For the record, I think that block syntax is largely overloaded. I'd
> rather not introduce a new type of block without a really good reason.
>
> Anyway, is there anything wrong with Babel, as suggested above?

To me, the syntax is a bit tiresome for inline calls,

     call_<name>[<inside header arguments>](<arguments>)[<end header arguments>]

You almost always have to tweak the header arguments to get it to work
properly.  E.g. I think it prints return values as code by default
(e.g. "=·=").

I wonder if we could allow remote editing of macros like with table
formulas.

Rasmus

-- 
Dung makes an excellent fertilizer

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

* Re: Multi-line macros (again)
  2016-10-12  9:56   ` Rasmus
@ 2016-10-12 10:22     ` Nicolas Goaziou
  2016-10-12 10:29       ` Rasmus
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2016-10-12 10:22 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> To me, the syntax is a bit tiresome for inline calls,
>
>      call_<name>[<inside header arguments>](<arguments>)[<end header arguments>]

This is where macros can shine. You can define a macro expanding to this
template.

> I wonder if we could allow remote editing of macros like with table
> formulas.

This is orthogonal to the issue. Once edited, it sill have to be
inserted in the document as a multi-line macro, which is not possible.

Regards,

-- 
Nicolas Goaziou

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

* Re: Multi-line macros (again)
  2016-10-12 10:22     ` Nicolas Goaziou
@ 2016-10-12 10:29       ` Rasmus
  0 siblings, 0 replies; 5+ messages in thread
From: Rasmus @ 2016-10-12 10:29 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

>> To me, the syntax is a bit tiresome for inline calls,
>>
>>      call_<name>[<inside header arguments>](<arguments>)[<end header arguments>]
>
> This is where macros can shine. You can define a macro expanding to this
> template.

Sure.

>> I wonder if we could allow remote editing of macros like with table
>> formulas.
>
> This is orthogonal to the issue. Once edited, it sill have to be
> inserted in the document as a multi-line macro, which is not possible.

Not if we can automatically format lines, which is not at all obvious.  It
might be possible with lispy macros, but might not be possible in general.
(Table formula lines can be long, but it's not a problem since they can be
edited in a separate window).

Rasmus

-- 
To err is human. To screw up 10⁶ times per second, you need a computer

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-07 11:30 Multi-line macros (again) Jarmo Hurri
2016-10-09  9:25 ` Nicolas Goaziou
2016-10-12  9:56   ` Rasmus
2016-10-12 10:22     ` Nicolas Goaziou
2016-10-12 10:29       ` Rasmus

Code repositories for project(s) associated with this public 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).