Re: [O] How to pass a block of text to a code block as data?

2013-02-11 Thread Michael Baum
Sean, that helps too, thank you. Now that you and Sebastien have gone to
all this trouble I found the part of the manual that sort of describes
this, but I clearly didn't understand it before. Possible needs a more
worked-out example for the slow among us, like self.

I've noticed one curious thing in trying a perl example. See first:

-8<--
#+name: wake
#+BEGIN_EXAMPLE
riverrun, past Eve and Adam's, from swerve of shore to bend
of bay, brings us by a commodius vicus of recirculation back to
Howth Castle and Environs.
Sir Tristram, violer d'amores, fr'over the short sea, had passen-
core rearrived from North Armorica on this side the scraggy
isthmus of Europe Minor to wielderfight his penisolate war: nor
had topsawyer's rocks by the stream Oconee exaggerated themselse
to Laurens County's gorgios while they went doublin their mumper
all the time: nor avoice from afire bellowsed mishe mishe to
#+END_EXAMPLE

#+begin_src perl :var inlines=wake :results output
  foreach $aln (split(/$/,$inlines)) {
   print $aln;
  }
#+end_src


#+results:
: riverrun, past Eve and Adam's, from swerve of shore to bend
: of bay, brings us by a commodius vicus of recirculation back to
: Howth Castle and Environs.
: Sir Tristram, violer d'amores, fr'over the short sea, had passen-
: core rearrived from North Armorica on this side the scraggy
: isthmus of Europe Minor to wielderfight his penisolate war: nor
: had topsawyer's rocks by the stream Oconee exaggerated themselse
: to Laurens County's gorgios while they went doublin their mumper
: all the time: nor avoice from afire bellowsed mishe mishe to

-8<--

and then a more complicated block that's closer to my real task:

-8<--

#+NAME: job2
#+BEGIN_EXAMPLE
!START
!ID:7655
!DATE:02/10/2013
!CLOSE:03/15/2013
!UNTILFILLED:
!POSITION:Science Editor
!COMPANY:East Newark Times Herald News and World Defender
!BEGIN-DESCRIPTION
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero
eros et accumsan et iusto odio dignissim qui blandit praesent luptatum
zzril delenit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut
mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu
posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit online at  http://enthnawd.org/jobs
!END-CONTACT
!END
#+END_EXAMPLE


#+begin_src perl :var inlines=job2 :results output
  foreach $aln (split(/$/,$inlines)) {
   print $aln;
  }
#+end_src

#+results:
#+begin_example
!START
!ID:7655
!DATE:02/10/2013
!CLOSE:03/15/2013
!UNTILFILLED:
!POSITION:Science Editor
!COMPANY:East Newark Times Herald News and World Defender
!BEGIN-DESCRIPTION
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut
wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero
eros et accumsan et iusto odio dignissim qui blandit praesent luptatum
zzril delenit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut
mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu
posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit online at  http://enthnawd.org/jobs
!END-CONTACT
!END
#+end_example

-8<--

NOTICE THAT while both return the result as Example text, the first simple
prepends each line with a colon, simple Example form, and the second wraps
the result in an Example block without altering the lines.

Not sure why? Is this just a function of the number of lines of the text?

Michael


-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


Re: [O] How to pass a block of text to a code block as data?

2013-02-08 Thread Michael Baum
Sebastien:

Thanks! That helps a lot. I'm having trouble extending your example,
however. A couple of questions --

- What signals the end of the block of text to be used as data? I take it
that it's important that these all be comment lines staring with a colon
after the #+name label? Is there a way to do the same thing with a begin
and end block construction?

- In this line:
   #+begin_src sh :stdin lines-of-text :results output

does the flag :stdin mean that the following named block literally becomes
the STDIN stream for the code block? If I replace your shell/grep example
with this:

#+begin_src perl :stdin lines-of-text :results output
while (<>) {
   print $_;
}
#+end_src

...it doesn't work, although as far as I know that perl code snippet should
in fact simply print out the incoming lines from stdin.

Thanks again,

Michael

On Fri, Feb 8, 2013 at 3:17 PM, Sebastien Vauban  wrote:

> Hi Michael,
>
> Michael Baum wrote:
> > I haven't been able to figure this out from the org-mode documents yet.
> > What I would like to do is have a source code block in python or perl or
> > something similar. to which I can pass a reference to several lines of
> text
> > that the source code block, when evaluated, would then act on. Which
> would
> > involve iterating through the data text one line at a time and writing
> the
> > output to a buffer.
> >
> > The text data could be indicated by a specific headline or a named block
> of
> > some sort or maybe an internal link, I'm not particularly fussy just so
> > there's a mechanism to do this.
> >
> > Would appreciate any guidance.
>
> #+name: lines-of-text
> : I haven't been able to figure this out from the org-mode documents yet.
> : What I would like to do is have a source code block in python or perl or
> : something similar. to which I can pass a reference to several lines of
> text
> : that the source code block, when evaluated, would then act on. Which
> would
> : involve iterating through the data text one line at a time and writing
> the
> : output to a buffer.
>
> #+begin_src sh :stdin lines-of-text :results output
>   grep would
> #+end_src
>
> #+results:
> #+begin_example
> What I would like to do is have a source code block in python or perl or
> that the source code block, when evaluated, would then act on. Which would
> #+end_example
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>
>


-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


[O] How to pass a block of text to a code block as data?

