emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org list source block
@ 2016-01-03 12:39 Jarmo Hurri
  2016-01-03 14:10 ` Richard Lawrence
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jarmo Hurri @ 2016-01-03 12:39 UTC (permalink / raw)
  To: emacs-orgmode


Greetings.

Once again I fail when I try to do something very _simple_ with Org.

I am trying to define a checklist and then use the same list in my
exported document in multiple locations. I don't think macros would work
here, since my org code has multiple lines. So I am trying to use
Babel.

The idea would be the following (please ignore code block header
arguments):

# -----------------------------------------------------------------
* Test list
  #+NAME: my-list
  #+BEGIN_SRC org :exports code :results value org
  - [ ] foo
  - [ ] bar
  #+END_SRC

  #+BEGIN_SRC org :noweb yes
  <<my-list>>
  #+END_SRC
# -----------------------------------------------------------------

I have tried to do this in many different ways, but in my exported file
the checklist always appears as an unformatted code block; that is,
checklist appear as '[ ]', not as nicely formatted LaTeX boxes. I have
tried to vary ':exports' and ':results' to no avail.

What is the correct solution to this?

BTW, if there is a solution to this, I think future generations might
benefit if something about it were mentioned in the manual in section
11.6 "Macro replacement".

Thanks in advance!

Jarmo

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

* Re: Org list source block
  2016-01-03 12:39 Org list source block Jarmo Hurri
@ 2016-01-03 14:10 ` Richard Lawrence
  2016-01-03 14:47   ` Jarmo Hurri
  2016-01-03 17:08 ` Charles C. Berry
  2016-01-03 17:23 ` Nicolas Goaziou
  2 siblings, 1 reply; 7+ messages in thread
From: Richard Lawrence @ 2016-01-03 14:10 UTC (permalink / raw)
  To: Jarmo Hurri, emacs-orgmode

Hi Jarmo,

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

> I am trying to define a checklist and then use the same list in my
> exported document in multiple locations. ...
> What is the correct solution to this?

Would an #+INCLUDE file work here?  See

http://orgmode.org/manual/Include-files.html#Include-files

Best,
Richard

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

* Re: Org list source block
  2016-01-03 14:10 ` Richard Lawrence
@ 2016-01-03 14:47   ` Jarmo Hurri
  0 siblings, 0 replies; 7+ messages in thread
From: Jarmo Hurri @ 2016-01-03 14:47 UTC (permalink / raw)
  To: emacs-orgmode

Richard Lawrence <richard.lawrence@berkeley.edu> writes:

> Hi Jarmo,
>
> Jarmo Hurri <jarmo.hurri@iki.fi> writes:
>
>> I am trying to define a checklist and then use the same list in my
>> exported document in multiple locations. ...
>> What is the correct solution to this?
>
> Would an #+INCLUDE file work here?

Yes, thank you! Adopted this solution for the time being.

Because this requires a (basically) unnecessary second file, I am still
hoping for other solutions to emerge.

Thanks!

Jarmo

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

* Re: Org list source block
  2016-01-03 12:39 Org list source block Jarmo Hurri
  2016-01-03 14:10 ` Richard Lawrence
