Commit Graph

161 Commits

Author SHA1 Message Date
Eric Schulte c3711b14d6 org-babel-current-exec-src-block-head -> org-babel-current-src-block-location
* lisp/ob-core.el (org-babel-current-src-block-location): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
(org-babel-execute-src-block): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
* lisp/ob-exp.el (org-babel-exp-results): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
* lisp/ob-lob.el (org-babel-lob-execute): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
2013-06-08 13:19:38 -06:00
Eric Schulte 2a73e06a6d adding a new global tangle-mode header argument
* doc/org.texi (Top): Documentation for new tangle-mode header argument.
  (Specific header arguments): Documentation for new tangle-mode header
  argument.
  (rownames): Documentation for new tangle-mode header argument.
  (tangle-mode): Documentation for new tangle-mode header argument.

* lisp/ob-core.el (org-babel-common-header-args-w-values): Adding the
  new :tangle-mode header argument.
  (org-babel-read): Read values starting with a "#" character as emacs
  lisp.

* lisp/ob-tangle.el (org-babel-tangle): Use the new :tangle-mode header
  argument.

* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Use the
  new :tangle-mode header argument.
2013-06-08 12:29:02 -06:00
Eric Schulte d6a9f1aa29 org-babel-current-exec-src-block-head -> outermost
* lisp/ob-core.el (org-babel-execute-src-block): The
  org-babel-current-exec-src-block-head variable should point to the
  outermost code block.
2013-06-06 10:58:52 -06:00
Vitalie Spinu f301bbcc86 make src block location available to execution backends
* lisp/ob-core.el (org-babel-where-is-src-block-head): return
  point-marker instead of point.

  (org-babel-current-exec-src-block-head): new global variable which is
  bound during `org-babel-execute-src-block-maybe'

  (org-babel-get-src-block-info): return a list of 7 elements, last
  being the header location

Evaluation backends might need to use the exact location of the block in
original org file. For example when inserting the correct source
references for visual debugging. With this patch the information on
current block is available in `org-babel-current-exec-src-block-head'.
2013-06-06 09:13:58 -06:00
Achim Gratz 3768cec391 Babel: complete fix for priority order of header arguments from e79e8943de
* lisp/ob-core.el (org-babel-parse-inline-src-block-match),
  lisp/ob-exp.el (org-babel-exp-src-block): Give header arguments from
  properties priority over default header arguments.

The previous commit e79e8943de did fix this only in
ob-core.el (org-babel-parse-src-block-match).  It was already correct
in ob-lob.el (org-babel-lob-execute).
2013-05-19 21:06:53 +02:00
Sebastien Vauban e79e8943de Fix priority order for inheriting header arguments
* ob-core.el (org-babel-parse-src-block-match): Fix order of list of header
arguments.
2013-05-06 16:32:22 -04:00
Eric Schulte f285b7ed3d Defcustom controlling the wrapping of inline results
* lisp/ob-core.el (org-babel-inline-result-wrap): Defcustom controlling
  the wrapping of inline results.
  (org-babel-examplize-region): Use new defcustom controlling the
  wrapping of inline results.
2013-04-26 09:38:33 -06:00
Bastien Guerry 267cbe5183 Merge branch 'maint' 2013-04-25 07:30:19 +02:00
Bastien Guerry dcb0ac48a8 Use `org-called-interactively-p' instead of `called-interactively-p'
* org-agenda.el (org-agenda-write):
* ob-core.el (org-babel-expand-src-block): Use
`org-called-interactively-p'.

Thanks to Jason L Wright for reporting this.
2013-04-25 07:30:04 +02:00
Aaron Ecay 7263b326d4 Add 'light argument to some uses of org-babel-get-src-block-info
* lisp/ob-core.el (org-babel-do-key-sequence-in-edit-buffer)
(org-babel-expand-noweb-references)
* lisp/ob-tangle.el (org-babel-tangle): Use 'light argument to
`org-babel-get-src-block-info'.
2013-04-21 23:45:27 -04:00
Aaron Ecay 9969d3feeb ob-core.el (org-babel-execute-src-block): fixes for :results none
* lisp/ob-core.el (org-babel-execute-src-block): Return nil in case of
`:results none'.  Also run `org-babel-after-execute-hook' in this
circumstance.