2013-02-08 Thread Michael Baum
I haven't been able to figure this out from the org-mode documents yet.
What I would like to do is have a source code block in python or perl or
something similar. to which I can pass a reference to several lines of text
that the source code block, when evaluated, would then act on. Which would
involve iterating through the data text one line at a time and writing the
output to a buffer.

The text data could be indicated by a specific headline or a named block of
some sort or maybe an internal link, I'm not particularly fussy just so
there's a mechanism to do this.

Would appreciate any guidance.

-- 
========
Michael Baum 


[O] Need help with processing a text block with python function

2013-01-01 Thread Michael Baum
I know this is kind of an org-mode 101 question, sorry, but after searching
docs for a couple of days, I could use a pointer. I want to write a
function in a code block in python or perl that steps through lines of text
and does some complicated reformatting, adding in html bits and such, for a
specialized application. Then I want to be able paste a block of text into
an org-mode file and call this function to walk through it and do it's
stuff, sending the result to an export buffer.

What's the best way to do that, specifically, what should I do with the
text to be processed? Put it all under a single headline and call the
function against that headline? Put it within some sort of begin/end
markers? I need the python or whatever script to be able to step through
one line at a time maybe using it's usual text input functions.

Thanks,
maab

-- 
========
Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


Re: [O] Problem with template expansion of previous prompts.

2012-12-07 Thread Michael Baum
Yes, you're correct, Aaron, thanks. Apparently the secondary substitutions
only get processed after all the questions are asked and the template is
written out to the temp buffer. So the backslash has to be escaped to
survive the first round of substitutions.

I kind of feel that this should be stated more explicitly in the manual. IN
BOLD TYPE.

maabaum

On Thu, Dec 6, 2012 at 6:34 PM, Aaron Ecay  wrote:

> You need to escape the backslash inside the string, I think.  "\1" is
> interpreted as a string consisting of one character, the ASCII character
> with hex code 0x01, which happens to be C-a.  "\\1" is a 2-character
> string: backslash, then one.
>
> --
> Aaron Ecay
>



-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


[O] Capture template -- Global replacement of prompt string in buffer?

2012-11-02 Thread Michael Baum
I'm not sure (because I didn't understand what was going on) if this is the
same question that Sebastian Fischmeister  asked earlier ("Custom escapes &
the evaluation order in fill-template"), but is it possible to construct a
capture template using something like the %{prompt} that replaces _all_
occurrences of the prompt string throughout the capture buffer,  rather
than just at the insertion point of the escape expression?

I want to do something like this:
---8<
("p" "phone log" entry (file+datetree org-phone-log)
"* %^{Organization} - %^{First Name} %^{Last Name}
:PROPERTIES:
:FIRST_NAME: {First Name}
:LAST_NAME: {Last Name}
:ORG: {Organization}
:END:

usw.
---8<

where the value entered in response to {First Name} gets globally
substituted in two or more places in the template.

Can this be done?

tnx,
maab

-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


[O] Setting a deadline in a template

2012-06-21 Thread Michael Baum
I'm sure there's a simple answer to this but i can't seem to tease it out
of the on-line docs. I want to set up a capture template for entering
incoming work that automatically sets a deadline for the item when it's
entered. Ideally, I'd like it to set a deadline 4 business hours in the
future of the current time, but that's a tricky calculation and I'd settle
for current time plus a day.

I've tried the naive approach:
...
DEADLINE: %T+1
...

Doesn't work so well. What's the proper way?

Thanks,
maaab

-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


Re: [O] Upgrade org-mode over a older distribution version

2012-05-31 Thread Michael Baum
Many thanks. I was afraid of something like that. So the idea is that a set
or org-mode files under site-lisp takes precedence over the built-in files
and that's how emacs knows which ones to run?

maab


On Thu, May 31, 2012 at 2:57 PM, Achim Gratz  wrote:

> Michael Baum writes:
> > Let's assume I have root access to the computer. Is it as simple as
> > downloading the current org-mode source, running make and all that,
> > and then replacing the existing .elc files in
> > /usr/share/emacs/23.2/lisp/org with the new ones?
>
> Never touch these files, they belong to Emacs.  You need to install into
> /usr/share/emacs/site-lisp or, if you want to do really fancy things
> with multiple Emacs versions, /usr/share/emacs/23.2/site-lisp.  So pull
> current master from Git and do:
>
> make up2
>
> This assumes sudo will be able to obtain administrative rights.  Make in
> master is already set up to place orgmode into the right spot.
>
>
> Regards,
> Achim.
> --
> +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
>
> Factory and User Sound Singles for Waldorf rackAttack:
> http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
>
>
>


-- 

Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen


[O] Upgrade org-mode over a older distribution version

2012-05-31 Thread Michael Baum
I'm sure this is an FAQ, but I haven't been able to find it.

The Org-mode manual says under "Installation", "*If you are using a version
of Org that is part of the Emacs distribution or an XEmacs package, please
skip this section and go directly to
Activation<http://orgmode.org/manual/Activation.html#Activation>
."*  The problem is that the distribution version I have, bundled in with
the emacs package supplied by openSUSE, is more than a major revision out
of date, at least with regard to org-mode. So the question is, what's the
proper way to upgrade it without breaking anything by accident?

Let's assume I have root access to the computer. Is it as simple as
downloading the current org-mode source, running make and all that, and
then replacing the existing .elc files in /usr/share/emacs/23.2/lisp/org
with the new ones?

maab

-- 
====
Michael Baum 

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen