emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* markup text with leading, trailing spaces
@ 2015-02-13 21:29 hymie!
  2015-02-13 22:31 ` Jorge A. Alfaro-Murillo
  2015-02-15  1:28 ` hymie!
  0 siblings, 2 replies; 11+ messages in thread
From: hymie! @ 2015-02-13 21:29 UTC (permalink / raw)
  To: emacs-orgmode

Greetings.

My next SNAFU involves mark-up text.

I'd like to be able to have a series of commands in my raw org file that I
can copy-n-paste into my shell window.  But I also like to export my org
files to HTML so that I can make ePubs and keep them in my iPad.

So while I strongly prefer the exported version of
- ~command1~
- ~command2~
- ~command3~
it's hard to copy-n-paste with the tildes in the way.

Unfortunately, this
- ~ command1 ~
- ~ command2 ~
- ~ command3 ~
does not mark up the text in my exported-to-html version.

And this
#+BEGIN_SRC
  command1
  command2
  command3
#+END_SRC
is just IMO ugly.

Is there something I can do, where I can get output similar to
- ~command1~
- ~command2~
- ~command3~
without the tildes blocking my text?

--hymie!

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

* Re: markup text with leading, trailing spaces
  2015-02-13 21:29 markup text with leading, trailing spaces hymie!
@ 2015-02-13 22:31 ` Jorge A. Alfaro-Murillo
  2015-02-14  4:08   ` hymie!
  2015-02-15  1:28 ` hymie!
  1 sibling, 1 reply; 11+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-02-13 22:31 UTC (permalink / raw)
  To: emacs-orgmode

hymie! writes:

> I'd like to be able to have a series of commands in my raw org 
> file that I can copy-n-paste into my shell window.  But I also 
> like to export my org files to HTML so that I can make ePubs and 
> keep them in my iPad.
 
> And this
> 
> #+BEGIN_SRC
>   command1
>   command2
>   command3
> #+END_SRC
>
> is just IMO ugly.

It shouldn't be. Try adding the word "shell" after BEGIN_SRC, so 
that it fontifies the code correctly (the variable 
org-src-fontify-natively should be set to t, but that has been 
default for a while). Also, add shell to the loaded babel 
languages, so that you can execute the code and get the results 
right away in org:

#+BEGIN_SRC emacs-lisp
  (org-babel-do-load-languages
  'org-babel-load-languages
       '((shell . t)))
#+END_SRC

No need for "copy-n-paste", just do C-c C-c where you have your 
commands. 

Another added benefit is that it is way easier to add the shell 
scripts inside a SRC block after you press C-c ' (C-c ' again to 
go back to your org file), since then you will have the power of 
Shell-script mode available, for example:

C-c (	 to define a function
C-c TAB	 for an if statement
C-c C-l	 for an indexed loop

Try copying this example into an org file, it should fontify it 
nicely, both in the org file and in the html exported.

#+BEGIN_SRC shell
  echo "hello"
  cd
  ls
  n=1
  while [ $n -le 10 ]; do
      echo $n
      n=$(( n + 1 ))
  done
  echo "bye"
#+END_SRC

Best,
 
-- 
Jorge.

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

* Re: markup text with leading, trailing spaces
  2015-02-13 22:31 ` Jorge A. Alfaro-Murillo
@ 2015-02-14  4:08   ` hymie!
  2015-02-14 19:03     ` Jorge A. Alfaro-Murillo
  0 siblings, 1 reply; 11+ messages in thread
From: hymie! @ 2015-02-14  4:08 UTC (permalink / raw)
  To: emacs-orgmode

In our last episode, the evil Dr. Lacto had captured our hero,
  jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo), who said:
