* lisp/ob-comint.el (org-babel-comint-with-output): Do not try to
filter out prompts in `comint-output-filter-functions'. The prompts
may arrive there arbitrarily - multiple prompts together, partial
prompts, full prompts, etc. For example "ghci> " prompt may arrive as
"gh" + "ci> " with second part still matching `comint-prompt-regexp'.
As a result, if we keep using `comint-output-filter-functions', the
split prompts may sometimes retain their initial part, littering the
results. Now, we postpone filtering to after receiving the output,
still making sure that agglomerated prompts gets filtered using a
custom regexp derived from `comint-prompt-regexp'.
* lisp/ob-comint.el (org-babel-comint-with-output): Consider that
comint can sometimes agglomerate multiple prompts together even within
a single output increment as passed to
`comint-output-filter-functions'.
Example in GHC comint buffer:
GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
ghci> ghci> :{
main :: IO ()
main = putStrLn "Hello World!"
:}
main
"org-babel-haskell-eoe"
ghci| ghci| ghci| ghci> ghci> Hello World!
ghci> "org-babel-haskell-eoe"
ghci>
* lisp/ob-comint.el (org-babel-comint-with-output): Do not rely on
output filter when detecting prompt lines. Search for
`comint-prompt-regexp' in the full output after applying the filter.
This is needed when the filter is supplied with partial prompts.
Reported-by: Frédéric Santos <frederic.santos@u-bordeaux.fr>
Link: https://orgmode.org/list/877czca7oj.fsf@u-bordeaux.fr
* lisp/ob-comint.el (org-babel-comint-with-output): Consider scenarios
when comint emits output without trailing newlines. The strategy to
split the full concatenated output using `comint-prompt-regexp' does
not work when the regexp matches bol. Use a constant string as a
separator instead of relying upon `comint-prompt-regexp'.
Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://orgmode.org/list/m2czakgpk8.fsf@me.com
* lisp/ob-comint.el (org-babel-comint-with-output): Clean up empty
output. Such output is emitted unnecessarily for multi-line scripts.
* lisp/ob-shell.el (org-babel-shell-set-prompt-commands): Disable
PS2 and equivalent prompts. Make sure that PROMPT_COMMAND does not
interfere with PS1 setting in POSIX shells.
(org-babel-sh-evaluate): Do not send input line-by-line. Instead, let
`org-babel-coming-with-output' handle waiting for the output as well
as recording it. Update to the new `org-babel-coming-with-output'
behavior of cleaning empty outputs.
* testing/lisp/test-ob-shell.el (test-ob-shell/session): Add a test.
Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/orgmode/m2r0zboix1.fsf@me.com/
* lisp/ob-comint.el (org-babel-comint-wait-for-output): Do not rely on
`face-at-point' returning non-nil.
* lisp/ob-shell.el (org-babel-shell-set-prompt-commands): New constant
holding shell-specific commands to change prompt.
(org-babel-prompt-command): New variable holding command to be user to
set distinguishable prompt.
(org-babel-shell-initialize): Set `org-babel-prompt-command' according
to shell name.
(org-babel-sh-prompt): New variable holding default shell prompt.
(org-babel-sh-initiate-session): Change the default prompt to
`org-babel-sh-prompt' and alter `comint-prompt-regexp' to match it
tightly.
Fixes https://list.orgmode.org/CKK9TULBP2BG.2UITT31YJV03J@laptop/T/#mc8e3ca2f5f1b9a94040a68b4c6201234b209041c
Emacs now advises using "website" (instead of "homepage") and
consequently to use the "URL" comment header instead of "Homepage".
* README:
* README_ELPA:
* doc/org-guide.org (Creating Footnotes):
* doc/org-manual.org (Creating Footnotes):
* etc/styles/README (URL): Prefer "website" to "homepage".
* lisp/*.el:
* mk/org-fixup.el: Replace the "Homepage" header comment with "URL".
Adds functionality to ob-comint.el to implement async session eval on
a per-language basis. Adds a reference implementation for ob-python.
* lisp/ob-comint.el (org-babel-comint-with-output): Remove comment.
(org-babel-comint-async-indicator, org-babel-comint-async-buffers,
org-babel-comint-async-file-callback,
org-babel-comint-async-chunk-callback,
org-babel-comint-async-dangling): Add buffer-local variables used for
async comint evaluation.
(org-babel-comint-use-async): Add function to determine whether block
should be evaluated asynchronously.
(org-babel-comint-async-filter): Add filter function to attach to
comint-output-filter-functions for babel async eval.
(org-babel-comint-async-register): Add function to setup buffer
variables and hooks for session eval.
(org-babel-comint-async-delete-dangling-and-eval): Add helper function
for async session eval.
* lisp/ob-python.el (org-babel-execute:python): Check for async header
argument.
(org-babel-python-evaluate): Check whether to use async evaluation.
(org-babel-python-async-indicator): Add constant for indicating the
start/end of async evaluations.
(org-babel-python-async-evaluate-session): Add function for Python
async eval.
*
testing/lisp/test-ob-python.el (test-ob-python/async-simple-session-output):
Unit test for Python async session eval.
(test-ob-python/async-named-output): Unit test that Python async eval
can replace named output.
(test-ob-python/async-output-drawer): Unit test that Python async eval
works with drawer results.
* lisp/ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Use `declare`.
* lisp/ob-core.el (org-babel-map-src-blocks): Use `declare`.
(org-babel-result-cond): Simplify edebug spec.
* lisp/org-clock.el (org-with-clock-position, org-with-clock):
* lisp/org-agenda.el (org-agenda-with-point-at-orig-entry):
* lisp/ob-tangle.el (org-babel-with-temp-filebuffer): Use `declare`.
Use `declare` instead of `def-edebug-spec` in most places
f8dbefbaa59bb17dd4a2dfa4d9ff560c46785792
Stefan Monnier
Fri Feb 12 16:08:01 2021 -0500
* ob-comint.el (org-babel-comint-eval-invisibly-and-wait-for-file):
The tramp macro `with-parsed-tramp-file-name' invokes a bunch of
tramp functions. These are now declared and tramp is explicitly
required.
* ob-comint.el (org-babel-comint-eval-invisibly-and-wait-for-file):
Remove the `(ignore v)'. This creates a byte-compiler warning for
supposedly unused `v', but allows remote execution.
* ob-comint.el: (tramp-flush-directory-property declaration): The
file is now "tramp-cache".
* ob-comint.el (org-babel-comint-eval-invisibly-and-wait-for-file):
Remove unused let binding for `v' (which is let bound by
`with-parsed-tramp-file-name').
Bug reported by Vikas Rawal
Subject: Using tramp to run R source code blocks on remote server
Archived-At: <http://permalink.gmane.org/gmane.emacs.orgmode/106557>
Add changes from Emacs repo that should have been backported with
bb77dd2.
Update copyright year to 2015
7e09ef09a479731d01b1ca46e94ddadd73ac98e3
Paul Eggert
Thu Jan 1 14:26:41 2015 -0800
* lisp/ob-comint.el (org-babel-comint-eval-invisibly-and-wait-for-file):
Fix bug.
The intention is to test whether the string ends with a newline, so we
should just do that. Otherwise:
(string-match "\n$" "foo\n\nbar") ;; => 3 => :-(
* lisp/ob-comint.el (org-babel-comint-in-buffer): don’t add to
comint-input-ring
Previously, babel code would be added to the comint input ring of a
babel session, making interactive use of the session difficult: one
had to page through the babel generated commands when browsing the
comint history with M-p/M-n. The session repl’s history should just
contain commands the user has specifically entered in the repl buffer,
and not those which are fed in from org mode. So, we bind
‘comint-input-filter’ to a function that always returns nil in the
‘org-babel-comint-in-buffer’ macro, to avoid any additions to the
input ring while executing code from babel.