Previously, the code returned the string "results silenced" in the case
of =:results none=, as this is the return value of the call to
`message'; additionally, the after-execute hook was not being run.
2013-04-21 23:45:27 -04:00
Bastien Guerry 3d994a602c ob-core.el (org-babel-insert-result): Fix bug when inserting results as a list: ensure we split a string containing "\n"
* ob-core.el (org-babel-insert-result): Fix bug when inserting
results as a list: ensure we split a string containing "\n".

Thanks to Sébastien Vauban for reporting this.
2013-04-19 19:44:40 +02:00
Bastien Guerry 03920a01fa Merge branch 'master-apply-aaron-patch2'
Conflicts:
	lisp/ob-core.el
2013-04-18 12:28:03 +02:00
Aaron Ecay bf29482973 Clean up various org-babel-*-maybe commands
* lisp/ob-core.el (org-babel-when-in-src-block): New macro.
  (org-babel-execute-src-block-maybe)
  (org-babel-expand-src-block-maybe)
  (org-babel-load-in-session-maybe, org-babel-pop-to-session-maybe):
  Use it.

org-babel-get-src-block-info is a potentially expensive operation, which
is why its ‘light’ argument exists.  But in any case, it is overkill to
query the whole info, if all that is needed is whether point is in a
block or not.  Factor the simplified common code out into a macro.
2013-04-18 12:26:23 +02:00
Aaron Ecay 4d763f35f5 Fix bug in org-babel-execute-src-block
* lisp/ob-core.el (org-babel-execute-src-block): Use `copy-tree'
to prevent setf from modifying users variables withing let-bound
`info' variable.

Otherwise, the setf calls in this function can reach into and change
other configuration variables, such as the library of babel.
2013-04-18 10:48:57 +02:00
Bastien Guerry 217d14ecc2 ob-core.el (org-babel-pop-to-session-maybe): Fix docstring
* ob-core.el (org-babel-pop-to-session-maybe): Fix docstring.
(org-babel-pop-to-session-maybe): Use true function's name,
not its alias.
2013-04-18 10:22:34 +02:00
Bastien Guerry cde4c876fb ob-core.el (org-babel-confirm-evaluate): Fix typo in docstring
* ob-core.el (org-babel-confirm-evaluate): Fix typo in
docstring.
2013-04-10 14:52:04 +02:00
Eric Schulte 6c11a0664e more restrictive elisp eval of header arguments
* lisp/ob-core.el (org-babel-read): More restrictive elisp eval of
  header arguments.
2013-04-09 10:35:50 -06:00
Eric Schulte 385ef25c6e don't over-evaluate result-params in macro
* lisp/ob-core.el (org-babel-result-cond): Don't over-evaluate
  result-params in macro.
2013-04-07 06:49:54 -06:00
Achim Gratz af6f32af1a fix commit df0c8a3bc4
* lisp/ob-core.el (org-babel-number-p): String match for any number
  moved first so that the match data for the length check does not
  become corrupted.
2013-04-07 11:16:45 +02:00
Eric Schulte 7117ad4f92 raw org and drawer imply verbatim results
This unifies the results handling across a number of different
  languages.  It is still possible to force tabular output by adding the
  ":results table" argument.

The following example demonstrates the results in shell python and perl.

** drawer and table
#+begin_src sh :results drawer table
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1 |
| 2 |
| 3 |
:END:

#+begin_src perl :results drawer table
"1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1 |
| 2 |
| 3 |
:END:

#+begin_src python :results drawer table
return "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1\n2\n3 |
:END:

** drawer
#+begin_src sh :results drawer
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

#+begin_src perl :results drawer
"1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

#+begin_src python :results drawer
return "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

** raw
#+begin_src sh :results raw
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

#+begin_src perl :results raw
"1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

#+begin_src python :results raw
return "1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

* lisp/ob-core.el (org-babel-result-cond): The "raw", "org" and "drawer"
  :results header argument values preclude table processing unless the
  "table" argument is given as well.
2013-04-06 11:39:23 -06:00
Eric Schulte 3932efdf8e intuitive code block post processing w/file results
* lisp/ob-core.el (org-babel-execute-src-block): Make sure we process
  file results before they are passed to the post-processing code block,
  and not afterwards.  Tangles these two header arguments in the code,
  but makes for more intuitive behavior and enables important use cases.
2013-04-04 06:41:55 -06:00
Eric Schulte bde2348c9e read code block values with earmuffs as Emacs Lisp
* lisp/ob-core.el (org-babel-read): Read code block values with earmuffs
  as Emacs Lisp.
2013-04-04 06:41:55 -06:00
Eric Schulte d35ec18ab5 post header arg post-processes code block results
* lisp/ob-core.el (org-babel-common-header-args-w-values): Add :post to
  the list of header arguments.
  (org-babel-execute-src-block): Post process results when the :post
  header argument has been supplied.
2013-04-04 06:41:55 -06:00
Eric Schulte 2f39a704cf removing alternate code block variable syntax
* doc/org.texi (var): Remove the "Alternate argument syntax" section
  from the documentation.
* lisp/ob-core.el (org-babel-src-name-w-name-regexp): Update the regexp
  used to match code block names.
  (org-babel-get-src-block-info): Remove the code used to parse this
  alternate variable specification syntax.
2013-04-03 09:17:00 -06:00
Eric Schulte 221da3ad27 cycle tables for :results org and :results wrap
* lisp/ob-core.el (org-babel-insert-result): Cycle tables for :results
  org and :results wrap.
2013-03-29 17:57:06 -06:00
Eric Schulte df0c8a3bc4 don't interpret single "-" as a number
* lisp/ob-core.el (org-babel-number-p): Don't interpret single "-" as a
  number.
2013-03-29 08:48:59 -06:00
Suhail Shergill 3b2abfce7b bugfix: fix `org-babel-execute-src-block' on remote hosts
* lisp/ob-core.el (org-babel-temp-file): For remote hosts, modify the prefix
  and leave `temporary-file-directory' unchanged.

The reason setting `temporary-file-directory' doesn't work here is
because `make-temp-file' recursively calls itself (indirectly).
Modifying `temporary-file-directly', affects the recursive calls as well,
which results in a "No such file file or directory" error.

