emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo)
To: emacs-orgmode@gnu.org
Subject: Re: markup text with leading, trailing spaces
Date: Fri, 13 Feb 2015 17:31:41 -0500	[thread overview]
Message-ID: <87wq3ligtu.fsf@yale.edu> (raw)
In-Reply-To: loom.20150213T222427-872@post.gmane.org

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	other threads:[~2015-02-13 22:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 21:29 markup text with leading, trailing spaces hymie!
2015-02-13 22:31 ` Jorge A. Alfaro-Murillo [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wq3ligtu.fsf@yale.edu \
    --to=jorge.alfaro-murillo@yale.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).