>hymie! writes:
>
>> I'd like to be able to have a series of commands in my raw org 
>> file that I can copy-n-paste into my shell window.  But I also 
>> like to export my org files to HTML so that I can make ePubs and 
>> keep them in my iPad.
> 
>> And this
>> 
>> #+BEGIN_SRC
>>   command1
>>   command2
>>   command3
>> #+END_SRC
>>
>> is just IMO ugly.
>
>It shouldn't be. Try adding the word "shell" after BEGIN_SRC, so 
>that it fontifies the code correctly (the variable 
>org-src-fontify-natively should be set to t, but that has been 
>default for a while)

It's not that the font is ugly.  It's that
* (in the epub) the source code appears in a box
* (in the html/epub) it's impossible to tell the difference between two
different commands and a single command that was too long and word wrapped
to fit in the box
* (in the html/epub) I can't have non-monospace comments between/attached
to/within the code without drawing four or five separate boxes around my code
* (in the org file) For whatever reason, monospace code appears as a
light-gray font, which is hard to read against a white background.  I'm
sure that can be changed, but I haven't had time to figure it out yet.

>Also, add shell to the loaded babel 
>languages, so that you can execute the code and get the results 
>right away in org:
>
>No need for "copy-n-paste", just do C-c C-c where you have your 
>commands. 

I think you are making the incorrect assumption that the machine on
which I maintain my Org files is the same machine that I wish to execute
commands on.

>Try copying this example into an org file, it should fontify it 
>nicely, both in the org file and in the html exported.

If my commnds were all 8 characters long or less, it would be fine.
Some of my commands look like this:

adduser username -d /data/chroot/home/username -s /usr/bin/rssh -m -k /dev/null -g rssh

useradd -U -G wheel -p '$6$wcMRrkcdGeNHLT5c$0s4qezb00ISmGZSsILOyV/WJn3RnuZPkSEknwoSZ22HvbgkBTe4TQwCz/mpG.3zby.1Jwnmtsq1B.uCbyg5l./' username

pssh -x '-q -t -t' -I -i --hosts hosts_linux_rhel6 'sudo -S wget puppet/puppet/pub/system_patch.pl -O /usr/local/bin/system_patch.pl' < hostnamefile

While I admit that the "useradd" command is an extreme example,
this becomes horribly ambiguous:

adduser username -d /data/chroot/home/username -s 
/usr/bin/rssh -m -k /dev/null -g rssh
pssh -x '-q -t -t' -I -i --hosts hosts_linux_rhel6
'sudo -S wget puppet/puppet/pub/system_patch.pl -O
/usr/local/bin/system_patch.pl' < hostnamefile

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net

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