The fix is to leave `temporary-file-directory' unaltered, for remote
hosts, and instead modifying the 'prefix' argument to `make-temp-file'
appropriately.

TINYCHANGE
2013-03-25 06:09:14 +01:00
Bastien Guerry 7610231952 ob-core.el (org-babel-hash-show-time): tiny Docstring enhancement
* ob-core.el (org-babel-hash-show-time): tiny Docstring enhancement.
2013-03-25 05:41:58 +01:00
Eric Schulte a461b0a444 allow comments between code blocks and un-named res
* lisp/ob-core.el (org-babel-where-is-src-block-result): Allow comments
  between code blocks and un-named results.
2013-03-17 19:57:01 -05:00
Achim Gratz 4f7d514f13 ob-core: allow auto-denial of source block evaluation
* lisp/ob-core.el (org-babel-confirm-evaluate-answer-no): Dynamically
  scoped variable, if bound non-nil the confirmation dialog will not
  be initiated and denial of evaluation is assumed.

  The new variable `org-babel-confirm-evaluate-answer-no´ can be bound
  to suppress the user interaction as is needed for async export, as
  discussed in http://thread.gmane.org/gmane.emacs.orgmode/67719
2013-03-09 23:09:15 +01:00
Eric Schulte d7758f565c refactor `org-babel-check-confirm-evaluate' macro
- meaningful variable names
- don't overly pollute the name space of the macro body