@ 2016-01-03 17:08 ` Charles C. Berry
  2016-01-04 15:33   ` Jarmo Hurri
  2016-01-03 17:23 ` Nicolas Goaziou
  2 siblings, 1 reply; 7+ messages in thread
From: Charles C. Berry @ 2016-01-03 17:08 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

On Sun, 3 Jan 2016, Jarmo Hurri wrote:

>
> Greetings.
>
> Once again I fail when I try to do something very _simple_ with Org.
>
> I am trying to define a checklist and then use the same list in my
> exported document in multiple locations. I don't think macros would work
> here, since my org code has multiple lines. So I am trying to use
> Babel.
>
> The idea would be the following (please ignore code block header
> arguments):
>
> # -----------------------------------------------------------------
> * Test list
>  #+NAME: my-list
>  #+BEGIN_SRC org :exports code :results value org
>  - [ ] foo
>  - [ ] bar
>  #+END_SRC
>
>  #+BEGIN_SRC org :noweb yes
>  <<my-list>>
>  #+END_SRC
> # -----------------------------------------------------------------
>
> I have tried to do this in many different ways, but in my exported file
> the checklist always appears as an unformatted code block; that is,
> checklist appear as '[ ]', not as nicely formatted LaTeX boxes. I have
> tried to vary ':exports' and ':results' to no avail.
>
> What is the correct solution to this?
>

Is this what you want?

--8<---------------cut here---------------start------------->8---
\section{Test list}
\label{sec:orgheadline1}
\begin{org}
\begin{itemize}
\item $\square$ foo
\item $\square$ bar
\end{itemize}
\end{org}
--8<---------------cut here---------------end--------------->8---

If so, you can get it with

--8<---------------cut here---------------start------------->8---
* Test list
#+NAME: my-list
#+BEGIN_SRC org :exports none :results value org
     - [ ] foo
     - [ ] bar
#+END_SRC

#+BEGIN_SRC org :noweb yes :results replace :wrap org :exports results
   <<my-list>>
#+END_SRC
--8<---------------cut here---------------end--------------->8---


Assuming that (require 'ob-org) has been taken care of!

HTH,

Chuck

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

* Re: Org list source block
  2016-01-03 12:39 Org list source block Jarmo Hurri
  2016-01-03 14:10 ` Richard Lawrence
  2016-01-03 17:08 ` Charles C. Berry
@ 2016-01-03 17:23 ` Nicolas Goaziou
  2016-01-04 15:26   ` Jarmo Hurri
  2 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2016-01-03 17:23 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Hello,

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

> Once again I fail when I try to do something very _simple_ with Org.

You're building programmatically your document. I don't believe it
belongs to "very simple" tasks.

> I am trying to define a checklist and then use the same list in my
> exported document in multiple locations. I don't think macros would work
> here, since my org code has multiple lines. So I am trying to use
> Babel.
>
> The idea would be the following (please ignore code block header
> arguments):
>
> # -----------------------------------------------------------------
> * Test list
>   #+NAME: my-list
>   #+BEGIN_SRC org :exports code :results value org
>   - [ ] foo - [ ] bar #+END_SRC
>
>   #+BEGIN_SRC org :noweb yes
>   <<my-list>>
>   #+END_SRC
> # -----------------------------------------------------------------
>
> I have tried to do this in many different ways, but in my exported file
> the checklist always appears as an unformatted code block; that is,
> checklist appear as '[ ]', not as nicely formatted LaTeX boxes. I have
> tried to vary ':exports' and ':results' to no avail.
>
> What is the correct solution to this?

I think something along the following lines should work.

  #+NAME: mylist
  #+BEGIN_SRC org :results raw :exports none
  - [ ] foo 
  - [ ] bar 
  #+END_SRC

  #+CALL: mylist() :results raw
  #+RESULTS:

  #+CALL: mylist() :results raw
  #+RESULTS:

> BTW, if there is a solution to this, I think future generations might
> benefit if something about it were mentioned in the manual in section
> 11.6 "Macro replacement".

As you noticed already, you are not using a macro. Why would it be in
macro replacement?

Regards,

-- 
Nicolas Goaziou

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

* Re: Org list source block
  2016-01-03 17:23 ` Nicolas Goaziou
@ 2016-01-04 15:26   ` Jarmo Hurri
  0 siblings, 0 replies; 7+ messages in thread
From: Jarmo Hurri @ 2016-01-04 15:26 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

>> Once again I fail when I try to do something very _simple_ with Org.
>
> You're building programmatically your document. I don't believe it
> belongs to "very simple" tasks.

Coming from a LaTeX background, Org is a real miracle tool, but it is
difficult to figure out how to do some things that used to be so
simple. Like in LaTeX you have a single \newcommand (or
\newenvironment), and then you use it wherever you want to. And if you
need similar document structure in multiple places, that is how a
programmer always does it.

>> BTW, if there is a solution to this, I think future generations might
>> benefit if something about it were mentioned in the manual in section
>> 11.6 "Macro replacement".
>
> As you noticed already, you are not using a macro. Why would it be in
> macro replacement?

To help the confused reader. Because people like me (common or rare
case?) just think: ok, I am going to define a macro for this. Then we go
to the org document and look up macros. Then we start doing online
searches for macros with linebreaks. Then we find discussions on
stackoverflow that say: "No you should do it with babel." Then we try to
figure out how to do it with babel. Then we post here. And so on.

My two absolute favorite tools from recent years are Org and Asymptote,
but neither have very beginner-friendly documentation. Partially because
both systems are so complex.

Yeah, I know I shouldn't whine: I could write the sections myself. But
others can do it better... :-)

> I think something along the following lines should work.
>
>   #+NAME: mylist
>   #+BEGIN_SRC org :results raw :exports none
>   - [ ] foo 
>   - [ ] bar 
>   #+END_SRC
>
>   #+CALL: mylist() :results raw
>   #+RESULTS:
>   #+CALL: mylist() :results raw
>   #+RESULTS:

This worked after adding org to org-babel-do-load-languges. Thanks!

Jarmo

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

* Re: Org list source block
  2016-01-03 17:08 ` Charles C. Berry
@ 2016-01-04 15:33   ` Jarmo Hurri
  0 siblings, 0 replies; 7+ messages in thread
From: Jarmo Hurri @ 2016-01-04 15:33 UTC (permalink / raw)
  To: emacs-orgmode

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> If so, you can get it with
>
> * Test list
> #+NAME: my-list
> #+BEGIN_SRC org :exports none :results value org
>      - [ ] foo
>      - [ ] bar
> #+END_SRC
>
> #+BEGIN_SRC org :noweb yes :results replace :wrap org :exports results
>    <<my-list>>
> #+END_SRC

Thanks, that worked!

All the best,

Jarmo

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

end of thread, other threads:[~2016-01-04 15:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-03 12:39 Org list source block Jarmo Hurri
2016-01-03 14:10 ` Richard Lawrence
2016-01-03 14:47   ` Jarmo Hurri
2016-01-03 17:08 ` Charles C. Berry
2016-01-04 15:33   ` Jarmo Hurri
2016-01-03 17:23 ` Nicolas Goaziou
2016-01-04 15:26   ` Jarmo Hurri

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