* Re: markup text with leading, trailing spaces
@ 2015-02-14 17:19 darcamo
  2015-02-14 17:41 ` hymie
  0 siblings, 1 reply; 11+ messages in thread
From: darcamo @ 2015-02-14 17:19 UTC (permalink / raw)
  To: hymie!, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3606 bytes --]

Even if you want to run commands in a different computer you can do that
with "C-c C-c" thanks to the ":dir folder" header argument and tramp.

As an example, suppose I have the code block below

#+begin_src sh
  hostname
#+end_src

If I run it I get something like

#+RESULTS:
: my_computer_name

However, if if I can ssh to a server called "myserver" I can change the
code block to

#+begin_src sh :dir /myserver:~/
  hostname
#+end_src

Now if I run the code block the code is executed in myserver and I get

#+RESULTS:
: myserver_host_name

Combine this with "C-c C-v b" (org-babel-execute-buffer) and you can easily
run many different commands in different machines. It is really great.

Em Sat Feb 14 2015 at 01:09:02, hymie! <hymie@lactose.homelinux.net>
escreveu:

In our last episode, the evil Dr. Lacto had captured our hero,
>   jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo), who said:
> >hymie! writes:
> >
> >> I'd like to be able to have a series of commands in my raw org
> >> file that I can copy-n-paste into my shell window.  But I also
> >> like to export my org files to HTML so that I can make ePubs and
> >> keep them in my iPad.
> >
> >> And this
> >>
> >> #+BEGIN_SRC
> >>   command1
> >>   command2
> >>   command3
> >> #+END_SRC
> >>
> >> is just IMO ugly.
> >
> >It shouldn't be. Try adding the word "shell" after BEGIN_SRC, so
> >that it fontifies the code correctly (the variable
> >org-src-fontify-natively should be set to t, but that has been
> >default for a while)
>
> It's not that the font is ugly.  It's that
> * (in the epub) the source code appears in a box
> * (in the html/epub) it's impossible to tell the difference between two
> different commands and a single command that was too long and word wrapped
> to fit in the box
> * (in the html/epub) I can't have non-monospace comments between/attached
> to/within the code without drawing four or five separate boxes around my
> code
> * (in the org file) For whatever reason, monospace code appears as a
> light-gray font, which is hard to read against a white background.  I'm
> sure that can be changed, but I haven't had time to figure it out yet.
>
> >Also, add shell to the loaded babel
> >languages, so that you can execute the code and get the results
> >right away in org:
> >
> >No need for "copy-n-paste", just do C-c C-c where you have your
> >commands.
>
> I think you are making the incorrect assumption that the machine on
> which I maintain my Org files is the same machine that I wish to execute
> commands on.
>
> >Try copying this example into an org file, it should fontify it
> >nicely, both in the org file and in the html exported.
>
> If my commnds were all 8 characters long or less, it would be fine.
> Some of my commands look like this:
>
> adduser username -d /data/chroot/home/username -s /usr/bin/rssh -m -k
> /dev/null -g rssh
>
> useradd -U -G wheel -p '$6$wcMRrkcdGeNHLT5c$0s4qezb00ISmGZSsILOyV/
> WJn3RnuZPkSEknwoSZ22HvbgkBTe4TQwCz/mpG.3zby.1Jwnmtsq1B.uCbyg5l./' username
>
> pssh -x '-q -t -t' -I -i --hosts hosts_linux_rhel6 'sudo -S wget
> puppet/puppet/pub/system_patch.pl -O /usr/local/bin/system_patch.pl' <
> hostnamefile
>
> While I admit that the "useradd" command is an extreme example,
> this becomes horribly ambiguous:
>
> adduser username -d /data/chroot/home/username -s
> /usr/bin/rssh -m -k /dev/null -g rssh
> pssh -x '-q -t -t' -I -i --hosts hosts_linux_rhel6
> 'sudo -S wget puppet/puppet/pub/system_patch.pl -O
> /usr/local/bin/system_patch.pl' < hostnamefile
>
> --hymie!    http://lactose.homelinux.net/~hymie
> hymie@lactose.homelinux.net
>
>
>

[-- Attachment #2: Type: text/html, Size: 5226 bytes --]

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

* Re: markup text with leading, trailing spaces
  2015-02-14 17:19 darcamo
@ 2015-02-14 17:41 ` hymie
  0 siblings, 0 replies; 11+ messages in thread
From: hymie @ 2015-02-14 17:41 UTC (permalink / raw)
  To: emacs-orgmode

"darcamo@gmail.com" writes:
>However, if if I can ssh to a server called "myserver" I can change the
>code block to
>
>#+begin_src sh :dir /myserver:~/
>  hostname
>#+end_src
>
>Now if I run the code block the code is executed in myserver and I get
>
>#+RESULTS:
>: myserver_host_name

That is a very neat feature.  However

>if I can ssh to a server called "myserver" 

I cannot.

--hymie!     http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net