* lisp/ob-core.el (org-babel-check-confirm-evaluate): Refactoring.
2013-03-09 21:45:40 +01:00
Eric Schulte bc6564ab48 whitespace changes
spaces between lines, and fix overlong lines

* lisp/ob-core.el (org-babel-check-confirm-evaluate): Whitespace.
  (org-babel-confirm-evaluate): Whitespace.
2013-03-09 21:43:29 +01:00
Eric Schulte b0bccccb5c additional code block execution refactoring
multiple changes to remove overly long lines.

* lisp/ob-core.el (org-babel-execute-src-block): A cond makes it more
  clear that we definitely do not execute without user confirmation.

  (org-babel-where-is-src-block-result): Overly long line.
2013-03-09 21:43:18 +01:00
Achim Gratz be0883940d ob-core: refactor org-babel-confirm-evaluate, do not confirm evaluation if cache is current
* lisp/ob-core.el (org-babel-check-confirm-evaluate): New macro to
  establish bindings based on INFO.
* lisp/ob-core.el (org-babel-check-evaluate): New defsubst that checks
  if the evaluation of a code block is disabled.  Refactors the first
  part of the original function `org-babel-confirm-evaluate´.
* lisp/ob-core.el (org-babel-confirm-evaluate): New defsubst that
  checks if the user should be queried and returns the answer.  Keeps
  the second part of the original function `org-babel-confirm-evaluate´.
* lisp/ob-core.el (org-babel-execute-src-block): Do not ask for
  confirmation if the cached result is current.
2013-03-09 21:33:19 +01:00
Achim Gratz 5fe486807e ob-core: reimplement org-babel-confirm-evaluate
* lisp/ob-core.el (org-babel-confirm-evaluate): Re-implement using
  bindings for common subexpressions.

There was a minor bug in the reporting of an aborted evaluation as
"disabled" when no export was happening and eval-no-export was t since
the state of the export was not checked again.
2013-03-09 21:31:01 +01:00
Eric Schulte 9dd13b2e1e fixed line over 80 chars long
* lisp/ob-core.el (org-babel-call-process-region-original): Fixed line
  over 80 chars long.
2013-03-09 21:30:35 +01:00
Achim Gratz 1ffd4f615a ob-core: do not declare and define org-babel-call-process-region-original
* lisp/ob-core.el (org-babel-call-process-region-original): Change
  declaration into definition with nil initial value at the beginning
  of the file and drop the later definition.  Add comment that the
  dynamic scoping of this variable is done for tramp.
2013-03-09 21:27:24 +01:00
Bastien Guerry 8a2e3e2a79 Add :version and :package-version
* ox.el (org-export-snippet-translation-alist)
(org-export-coding-system, org-export-in-background)
(org-export-async-init-file, org-export-invisible-backends)
(org-export-dispatch-use-expert-ui):
* ox-texinfo.el (org-texinfo-filename, org-texinfo-classes)
(org-texinfo-format-headline-function)
(org-texinfo-node-description-column)
(org-texinfo-active-timestamp-format)
(org-texinfo-link-with-unknown-path-format)
(org-texinfo-tables-verbatim)
(org-texinfo-table-scientific-notation)
(org-texinfo-text-markup-alist)
(org-texinfo-format-drawer-function)
(org-texinfo-format-inlinetask-function)
(org-texinfo-info-process):
* ox-man.el (org-man-tables-centered)
(org-man-table-scientific-notation)
(org-man-source-highlight, org-man-source-highlight-langs)
(org-man-pdf-process, org-man-logfiles-extensions):
* ox-html.el (org-html-allow-name-attribute-in-anchors)
(org-html-coding-system, org-html-divs):
* ox-ascii.el (org-ascii-text-width)
(org-ascii-headline-spacing, org-ascii-indented-line-width)
(org-ascii-paragraph-spacing, org-ascii-charset)
(org-ascii-underline, org-ascii-bullets)
(org-ascii-links-to-notes)
(org-ascii-table-keep-all-vertical-lines)
(org-ascii-table-widen-columns)
(org-ascii-table-use-ascii-art)
(org-ascii-format-drawer-function)
(org-ascii-format-inlinetask-function):
* org.el (org-modules, org-export-backends)
(org-highlight-latex-and-related, orgstruct-setup-hook):
* org-attach.el (org-attach-git-annex-cutoff):
* org-archive.el (org-archive-file-header-format):
* org-agenda.el (org-agenda-todo-ignore-time-comparison-use-seconds):
* ob-python.el (org-babel-python-hline-to)
(org-babel-python-None-to):
* ob-ditaa.el (org-ditaa-eps-jar-path):
* ob-core.el (org-babel-results-keyword): Add :version and
:package-version.

