emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Executing sh-code


From: Sébastien Vauban
Subject: [Orgmode] Executing sh-code
Date: Fri, 15 Oct 2010 18:06:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (windows-nt)

Hi Eric,

* Executing sh code

This report is not complete yet (I now really have to go), but comments are
already welcome, and can put things in light for further study...

** No session

#+begin_src sh
echo In $(pwd):
ls *.org
#+end_src

#+results:
| In                          | /cygdrive/c/home/sva/Examples/Org-scraps: |
| Agenda-Sorting-Strategy.org |                                           |
| Clock-Report.org            |                                           |
| Ledger-Scorpios.org         |                                           |
| org-beamer-fpu-rules.org    |                                           |
| org-hist.org                |                                           |

** With session

#+begin_src sh :session sva
echo In $(pwd):
ls *.org
#+end_src

never terminates, echoing:

: executing Sh code block...

in the minibuffer.

** Variable comint-prompt-regexp

Value of the =comint-prompt-regexp= variable in my shell, used by Org-babel to
digest output from the shell:

#+begin_src emacs-lisp
(switch-to-buffer "sva")
(describe-variable 'comint-prompt-regexp)
#+end_src

#+results:
#+begin_example
comint-prompt-regexp is a variable defined in `comint.el'.
Its value is 
"^[^#$%>\n]*[#$%>] *"
Local in buffer sva; global value is "^"

Documentation:
Regexp to recognize prompts in the inferior process.
Defaults to "^", the null string at BOL.

This variable is only used if the variable
`comint-use-prompt-regexp' is non-nil.

Good choices:
  Canonical Lisp: "^[^> \n]*>+:? *" (Lucid, franz, kcl, T, cscheme, oaklisp)
  Lucid Common Lisp: "^\\(>\\|\\(->\\)+\\) *"
  franz: "^\\(->\\|<[0-9]*>:\\) *"
  kcl: "^>+ *"
  shell: "^[^#$%>\n]*[#$%>] *"
  T: "^>+ *"

This is a good thing to set in mode hooks.
#+end_example

This regexp should match my own prompt as it appears in your *shell*
buffers locally (product of my personal =.bashrc=) configuration.

** What about shell-prompt-pattern?

Browsing along, it seems there is another interesting value to look at:
=shell-prompt-pattern=.

#+begin_src emacs-lisp
(switch-to-buffer "sva")
(describe-variable 'shell-prompt-pattern)
#+end_src

#+results:
#+begin_example
shell-prompt-pattern is a variable defined in `shell.el'.
Its value is 
"^MEDIACENTER [^ ]+ \\[[0-9]+\\] "

Documentation:
Regexp to match prompts in the inferior shell.
Defaults to "^[^#$%>\n]*[#$%>] *", which works pretty well.
This variable is used to initialize `comint-prompt-regexp' in the
shell buffer.

If `comint-use-prompt-regexp' is nil, then this variable is only used
to determine paragraph boundaries.  See Info node `Shell Prompts' for
how Shell mode treats paragraphs.

The pattern should probably not match more than one line.  If it does,
Shell mode may become confused trying to distinguish prompt from input
on lines which don't start with a prompt.

This is a fine thing to set in your `.emacs' file.

You can customize this variable.
#+end_example

** Back to comint's prompt regexp!

#+begin_src emacs-lisp
(switch-to-buffer "sva")
(describe-variable 'comint-use-prompt-regexp)
#+end_src

#+results:
#+begin_example
comint-use-prompt-regexp is a variable defined in `comint.el'.
Its value is nil

Documentation:
If non-nil, use `comint-prompt-regexp' to recognize prompts.
If nil, then program output and user-input are given different `field'
properties, which Emacs commands can use to distinguish them (in
particular, common movement commands such as `beginning-of-line'
respect field boundaries in a natural way).

You can customize this variable.
#+end_example

NIL!?  Do you have this as well?

Thanks!

Best regards,
  Seb

-- 
Sébastien Vauban




reply via email to

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