aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/ob-python.el (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ob-python: Wait for session initialization on slow machinesIhor Radchenko2022-11-151-2/+18
| | | | | | | | | | | | * lisp/ob-python.el (org-babel-python--initialized): New internal flag used to indicate that python session has been initialized in buffer. (org-babel-python-initiate-session-by-key): Set `org-babel-python--initialized' in `python-shell-first-prompt-hook' when using built-in python.el. Wait until the hook is fired before we finish initiating the session. This patch intends to fix CI test failures where the CPU allocation is limited and python loading is extremely slow.
* ob-python: Handle newer version of python-mode.elIhor Radchenko2022-10-261-3/+2
| | | | | | | | | | * lisp/ob-python.el (py-choose-shell): (py-toggle-shells): Use the new function name. (py-default-interpreter): Remove the variable that is no longer provided by python-mode.el. (org-babel-python-initiate-session-by-key): Use `py-choose-shell'. Reported-by: Christian Köstlin <christian.koestlin@gmail.com>
* Assert all the Org files to load the same Org versionIhor Radchenko2022-09-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/org-compat.el (org-assert-version): New macro comparing Org version at compile time and laod time. Add `org-assert-version' call to all files: * lisp/org-macs.el: * lisp/org-crypt.el: * lisp/org-ctags.el: * lisp/org-cycle.el: * lisp/org-datetree.el: * lisp/org-duration.el: * lisp/org-element.el (avl-tree): * lisp/org-entities.el: * lisp/org-faces.el: * lisp/org-feed.el: * lisp/org-fold-core.el: * lisp/org-fold.el: * lisp/org-footnote.el: * lisp/org-goto.el: * lisp/org-habit.el: * lisp/org-id.el: * lisp/org-indent.el: * lisp/org-inlinetask.el: * lisp/org-keys.el: * lisp/org-lint.el: * lisp/org-list.el: * lisp/org-macro.el: * lisp/org-mobile.el: * lisp/org-mouse.el: * lisp/org-num.el: * lisp/org-pcomplete.el: * lisp/org-persist.el: * lisp/org-plot.el: * lisp/org-protocol.el: * lisp/org-refile.el: * lisp/org-src.el: * lisp/org-table.el: * lisp/org-tempo.el: * lisp/org-timer.el: * lisp/org.el: * lisp/ox-ascii.el: * lisp/ox-beamer.el: * lisp/ox-html.el: * lisp/ox-icalendar.el: * lisp/ox-koma-letter.el: * lisp/ox-latex.el: * lisp/ox-man.el: * lisp/ox-md.el: * lisp/ox-odt.el: * lisp/ox-org.el: * lisp/ox-publish.el: * lisp/ox-texinfo.el: * lisp/ox.el:
* ob-python: Fix Emacs bug#50514 when Python loads slowlyIhor Radchenko2022-08-281-2/+3
| | | | | | * lisp/ob-python.el (org-babel-python-initiate-session-by-key): Do not rely on 10ms delay to initialize Python. Wait until python process is initialized using `org-babel-comint-wait-for-output'.
* Prefer "website" to "homepage"Stefan Kangas2022-06-261-1/+1
| | | | | | | | | | | | | | 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".
* Update copyright year to 2022Kyle Meyer2022-01-011-1/+1
|
* *el: Fix indentationBastien2021-09-291-2/+2
|
* ob-comint.el, ob-python.el: Async session evaluationJack Kamm2021-05-181-4/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge branch 'maint'Kyle Meyer2021-01-011-1/+1
|\
| * Update copyright year to 2021Kyle Meyer2021-01-011-1/+1
| |
| * ob-python: Rename exec tmpfile handle to prevent conflictAdrian Kummerlaender2020-10-241-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python--exec-tmpfile): Rename tmpfile handle (org-babel-python-format-session-value): Rename tmpfile handle Opening the exec tmpfile as a `f' variable shadows any such variable that might by defined by the Python session context. e.g. my Org babel files commonly pass single letter variables inside a session which is broken by this behavior. The new name `__org_babel_python_tmpfile' is in line with other org mode specific Python variables set by ob-python. This is unlikely to conflict with the user's Python code. TINYCHANGE
* | ob-python: Rename exec tmpfile handle to prevent conflictAdrian Kummerlaender2020-10-101-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python--exec-tmpfile): Rename tmpfile handle (org-babel-python-format-session-value): Rename tmpfile handle Opening the exec tmpfile as a `f' variable shadows any such variable that might by defined by the Python session context. e.g. my Org babel files commonly pass single letter variables inside a session which is broken by this behavior. The new name `__org_babel_python_tmpfile' is in line with other org mode specific Python variables set by ob-python. This is unlikely to conflict with the user's Python code. TINYCHANGE
* | ob-python: Improvements to :return header argumentJack Kamm2020-09-271-4/+7
|/ | | | | * lisp/ob-python.el (org-babel-execute:python): Allow return-val to be non-nil in sessions, and concatenate it after the expanded body.
* ob-python: Fix hanging on emacs-26.3 by adding indicator tokenJack Kamm2020-09-091-16/+29
| | | | | | | | | | | * lisp/ob-python.el (org-babel-python-eoe-indicator): Add back variable for end-of-expression indicator. (org-babel-python--shift-right): New function to indent source body. (org-babel-python-evaluate-external-process): Call new function org-babel-python--shift-right. (org-babel-python--send-string): Wrap body in try-except-finally, print indicator token, and find end of output via the token. cf https://orgmode.org/list/871rjcan53.fsf@kyleam.com/
* ob-python: Replace session value format string with functionJack Kamm2020-09-071-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python--eval-ast): Removed. (org-babel-python-format-session-value): New function that returns Python code to evaluate for sessions with value results. (org-babel-python-evaluate-session): Replace org-babel-python--eval-ast with org-babel-python-format-session-value. Motivation is that the new function is more flexible than the old format string. We can pass in the full result-params, which can be used to add more formatting options in future. We could also add more optional arguments in the future to extend this functionality. This function will be particularly helpful for a couple patches after 9.4: - ob-reticulate - https://orgmode.org/list/875z98gj4f.fsf@gmail.com/ - Improved formatting - https://orgmode.org/list/87eenpfe77.fsf@gmail.com/ However, I add this function in now 9.4, so those future patches can rely on it in 9.4. In particular, ob-reticulate will probably be packaged separately from org-mode, and I want to provide a stable interface to it so that it can be released after 9.4.
* ob-python: Improve robustness of session evaluationJack Kamm2020-09-061-32/+36
| | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (py-send-string-no-output): Remove external function. (py-shell-send-string): Add external function. (org-babel-python--eval-ast): Remove blank lines. (org-babel-python--send-string): New function to send string to Python process and return output. (org-babel-python-evaluate-session): Call org-babel-python--send-string to evaluate code. New function to send code to Python session. It has the following desirable properties: - Wait for evaluation to finish before returning. - Input can have arbitrary spaces/newlines. - Avoid echoing input to the session. - Echo all output to the session. - Output is also captured and returned separately. - Avoid adding extra prompts to the session. - Work well with both Python and IPython repls. The implementation borrows from `python-shell-send-string-no-output' and `org-babel-comint-with-output'. This commit is related to 632ceabb1, which tried to implement the same thing, but also introduced bugs, and had to be partially reverted in b5709ddc9.
* ob-python: fix startup messages leaking into outputJack Kamm2020-09-061-9/+7
| | | | | | | | * lisp/ob-python.el (org-babel-python-initiate-session-by-key): Remove workaround for emacs<24.1. Sleep after starting Python, to prevent startup messages leaking into output results. * testing/lisp/test-ob-python.el (test-ob-python/session-multiline): Remove workaround for startup message leaking into results.
* ob-python: Add maintainer to headerJack Kamm2020-09-041-0/+1
|
* ob-python: Fix session blocks not waiting for value resultJack Kamm2020-09-041-20/+33
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (py-shell-send-string): Remove unneeded declare-function. (org-babel-python-eoe-indicator): Add back this const. (org-babel-python--eval-ast): Fix spacing so the block can be entered line by line into the interpreter. (org-babel-python-evaluate-session): Revert previous changes to evaluation for value results. * testing/lisp/test-ob-python.el (test-ob-python/session-value-sleep): New test for session blocks that don't return immediately. 632ceabb1 introduced a bug where session blocks don't wait for value results if not returned immediately. This reverts part of that commit, specifically for evaluation of session blocks with value results. It leaves other parts of that commit alone, for example the changes to session output results, which is more robust handling prompts from ipython interpreter. A downside of reverting the session value implementation is that the ugly code from org-babel-python--eval-ast is again printed in the console, but this is less bad than the new bug that was introduced by the change, hence reverted.
* ob-python: Refactor session evaluationJack Kamm2020-08-281-100/+75
| | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el: Require python.el at top-level. (org-babel-python-eoe-indicator): Remove unused variable. (org-babel-python-initiate-session-by-key): Rename python-buffer to avoid obsolete warning. (org-babel-python-evaluate-external-process): Remove unnecessary require. (org-babel-python--exec-tmpfile): Simplify this template. (org-babel-python--eval-ast): Add printing of results to this template, requiring additional string escapes. (org-babel-python-evaluate-session): Simplify to use adjusted templates, and call out to functionality in python.el or python-mode.el. (org-babel-python-evaluate-session): Simplified to use adjusted templates. This commit refactors and cleans up code related to session evaluation. python.el is now required at the top-level. Python templates for wrapping code are simplified. Instead of directly pasting code to the REPL, functionality from python.el and python-mode.el are used; this fixes issues with code being echoed to the REPL, and should be generally more robust. Finally, in the :results value case, special handling of exceptions is removed, and we no longer print None when the last statement isn't an expression.
* ob-python: Fix discrepancy of single/multi-line code blocksJack Kamm2020-08-281-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python-evaluate-session): Fix discrepancy between how single-line and multiline code blocks return output. For example, before this commit, the 2 blocks behaved differently: +begin_src python :session :results output pass "foo" +end_src +RESULTS: +begin_src python :session :results output "foo" +end_src +RESULTS: : 'foo' But now, they both behave as the former.
* ob-python.el: Fix issue with sessions on remote machinesChristian Vanderwall2020-08-201-2/+4
| | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python-evaluate-session): Process temporary file name with `org-babel-process-file-name' before inserting it into code Python code snippets. Before this change, the entire temporary filename was sent to the Python session for execution, causing a 'No such file' error when the filename had a Tramp format such as /ssh:user@server:/tmp/python-ABCDEF. TINYCHANGE
* ob-python.el: Fix multiline strings in non-session :results valueJack Kamm2020-06-091-5/+13
| | | | | | | | | | | | * lisp/ob-python.el (org-babel-python-evaluate-external-process): Use functions from python.el to indent lines, avoiding multiline strings. * testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Set test as expected to succeed. (test-ob-python/multiline-str): Add test for multiline string in body. (test-ob-python/header-var-assignment): Test that :var is in correct scope and can be assigned to. cf. https://orgmode.org/list/87tv009l9a.fsf@gmail.com/#t
* ob-python.el: Revert fix for multiline varJack Kamm2020-05-281-7/+2
| | | | | | | | | | | * lisp/ob-python.el (org-babel-execute:python, org-babel-python-evaluate): Move variable assignment back to body from preamble. * testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Mark unit test for multiline-variable as expected to fail. Reverts 6149b6cb6 which fixed multiline vars in ob-python, but caused a new bug (https://lists.gnu.org/archive/html/emacs-orgmode/2020-05/msg00719.html).
* ob-python.el: Assign variables in preamble instead of bodyJack Kamm2020-05-241-2/+7
| | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-execute:python): Add variable assignment to preamble instead of body. (org-babel-python-evaluate): Concatenate preamble (which now includes variable assignment) to body before session evaluation. Fixes https://lists.gnu.org/archive/html/emacs-orgmode/2020-03/msg00126.html. For non-session evaluation, ob-python adds indentation to the body inside main(), but this was adding spurious indentation for multiline strings passed through :var. This commit fixes the issue by moving variable assignment out of the body and into the preamble.
* ob-python.el: Fix session initiation when using python-mode.elstardiviner2020-02-191-3/+3
| | | | | | * lisp/ob-python.el (org-babel-python-initiate-session-by-key): Fixes new session initiation when org-babel-python-mode is python-mode.el.
* Tiny formatting fixesBastien2020-02-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ox.el (org-export-table-dimensions): * lisp/ox-texinfo.el (org-texinfo-template): * lisp/ox-md.el (org-md-link): * lisp/ox-icalendar.el (org-icalendar-use-UTC-date-time-p): * lisp/ox-ascii.el (org-ascii-fixed-width): * lisp/org.el (org-context): * lisp/org-table.el (org-table-eval-formula) (org-table-export): * lisp/org-refile.el: * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): * lisp/org-num.el (org-num): * lisp/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org-macro.el (org-macro): * lisp/org-lint.el (org-lint): * lisp/org-keys.el (org-keys): * lisp/org-duration.el: * lisp/org-clock.el (org-clock-get-last-clock-out-time) (org-clock-update-mode-line, org-find-open-clocks): * lisp/org-agenda.el (org-diary) (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item) (org-agenda-highlight-todo, org-cmp-alpha) (org-agenda-filter-by-category): * lisp/ol.el (org-link-expand-abbrev, ol): * lisp/ol-docview.el (ol-docview): * lisp/ol-bibtex.el (org-execute-file-search-in-bibtex) (org-bibtex, org-bibtex-read): * lisp/ol-bbdb.el (org-bbdb-anniversary-description): * lisp/ob-tangle.el (org-babel-tangle-jump-to-org): * lisp/ob-table.el (org-babel-table-truncate-at-newline): * lisp/ob-stan.el: * lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar): * lisp/ob-sql.el: * lisp/ob-shen.el: * lisp/ob-shell.el (org-babel-prep-session:shell) (org-babel-prep-session:shell): * lisp/ob-sed.el (org-babel-execute:sed) (org-babel-execute:sed): * lisp/ob-screen.el: * lisp/ob-sass.el: * lisp/ob-ruby.el (org-babel-prep-session:ruby) (org-babel-prep-session:ruby): * lisp/ob-ref.el (org-babel-ref-resolve, ob-ref): * lisp/ob-python.el (org-babel-prep-session:python) (org-babel-prep-session:python): * lisp/ob-plantuml.el: * lisp/ob-picolisp.el: * lisp/ob-perl.el: * lisp/ob-org.el: * lisp/ob-octave.el (org-babel-prep-session:octave) (org-babel-prep-session:octave) (org-babel-octave-evaluate-session): * lisp/ob-ocaml.el: * lisp/ob-mscgen.el (org-babel-execute:mscgen) (org-babel-execute:mscgen): * lisp/ob-maxima.el: (ob-maxima): * lisp/ob-matlab.el: * lisp/ob-makefile.el: * lisp/ob-lua.el (org-babel-prep-session:lua) (org-babel-prep-session:lua): * lisp/ob-lisp.el: * lisp/ob-ledger.el: * lisp/ob-latex.el (org-babel-expand-body:latex) (org-babel-expand-body:latex, ob-latex): * lisp/ob-js.el: * lisp/ob-java.el: * lisp/ob-io.el (org-babel-prep-session:io) (org-babel-prep-session:io): * lisp/ob-hledger.el: * lisp/ob-haskell.el: * lisp/ob-groovy.el (org-babel-groovy-wrapper-method) (org-babel-groovy-evaluate): * lisp/ob-gnuplot.el: * lisp/ob-fortran.el (org-babel-expand-body:fortran) (org-babel-expand-body:fortran): * lisp/ob-forth.el (org-babel-forth-session-execute): * lisp/ob-exp.el (ob-exp): * lisp/ob-eval.el: * lisp/ob-emacs-lisp.el: * lisp/ob-ebnf.el: * lisp/ob-dot.el: * lisp/ob-ditaa.el: * lisp/ob-css.el: * lisp/ob-core.el (org-babel-put-rownames): * lisp/ob-coq.el: * lisp/ob-comint.el: * lisp/ob-calc.el: * lisp/ob-awk.el: * lisp/ob-asymptote.el: * lisp/ob-abc.el: * lisp/ob-R.el (org-babel-prep-session:R): Formatting fixes.
* Revert "ob-python: Session returns empty string if no return value"Bastien2020-02-171-1/+1
| | | | This reverts commit 5fc45765483f80cbfbdb4f07a21588ef3392dccc.
* ob-python: Session returns empty string if no return valueJack Kamm2020-02-171-1/+1
| | | | | * lisp/ob-python.el (org-babel-python--eval-ast): Change sessions to return an empty string, instead of None, if there is no return value.
* ob-python: Remove unused variableJack Kamm2020-02-041-1/+0
| | | | | * lisp/ob-python.el (org-babel-python-evaluate-session): Remove unused lexical variable `last-indent' that was causing a compilation warning
* ob-python: Fix several issues with :session :results valueJack Kamm2020-02-031-27/+41
| | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-babel-python-evaluate-session): Fix a few related issues with :session :results value blocks, including broken if-else statements, indented blocks with blank lines, and returning the wrong value when underscore has been used. (org-babel-python--eval-ast): New constant variable, a string consisting of Python code to execute a source block using ast. Previously, python blocks with parameters ":session :results value" were entered line-by-line into the Python session, which could cause issues around indentation and new lines. Now, such python blocks are written to temp files, then the built-in ast python module is used to parse and execute them, and to extract the last line separately to return as a result. Introduces a change in behavior, requiring that the last line must be a top-level expression statement if its result is to be saved (otherwise, the result is None).
* Update copyright year to 2020Kyle Meyer2020-01-011-1/+1
|
* Backport commit 114323226 from EmacsJuanma Barranquero2019-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-C.el (org-babel-prep-session:C) (org-babel-load-session:C): * lisp/ob-J.el (org-babel-execute:J): * lisp/ob-asymptote.el (org-babel-prep-session:asymptote): * lisp/ob-awk.el (org-babel-execute:awk): * lisp/ob-core.el (org-babel-process-file-name): * lisp/ob-ebnf.el (org-babel-execute:ebnf): * lisp/ob-forth.el (org-babel-execute:forth): * lisp/ob-fortran.el (org-babel-execute:fortran) (org-babel-prep-session:fortran, org-babel-load-session:fortran): * lisp/ob-groovy.el (org-babel-execute:groovy): * lisp/ob-io.el (org-babel-execute:io): * lisp/ob-js.el (org-babel-execute:js): * lisp/ob-lilypond.el (org-babel-default-header-args:lilypond) (org-babel-lilypond-compile-post-tangle) (org-babel-lilypond-display-pdf-post-tangle) (org-babel-lilypond-tangle) (org-babel-lilypond-execute-tangled-ly) (org-babel-lilypond-compile-lilyfile) (org-babel-lilypond-check-for-compile-error) (org-babel-lilypond-process-compile-error) (org-babel-lilypond-mark-error-line) (org-babel-lilypond-parse-error-line) (org-babel-lilypond-attempt-to-open-pdf) (org-babel-lilypond-attempt-to-play-midi) (org-babel-lilypond-switch-extension) (org-babel-lilypond-set-header-args): * lisp/ob-lua.el (org-babel-prep-session:lua): * lisp/ob-picolisp.el (org-babel-execute:picolisp): * lisp/ob-processing.el (org-babel-prep-session:processing): * lisp/ob-python.el (org-babel-prep-session:python): * lisp/ob-scheme.el (org-babel-scheme-capture-current-message) (org-babel-scheme-execute-with-geiser, org-babel-execute:scheme): * lisp/ob-shen.el (org-babel-execute:shen): * lisp/org-agenda.el (org-agenda-entry-types) (org-agenda-move-date-from-past-immediately-to-today) (org-agenda-time-grid, org-agenda-sorting-strategy) (org-agenda-filter-by-category, org-agenda-forward-block): * lisp/org-faces.el (org-verbatim, org-cycle-level-faces): * lisp/org-indent.el (org-indent-set-line-properties): * lisp/org-macs.el (org-get-limited-outline-regexp): * lisp/org-mobile.el (org-mobile-files): * lisp/org.el (org-use-fast-todo-selection) (org-extend-today-until, org-use-property-inheritance) (org-refresh-effort-properties) (org-track-ordered-property-with-tag, org-shiftright): * lisp/ox-html.el (org-html-checkbox-type): * lisp/ox-man.el (org-man-source-highlight) (org-man-verse-block): * lisp/ox-publish.el (org-publish-sitemap-default): Assorted docfixes. lisp/*.el: Fix typos and other trivial doc fixes 11432322650830fe9ae365f4113733a79226056d Juanma Barranquero Sat Sep 21 00:27:53 2019 +0200
* Update copyright yearBastien2019-01-011-1/+1
|
* ob-*: single armed “if” -> “when”Aaron Ecay2018-05-101-2/+2
| | | | | | | | | | | | * lisp/ob-C.el (org-babel-C-val-to-base-type): * lisp/ob-comint.el (org-babel-comint-buffer-livep): * lisp/ob-fortran.el (org-babel-fortran-ensure-main-wrap): * lisp/ob-octave.el (org-babel-octave-import-elisp-from-file): * lisp/ob-scheme.el (org-babel-scheme-get-repl): Transform ‘if’ with no else branch to ‘when’ * lisp/ob-lua.el (org-babel-lua-evaluate-external-process): * lisp/ob-python.el (org-babel-python-evaluate-external-process): Simplify conditional logic slightly.
* Update declare-function calls for functions that have moved.Aaron Ecay2018-05-101-2/+1
| | | | | In cases where functions have moved from org.el into org-macs.el, it is often possible to replace declare-function by (require 'org-macs)
* ob-python: Small refactoringNicolas Goaziou2018-04-031-13/+13
| | | | | * lisp/ob-python.el (org-babel-python-evaluate-session): Small refactoring.
* ob-python: Insert blank line when sending code to interpreterGong Qijian2018-04-031-1/+13
| | | | | | | | | | | | | | | | | | * lisp/ob-python.el (org-bable-python-evaluate-session): Syntax error occurs when evaluating the following code block: \#+begin_src python :session if True: 1 2 \#+end_src A blank line is required for top level module code to end an indented block, such as a for loop, try/except, or if statement. https://www.python.org/dev/peps/pep-0008/#blank-line TINYCHANGE
* Use https for links to orgmode.orgTim Landscheidt2018-01-191-1/+1
| | | | TINYCHANGE
* Update copyright yearsKyle Meyer2018-01-071-1/+1
|
* ob-python: Fix :session :results output multiline behaviorJack Kamm2017-12-181-10/+26
| | | | | | | | | * lisp/ob-python.el (orb-babel-python-evaluate-session): When :session :results output, send multiline code blocks to tmpfile and execute in Python with exec(). (org-babel-python--exec-tmpfile): New variable. * testing/lisp/test-ob-python.el (test-ob-python/session-multiline): Test for :session with multiple lines and indentation.
* Backport commit bc511a64f from EmacsPaul Eggert2017-09-171-1/+1
| | | | | | | Prefer HTTPS to FTP and HTTP in documentation bc511a64f6da9ab51acc7c8865e80c4a4cb655c2 Paul Eggert Wed Sep 13 15:54:37 2017 -0700
* ob-python: Honor the :python header argument in python src blocksNathaniel Nicandro2017-04-291-3/+4
| | | | | | | | * lisp/ob-python.el (org-babel-execute:python): `org-babel-python-command` should be set before calling `org-babel-python-initiate-session`. TINYCHANGE
* Update copyright yearsKyle Meyer2017-01-051-1/+1
|
* Use ‘eq’ instead of ‘equal’ for symbolsAaron Ecay2016-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-C.el (org-babel-C-val-to-C-type): * lisp/ob-core.el (org-babel-get-colnames): (org-babel-disassemble-tables): * lisp/ob-lua.el (org-babel-lua-var-to-lua): (org-babel-lua-table-or-string): * lisp/ob-python.el (org-babel-python-var-to-python): (org-babel-python-table-or-string): * lisp/ob-ruby.el (org-babel-ruby-var-to-ruby): (org-babel-ruby-table-or-string): * lisp/ob-shell.el (org-babel-sh-var-to-string): * lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar): * lisp/org-agenda.el (org-agenda-prepare-window): (org-compile-prefix-format): * lisp/org-bibtex.el (org-bibtex-headline): * lisp/org-capture.el (org-capture): * lisp/org-colview.el (org-columns-next-allowed-value): * lisp/org-mhe.el (org-mhe-store-link): (org-mhe-get-message-real-folder): (org-mhe-get-message-folder): (org-mhe-get-message-num): (org-mhe-get-header): (org-mhe-follow-link): * lisp/org-table.el (org-define-lookup-function): * lisp/org.el (format-spec): * lisp/ox-odt.el (org-odt--translate-description-lists): * lisp/ox-publish.el (org-publish-compare-directory-files): Use `eq' instead of `equal' when comparing to symbols. * lisp/org-timer.el (org-timer-set-mode-line): * lisp/org-capture.el (org-capture-finalize): Use `cl-case' instead of `(cond ((eq x 'foo) ...) ...)'.
* Use assq instead of assoc for :keywordsAaron Ecay2016-09-231-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-C.el (org-babel-C-execute): * lisp/ob-J.el (org-babel-execute:J): * lisp/ob-R.el (org-babel-edit-prep:R): (org-babel-expand-body:R): (org-babel-execute:R): (org-babel-variable-assignments:R): (org-babel-R-initiate-session): * lisp/ob-abc.el (org-babel-execute:abc): * lisp/ob-asymptote.el (org-babel-execute:asymptote): * lisp/ob-awk.el (org-babel-execute:awk): * lisp/ob-clojure.el (org-babel-expand-body:clojure): (org-babel-execute:clojure): * lisp/ob-core.el (org-babel-expand-body:generic): (org-babel-load-in-session): (org-babel-initiate-session): (org-babel-open-src-block-result): (org-babel-process-params): (org-babel-insert-result): (org-babel-expand-noweb-references): * lisp/ob-ditaa.el (org-babel-execute:ditaa): * lisp/ob-dot.el (org-babel-execute:dot): * lisp/ob-ebnf.el (org-babel-execute:ebnf): * lisp/ob-emacs-lisp.el (org-babel-expand-body:emacs-lisp): (org-babel-execute:emacs-lisp): * lisp/ob-exp.el (org-babel-exp-process-buffer): (org-babel-exp-do-export): (org-babel-exp-code): * lisp/ob-forth.el (org-babel-execute:forth): * lisp/ob-fortran.el (org-babel-execute:fortran): * lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): (org-babel-expand-body:gnuplot): (org-babel-execute:gnuplot): * lisp/ob-groovy.el (org-babel-execute:groovy): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-execute:io): * lisp/ob-java.el (org-babel-execute:java): * lisp/ob-js.el (org-babel-execute:js): * lisp/ob-latex.el (org-babel-execute:latex): * lisp/ob-ledger.el (org-babel-execute:ledger): * lisp/ob-lilypond.el (org-babel-lilypond-process-basic): * lisp/ob-lisp.el (org-babel-expand-body:lisp): (org-babel-execute:lisp): * lisp/ob-lua.el (org-babel-execute:lua): * lisp/ob-maxima.el (org-babel-execute:maxima): * lisp/ob-mscgen.el (org-babel-execute:mscgen): * lisp/ob-ocaml.el (org-babel-execute:ocaml): * lisp/ob-octave.el (org-babel-execute:octave): * lisp/ob-org.el (org-babel-execute:org): * lisp/ob-perl.el (org-babel-execute:perl): * lisp/ob-picolisp.el (org-babel-execute:picolisp): * lisp/ob-plantuml.el (org-babel-execute:plantuml): * lisp/ob-python.el (org-babel-execute:python): * lisp/ob-ruby.el (org-babel-execute:ruby): * lisp/ob-sass.el (org-babel-execute:sass): * lisp/ob-scala.el (org-babel-execute:scala): * lisp/ob-scheme.el (org-babel-execute:scheme): * lisp/ob-screen.el (org-babel-execute:screen): (org-babel-prep-session:screen): * lisp/ob-shell.el (org-babel-execute:shell): (org-babel-variable-assignments:shell): (org-babel-sh-evaluate): * lisp/ob-shen.el (org-babel-execute:shen): * lisp/ob-sql.el (org-babel-execute:sql): * lisp/ob-sqlite.el (org-babel-execute:sqlite): * lisp/ob-tangle.el (org-babel-tangle): (org-babel-tangle-single-block): * lisp/org-src.el (org-src-associate-babel-session): * lisp/org.el (org-next-link): Use `assq' instead of `assoc' with :keyword keys.
* Clean up string handling.Aaron Ecay2016-08-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/org-compat.el (string-prefix-p, string-suffix-p): Add compatibility definitions for 24.3. * lisp/ob-R.el (org-babel-edit-prep:R): * lisp/ob-core.el (org-babel-demarcate-block): * lisp/ob-js.el (org-babel-js-read): * lisp/ob-latex.el (org-babel-execute:latex): * lisp/ob-ref.el (org-babel-ref-parse): * lisp/ob-shell.el (org-babel-variable-assignments:shell): * lisp/org-protocol.el (org-protocol-create): * lisp/org-table.el (org-table-field-info): * lisp/org.el (org-get-buffer-for-internal-link): * lisp/ox-publish.el (org-publish-compare-directory-files): * lisp/ox-texinfo.el (org-texinfo-template): Use `string-{suffix,prefix}-p' instead of `string-match(-p)'. * lisp/ob-python.el (org-babel-python-read-string): Ditto, also use `substring' rather than `match-string'. * lisp/org-table.el (org-table-copy-down): (org-table-insert-hline, org-table-current-field-formula): (org-table-get-formula): Use `string-match-p' instead of `string-match'.
* Silence byte-compilerNicolas Goaziou2016-07-251-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/ob-core.el (org-babel-process-params): Silence byte-compiler. * lisp/ob-groovy.el (org-babel-groovy-evaluate): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-io.el (org-babel-io-evaluate): * lisp/ob-octave.el (org-babel-octave-evaluate-external-process): (org-babel-octave-evaluate-session): * lisp/ob-perl.el (org-babel-perl-evaluate): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ruby.el (org-babel-ruby-pp-wrapper-method): (org-babel-ruby-evaluate): * lisp/ob-scala.el: * lisp/ob-tangle.el: (org-babel-tangle-collect-blocks): * lisp/org-agenda.el (org-agenda-get-category-icon): (org-agenda-todo-yesterday): * lisp/org-bbdb.el (org-bbdb-anniv-extract-date): (org-bbdb-make-anniv-hash): (org-bbdb-anniversaries-future): * lisp/org-bibtex.el (org-bibtex-fleshout): (org-bibtex-read): (org-bibtex-write): * lisp/org-capture.el (org-capture-set-target-location): (org-capture-get-indirect-buffer): (org-mks): * lisp/org-clock.el (org-clock--oldest-date): (org-clock-resolve): (org-clock-sum): (org-clock-special-range): (org-clocktable-steps): * lisp/org-ctags.el (org-ctags-create-tags): * lisp/org-element.el (org-element--interpret-affiliated-keywords): (org-element--cache-shift-positions): (org-element--cache-sync): (org-element--cache-submit-request): * lisp/org-habit.el (org-habit-parse-todo): * lisp/org-inlinetask.el (org-inlinetask-hide-tasks): * lisp/org-lint.el (org-lint--generate-reports): * lisp/org-mouse.el (org-mouse-get-context): * lisp/org-plot.el (org-plot/gnuplot-to-grid-data): (org-plot/gnuplot): * lisp/ox-ascii.el (org-ascii--current-text-width): (org-ascii--current-justification): (org-ascii--build-caption): (org-ascii--checkbox): (org-ascii-item): * lisp/ox-html.el (org-html-footnote-section): * lisp/ox-latex.el (org-latex--make-option-string): * lisp/ox-odt.el (org-odt-toc): (org-odt-add-automatic-style): (org-odt-format-label): (org-odt-link--inline-image): (org-odt--render-image/formula): (org-odt--enumerable-image-p): (org-odt--enumerable-latex-image-p): (org-odt--enumerable-formula-p): (org-odt-do-format-code): (org-odt-table-cell): Silence byte-compiler.
* Remove unnecessary (require 'cl)Nicolas Goaziou2016-07-251-1/+0
|
* Deprecate `org-babel-trim' in favor of `org-trim'Nicolas Goaziou2016-06-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/org.el (org-trim): Add optional argument. * contrib/lisp/ob-mathematica.el (org-babel-execute:mathematica): * contrib/lisp/org-bibtex-extras.el (obe-html-export-citations): * contrib/lisp/org-mime.el (org-mime-compose): * lisp/ob-C.el (org-babel-C-execute): * lisp/ob-calc.el (org-babel-execute:calc): * lisp/ob-clojure.el (org-babel-expand-body:clojure): * lisp/ob-core.el (org-babel-initiate-session): (org-babel-parse-multiple-vars): (org-babel-read-element): (org-babel-insert-result): (org-babel-expand-noweb-references): (org-babel-trim): Mark obsolete. * lisp/ob-forth.el (org-babel-forth-session-execute): * lisp/ob-fortran.el (org-babel-execute:fortran): * lisp/ob-haskell.el (org-babel-execute:haskell): * lisp/ob-latex.el (org-babel-expand-body:latex): * lisp/ob-lisp.el (org-babel-expand-body:lisp): * lisp/ob-ocaml.el (org-babel-execute:ocaml): * lisp/ob-octave.el (org-babel-octave-evaluate-session): * lisp/ob-python.el (org-babel-python-evaluate-external-process): (org-babel-python-evaluate-session): * lisp/ob-ref.el (org-babel-ref-split-args): * lisp/ob-ruby.el (org-babel-ruby-evaluate): * lisp/ob-shell.el (org-babel-sh-evaluate): * lisp/ob-table.el (org-sbe): * lisp/ob-tangle.el (org-babel-spec-to-string): * lisp/org-bibtex.el (org-bibtex-get): * testing/lisp/test-ob.el (test-ob/parse-header-args): Use `org-trim' instead of `org-babel-trim'.