* ox-ascii.el: Use utf-8-emacs as the file coding system.
2013-03-05 16:38:33 +01:00
Bastien Guerry 2d2913ce4f ob-core.el (org-babel-load-in-session): Throw a useful error when there is no code block at point
* ob-core.el (org-babel-load-in-session): Throw a useful error
when there is no code block at point.
2013-03-02 15:28:51 +01:00
Achim Gratz 302d3780ec ob-core: add binding for merged-params to avoid multiple evaluation
* lisp/ob-core.el (org-babel-execute-src-block): Add binding for
  merged-params to avoid multiple evaluation of
  `org-babel-merge-params´.
2013-02-27 23:48:02 +01:00
Achim Gratz 0fcfafe331 ob-core: Rename cache? to cache-p, add binding for cache-current-p
* lisp/ob-core.el (org-babel-execute-src-block): Rename cache? to
  cache-p, add binding for cache-current-p and use it.
2013-02-27 23:48:02 +01:00
Achim Gratz eee580c8b3 Revert "ob-core.el: Do not ask for confirmation if cached value is current"
Reverting "Fix a typo I introduced while editing Achim's commit 091bf0"
Reverting "ob-core.el: Do not ask for confirmation if cached value is current"

This reverts commit 091bf02514.
2013-02-27 22:10:05 +01:00
Bastien Guerry bdce4dbf9b Fix a typo I introduced while editing Achim's commit 091bf0
Thanks to Achim for reporting this!
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=091bf0
2013-02-27 13:29:23 +01:00
Achim Gratz 091bf02514 ob-core.el: Do not ask for confirmation if cached value is current
* ob-core.el (org-babel-execute-src-block): Do not run
`org-babel-confirm-evaluate´ if source block has a cache and the
cache value is current (there is no evaluation involved in this
case).
2013-02-27 09:44:27 +01:00
Eric Schulte f51fd88554 Return expanded code on programmatic calls
* lisp/ob-core.el (org-babel-expand-src-block): Return value of expanded
  code block on non-interactive calls.
2013-02-24 09:50:46 -07:00
Grégoire Jadi 67febc3600 Unify `org-id-reverse-string' and `org-babel-reverse-string' into `org-reverse-string'
* lisp/org.el (org-reverse-string): Add `org-reverse-string' to
  reverse a string.
* lisp/org-id.el(org-id-new, org-id-decode): Replace
  `org-id-reverse-string' by `org-reverse-string'.
* lisp/ob-core.el(org-babel-trim): Replace `org-babel-reverse-string'
  by `org-reverse-string' and declare it.

TINYCHANGE
2013-02-13 16:29:09 +01:00
Bastien Guerry 019a8dee21 ob-core.el (org-babel-insert-result): Fix bug when inserting an empty string as the result
* ob-core.el (org-babel-insert-result): Fix bug when inserting
an empty string as the result.
2013-02-12 17:49:06 +01:00
Eric Schulte 728c0eb693 bring back org-ts-regep fix lost in merge
* lisp/ob-core.el (org-babel-result-regexp): Bring back Bastien's
  hackish fix from commit c17e07e9 which was accidentally dropped in a
  merge.
