emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] markup text with leading, trailing spaces


From: Jorge A. Alfaro-Murillo
Subject: Re: [O] markup text with leading, trailing spaces
Date: Fri, 13 Feb 2015 17:31:41 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]