[Top][All Lists]

[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

| 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

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)

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

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.

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:

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

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

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.

** Back to comint's prompt regexp!

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

comint-use-prompt-regexp is a variable defined in `comint.el'.
Its value is nil

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.

NIL!?  Do you have this as well?


Best regards,

Sébastien Vauban

reply via email to

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