2013-02-09 16:05:44 -07:00
Gary Oberbrunner e2b17ccc52 Improvements to Org SQL support
* add a header-row delimiter to the tables returned from mysql
 * add new sql-specific header args for the database connection, and implements them for mysql
 * add support for :colnames (mysql only)
 * (minor) add an edebug spec to org-babel-result-cond to allow edebugging through it
 * add some doc about what header args are used
2013-02-09 14:11:45 -07:00
Eric Schulte f3be2ae163 Change syntax of babel time hash layout
The syntax of result hashes with times are now as show below.

  #+RESULTS[<TIME> HASH]:

* lisp/ob-core.el (org-babel-result-regexp): Simplified regexp given new
  time hash layout.
  (org-babel-current-result-hash): New match string.
  (org-babel-hide-hash): New match string.
  (org-babel-where-is-src-block-result): New match string, and inserting
  hashes in the new format.
2013-02-09 14:11:45 -07:00
Bastien Guerry b636982b00 Silent byte-compiler. 2013-02-08 17:21:54 +01:00
Bastien Guerry eac6af707c New commands `org-next-block' and `org-previous-block'
* ob-core.el (org-babel-next-src-block)
(org-babel-previous-src-block): Rewrite using
`org-next-block'.

* org.el (org-next-block, org-previous-block): New navigation
commands.
(org-mode-map): Bind the new commands to C-c C-F and C-c C-B
respectively.

Thanks to Bill White for suggesting this.
2013-02-08 17:11:13 +01:00
Bastien Guerry c17e07e94f ob-core.el (org-ts-regexp): Remove duplicate defconst'ing
* ob-core.el (org-ts-regexp): Remove duplicate defconst'ing.
(org-babel-result-regexp): Don't use `org-ts-regexp', use a
regexp string directly.

This is not the best solution, we should be able to use
`org-ts-regexp' here, but the dependencies makes it hard.
So let's not define org-ts-regexp twice, just use a raw
regexp instead, and add a FIXME warning about this.
2013-01-31 10:57:49 +01:00
Eric Schulte ab49324917 fix bug introduced in c1226e8
* lisp/ob-core.el (org-ts-regexp): Declare this here as well.
2013-01-30 13:53:55 -07:00
Eric Schulte c1226e80d4 option to show time stamps over result hashes
suggested by Thomas Alexander Gerds

* lisp/ob-core.el (org-babel-result-regexp): Now matching time stamp as
  well.
  (org-babel-hash-show-time): Variable controlling the display of time
  stamps.
  (org-babel-current-result-hash): With hash time stamps.
  (org-babel-hide-all-hashes): With hash time stamps.
  (org-babel-where-is-src-block-result): With hash time stamps.
2013-01-30 10:08:38 -07:00
Bastien Guerry ae7516b0e1 Sync `org-babel-temp-file' definition with maint 2012-12-23 17:47:20 +01:00
Bastien Guerry fd9b262d94 Fix more compiler warnings.
* org.el (org-clock-timestamps-up): Fix declarations.

* ob-core.el (org-split-string): Declare function.
2012-12-20 01:20:17 +01:00
Nicolas Goaziou 90de5ee463 ob-core: Fix the #+END_ directive from the :wrap param
* lisp/ob.el: Only use the :wrap argument up to the first space when creating
  the #+END_ directive.

Using an option like ":wrap SRC fundamental" was generating and end marker of
"#+END_SRC fundamental", which caused the new exporter to fail to handle to
block properly.

Patch from Michael Gauland.
2012-12-19 21:16:57 +01:00
Eric Schulte ff0081847c requiring ob now pulls in all of Babel 2012-12-12 10:48:56 -07:00
Eric Schulte 0694965865 renaming lisp/ob.el to lisp/ob-core.el 2012-12-12 10:48:56 -07:00
Renamed from lisp/ob.el (Browse further)