>> >hymie! writes:
>> >
>> >> I'd like to be able to have a series of commands in my raw org
>> >> file that I can copy-n-paste into my shell window.  But I also
>> >> like to export my org files to HTML so that I can make ePubs and
>> >> keep them in my iPad.
>> >
>> >> And this
>> >>
>> >> #+BEGIN_SRC
>> >>   command1
>> >>   command2
>> >>   command3
>> >> #+END_SRC
>> >>
>> >> is just IMO ugly.
>>
>> It's not that the font is ugly.  It's that
>> * (in the epub) the source code appears in a box
>> * (in the html/epub) it's impossible to tell the difference between two
>> different commands and a single command that was too long and word wrapped
>> to fit in the box
>> * (in the html/epub) I can't have non-monospace comments between/attached
>> to/within the code without drawing four or five separate boxes around my
>> code
>> * (in the org file) For whatever reason, monospace code appears as a
>> light-gray font, which is hard to read against a white background.  I'm
>> sure that can be changed, but I haven't had time to figure it out yet.
>>

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

* Re: markup text with leading, trailing spaces
  2015-02-14  4:08   ` hymie!
@ 2015-02-14 19:03     ` Jorge A. Alfaro-Murillo
  2015-02-15  0:29       ` hymie!
  0 siblings, 1 reply; 11+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-02-14 19:03 UTC (permalink / raw)
  To: emacs-orgmode

hymie! writes:

> I think you are making the incorrect assumption that the machine 
> on which I maintain my Org files is the same machine that I wish 
> to execute commands on.

Yes, or that you can ssh to it.

> If my commnds were all 8 characters long or less, it would be 
> fine.  Some of my commands look like this: 
> 
> While I admit that the "useradd" command is an extreme example, 
> this becomes horribly ambiguous: 
> 
> adduser username -d /data/chroot/home/username -s  /usr/bin/rssh 
> -m -k /dev/null -g rssh pssh -x '-q -t -t' -I -i --hosts 
> hosts_linux_rhel6 'sudo -S wget 
> puppet/puppet/pub/system_patch.pl -O 
> /usr/local/bin/system_patch.pl' < hostnamefile

You could add a \ at the end of each line that does not end the 
command.

Best,

-- 
Jorge.

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

* Re: markup text with leading, trailing spaces
  2015-02-14 19:03     ` Jorge A. Alfaro-Murillo
@ 2015-02-15  0:29       ` hymie!
  0 siblings, 0 replies; 11+ messages in thread
From: hymie! @ 2015-02-15  0:29 UTC (permalink / raw)
  To: emacs-orgmode

Jorge A. Alfaro-Murillo <jorge.alfaro-murillo <at> yale.edu> writes:

> 
> hymie! writes:
> 
> > I think you are making the incorrect assumption that the machine 
> > on which I maintain my Org files is the same machine that I wish 
> > to execute commands on.
> 
> Yes, or that you can ssh to it.

Unfortunately, it is still an incorrect assumption.

> > adduser username -d /data/chroot/home/username -s  /usr/bin/rssh 
> > -m -k /dev/null -g rssh pssh -x '-q -t -t' -I -i --hosts 
> > hosts_linux_rhel6 'sudo -S wget 
> > puppet/puppet/pub/system_patch.pl -O 
> > /usr/local/bin/system_patch.pl' < hostnamefile
> 
> You could add a \ at the end of each line that does not end the 
> command.

The only problem there is that I need to know in advance what my line length
limit is.  That's why I'm really hoping for something that I can use
standard automatic word-wrapping instead of "verbatim mode".

--hymie!

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

* Re: markup text with leading, trailing spaces
  2015-02-13 21:29 markup text with leading, trailing spaces hymie!
  2015-02-13 22:31 ` Jorge A. Alfaro-Murillo
@ 2015-02-15  1:28 ` hymie!
  2015-02-23 14:55   ` hymie!
  1 sibling, 1 reply; 11+ messages in thread
From: hymie! @ 2015-02-15  1:28 UTC (permalink / raw)
  To: emacs-orgmode

hymie! <hymie <at> lactose.homelinux.net> writes:

> So while I strongly prefer the exported version of
> - ~command1~
> - ~command2~
> - ~command3~
> it's hard to copy-n-paste with the tildes in the way.

org-hide-emphasis-markers is the answer.  Setting this to true, the tildes
disappear.  

--hymie!

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

* Re: markup text with leading, trailing spaces
  2015-02-15  1:28 ` hymie!
@ 2015-02-23 14:55   ` hymie!
  2015-02-23 15:04     ` Rasmus
  0 siblings, 1 reply; 11+ messages in thread
From: hymie! @ 2015-02-23 14:55 UTC (permalink / raw)
  To: emacs-orgmode

Sorry to resurrect an old thread, but this isn't actually working.

hymie! <hymie <at> lactose.homelinux.net> writes:

> 
> hymie! <hymie <at> lactose.homelinux.net> writes:
> 
> > So while I strongly prefer the exported version of
> > - ~command1~
> > - ~command2~
> > - ~command3~
> > it's hard to copy-n-paste with the tildes in the way.
> 
> org-hide-emphasis-markers is the answer.  Setting this to true, the tildes
> disappear.  

The tildes disappear from the visual screen, but when I copy-n-paste, the
tildes are still copied. :(

Still looking for a solution that I like.

--EbH

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

* Re: markup text with leading, trailing spaces
  2015-02-23 14:55   ` hymie!
@ 2015-02-23 15:04     ` Rasmus
  2015-02-23 17:31       ` hymie!
  0 siblings, 1 reply; 11+ messages in thread
From: Rasmus @ 2015-02-23 15:04 UTC (permalink / raw)
  To: emacs-orgmode

hymie! <hymie@lactose.homelinux.net> writes:

> Sorry to resurrect an old thread, but this isn't actually working.
>
> hymie! <hymie <at> lactose.homelinux.net> writes:
>
>> 
>> hymie! <hymie <at> lactose.homelinux.net> writes:
>> 
>> > So while I strongly prefer the exported version of
>> > - ~command1~
>> > - ~command2~
>> > - ~command3~
>> > it's hard to copy-n-paste with the tildes in the way.
>> 
>> org-hide-emphasis-markers is the answer.  Setting this to true, the tildes
>> disappear.  
>
> The tildes disappear from the visual screen, but when I copy-n-paste, the
> tildes are still copied. :(
>
> Still looking for a solution that I like.

Customize org-ascii-verbatim-format and use ox-ascii export.

-- 
And when I’m finished thinking, I have to die a lot

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

* Re: markup text with leading, trailing spaces
  2015-02-23 15:04     ` Rasmus
@ 2015-02-23 17:31       ` hymie!
  0 siblings, 0 replies; 11+ messages in thread
From: hymie! @ 2015-02-23 17:31 UTC (permalink / raw)
  To: emacs-orgmode

In our last episode, the evil Dr. Lacto had captured our hero,
  Rasmus <rasmus@gmx.us>, who said:
>>> hymie! <hymie <at> lactose.homelinux.net> writes:
>>> 
>>> > So while I strongly prefer the exported version of
>>> > - ~command1~
>>> > - ~command2~
>>> > - ~command3~
>>> > it's hard to copy-n-paste with the tildes in the way.
>>> 
>Customize org-ascii-verbatim-format and use ox-ascii export.

OMG.  That's the answer.  I can select the section, use C-c C-e t A
to export the selection into a buffer, and there's no formatting marks,
and I can copy and paste each line, and it's perfect.

Thank you!

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net

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

end of thread, other threads:[~2015-02-23 17:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13 21:29 markup text with leading, trailing spaces hymie!
2015-02-13 22:31 ` Jorge A. Alfaro-Murillo
2015-02-14  4:08   ` hymie!
2015-02-14 19:03     ` Jorge A. Alfaro-Murillo
2015-02-15  0:29       ` hymie!
2015-02-15  1:28 ` hymie!
2015-02-23 14:55   ` hymie!
2015-02-23 15:04     ` Rasmus
2015-02-23 17:31       ` hymie!
  -- strict thread matches above, loose matches on Subject: below --
2015-02-14 17:19 darcamo
2015-02-14 17:41 ` hymie

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