mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-23 10:34:17 +00:00
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes: > Eric Schulte <schulte.eric@gmail.com> wrote: > >> The attached updated patch fixes a bug in the original. >> > > Minor problem in applying: > > ,---- > | $ git apply ~/Mail/inbox/724 > | /home/nick/Mail/inbox/724:671: trailing whitespace. > | #+name: > | /home/nick/Mail/inbox/724:599: new blank line at EOF. > | + > | warning: 2 lines add whitespace errors. > `---- The attached version fixes these issues, Thanks -- Eric >From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001 From: Eric Schulte <schulte.eric@gmail.com> Date: Fri, 28 Oct 2011 10:44:21 -0600 Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE Following a round of on-list discussion many code block synonyms have been removed, moving forward the following syntax is valid. - call lines are specified with #+call: - code blocks are named with #+name: - results are named with #+name:, however results generated by a code block may still be labeled with #+results:, and tables named with #+tblname: will be considered to be named results The following function may be used to update an existing Org-mode buffer to the new syntax. (defun update-org-buffer () "Update an Org-mode buffer to the new data, code block and call line syntax." (interactive) (save-excursion (flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t) "\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*")) (update (re new) (goto-char (point-min)) (while (re-search-forward re nil t) (replace-match new nil nil nil 1)))) (let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE"))) (lob-re (to-re '("LOB"))) (case-fold-search t)) (update old-re "name") (update lob-re "call"))))) Note: If an old version of Org-mode (e.g., the one shipped with Emacs) is installed on your system many of the important variables will be pre-defined with a defvar and *will not* have their values automatically updated, these include the following. - org-babel-data-names - org-babel-result-regexp - org-babel-src-block-regexp - org-babel-src-name-regexp - org-babel-src-name-w-name-regexp It may be necessary to either remove the source code of older versions of Org-mode, or to explicitly evaluate the ob.el file. * lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated Documentation. * lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated regular expression. (org-babel-inline-lob-one-liner-regexp): Updated regular expression. * lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that looks like a data results may actually be a code block. * lisp/ob-table.el: Updated documentation. * lisp/ob.el (org-babel-src-name-regexp): Simplified regexp. (org-babel-get-src-block-info): Updated match strings. (org-babel-data-names): Simplified acceptable names. (org-babel-find-named-block): Indentation. (org-babel-find-named-result): Updated to not return a code block as a result. * lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing references to old syntactic elements. (org-additional-option-like-keywords): Removing references to old syntactic elements. * contrib/babel/library-of-babel.org: Updated to make use of the new syntax. * testing/examples/babel-dangerous.org: Updated to make use of the new syntax. * testing/examples/babel.org: Updated to make use of the new syntax. * testing/examples/ob-awk-test.org: Updated to make use of the new syntax. * testing/examples/ob-fortran-test.org: Updated to make use of the new syntax. * testing/lisp/test-ob.el: Removed two bad tests which tested the literal values of old regular expressions rather than their behavior.
This commit is contained in:
parent
b43c1c621f
commit
7e93b90f88
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
A collection of simple utility functions:
|
A collection of simple utility functions:
|
||||||
|
|
||||||
#+srcname: echo
|
#+name: echo
|
||||||
#+begin_src emacs-lisp :var input="echo'd"
|
#+begin_src emacs-lisp :var input="echo'd"
|
||||||
input
|
input
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -35,7 +35,7 @@ Read the contents of the file at =file=. The =:results vector= and
|
|||||||
=:results scalar= header arguments can be used to read the contents of
|
=:results scalar= header arguments can be used to read the contents of
|
||||||
file as either a table or a string.
|
file as either a table or a string.
|
||||||
|
|
||||||
#+srcname: read
|
#+name: read
|
||||||
#+begin_src emacs-lisp :var file="" :var format=""
|
#+begin_src emacs-lisp :var file="" :var format=""
|
||||||
(if (string= format "csv")
|
(if (string= format "csv")
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
@ -49,7 +49,7 @@ file as either a table or a string.
|
|||||||
Write =data= to a file at =file=. If =data= is a list, then write it
|
Write =data= to a file at =file=. If =data= is a list, then write it
|
||||||
as a table in traditional Org-mode table syntax.
|
as a table in traditional Org-mode table syntax.
|
||||||
|
|
||||||
#+srcname: write
|
#+name: write
|
||||||
#+begin_src emacs-lisp :var data="" :var file="" :var ext='()
|
#+begin_src emacs-lisp :var data="" :var file="" :var ext='()
|
||||||
(flet ((echo (r) (if (stringp r) r (format "%S" r))))
|
(flet ((echo (r) (if (stringp r) r (format "%S" r))))
|
||||||
(with-temp-file file
|
(with-temp-file file
|
||||||
@ -67,7 +67,7 @@ as a table in traditional Org-mode table syntax.
|
|||||||
|
|
||||||
Read local or remote file in [[http://www.json.org/][json]] format into emacs-lisp objects.
|
Read local or remote file in [[http://www.json.org/][json]] format into emacs-lisp objects.
|
||||||
|
|
||||||
#+srcname: json
|
#+name: json
|
||||||
#+begin_src emacs-lisp :var file='() :var url='()
|
#+begin_src emacs-lisp :var file='() :var url='()
|
||||||
(require 'json)
|
(require 'json)
|
||||||
(cond
|
(cond
|
||||||
@ -96,7 +96,7 @@ The =google= command seems to be throwing "Moved Temporarily" errors
|
|||||||
when trying to download textual documents, but this is working fine
|
when trying to download textual documents, but this is working fine
|
||||||
for spreadsheets.
|
for spreadsheets.
|
||||||
|
|
||||||
#+source: gdoc-read
|
#+name: gdoc-read
|
||||||
#+begin_src emacs-lisp :var title="example" :var format="csv"
|
#+begin_src emacs-lisp :var title="example" :var format="csv"
|
||||||
(let* ((file (concat title "." format))
|
(let* ((file (concat title "." format))
|
||||||
(cmd (format "google docs get --format %S --title %S" format title)))
|
(cmd (format "google docs get --format %S --title %S" format title)))
|
||||||
@ -126,7 +126,7 @@ Write =data= to a google document named =title=. If =data= is tabular
|
|||||||
it will be saved to a spreadsheet, otherwise it will be saved as a
|
it will be saved to a spreadsheet, otherwise it will be saved as a
|
||||||
normal document.
|
normal document.
|
||||||
|
|
||||||
#+source: gdoc-write
|
#+name: gdoc-write
|
||||||
#+begin_src emacs-lisp :var title="babel-upload" :var data=fibs(n=10) :results silent
|
#+begin_src emacs-lisp :var title="babel-upload" :var data=fibs(n=10) :results silent
|
||||||
(let* ((format (if (listp data) "csv" "txt"))
|
(let* ((format (if (listp data) "csv" "txt"))
|
||||||
(tmp-file (make-temp-file "org-babel-google-doc" nil (concat "." format)))
|
(tmp-file (make-temp-file "org-babel-google-doc" nil (concat "." format)))
|
||||||
@ -157,7 +157,7 @@ example usage
|
|||||||
Plot column 2 (y axis) against column 1 (x axis). Columns 3 and
|
Plot column 2 (y axis) against column 1 (x axis). Columns 3 and
|
||||||
beyond, if present, are ignored.
|
beyond, if present, are ignored.
|
||||||
|
|
||||||
#+srcname: R-plot(data=R-plot-example-data)
|
#+name: R-plot(data=R-plot-example-data)
|
||||||
#+begin_src R
|
#+begin_src R
|
||||||
plot(data)
|
plot(data)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -169,7 +169,7 @@ plot(data)
|
|||||||
| 4 | 16 |
|
| 4 | 16 |
|
||||||
| 5 | 25 |
|
| 5 | 25 |
|
||||||
|
|
||||||
#+lob: R-plot(data=R-plot-example-data)
|
#+call: R-plot(data=R-plot-example-data)
|
||||||
|
|
||||||
#+resname: R-plot(data=R-plot-example-data)
|
#+resname: R-plot(data=R-plot-example-data)
|
||||||
: nil
|
: nil
|
||||||
@ -180,7 +180,7 @@ plot(data)
|
|||||||
|
|
||||||
** Headline references
|
** Headline references
|
||||||
|
|
||||||
#+source: headline
|
#+name: headline
|
||||||
#+begin_src emacs-lisp :var headline=top :var file='()
|
#+begin_src emacs-lisp :var headline=top :var file='()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when file (get-file-buffer file))
|
(when file (get-file-buffer file))
|
||||||
@ -217,7 +217,7 @@ optional.
|
|||||||
| env | optional environment, default to "tabular" |
|
| env | optional environment, default to "tabular" |
|
||||||
| width | optional width specification string |
|
| width | optional width specification string |
|
||||||
|
|
||||||
#+srcname: booktabs
|
#+name: booktabs
|
||||||
#+begin_src emacs-lisp :var table='((:head) hline (:body)) :var align='() :var env="tabular" :var width='() :noweb yes :results latex
|
#+begin_src emacs-lisp :var table='((:head) hline (:body)) :var align='() :var env="tabular" :var width='() :noweb yes :results latex
|
||||||
(flet ((to-tab (tab)
|
(flet ((to-tab (tab)
|
||||||
(orgtbl-to-generic
|
(orgtbl-to-generic
|
||||||
@ -266,7 +266,7 @@ are optional.
|
|||||||
| foot | optional "foot" string |
|
| foot | optional "foot" string |
|
||||||
| lastfoot | optional "lastfoot" string |
|
| lastfoot | optional "lastfoot" string |
|
||||||
|
|
||||||
#+srcname: longtable
|
#+name: longtable
|
||||||
#+begin_src emacs-lisp :var table='((:table)) :var align='() :var width='() :var hline="\\hline" :var firsthead='() :var head='() :var foot='() :var lastfoot='() :noweb yes :results latex
|
#+begin_src emacs-lisp :var table='((:table)) :var align='() :var width='() :var hline="\\hline" :var firsthead='() :var head='() :var foot='() :var lastfoot='() :noweb yes :results latex
|
||||||
(org-fill-template
|
(org-fill-template
|
||||||
"
|
"
|
||||||
@ -314,7 +314,7 @@ span. Note the use of LaTeX, rather than Org-mode, markup.
|
|||||||
#+tblname: arguments-notes
|
#+tblname: arguments-notes
|
||||||
| \multicolumn{2}{l}{This is a footnote to the \emph{arguments} table.} |
|
| \multicolumn{2}{l}{This is a footnote to the \emph{arguments} table.} |
|
||||||
|
|
||||||
#+srcname: booktabs-notes
|
#+name: booktabs-notes
|
||||||
#+begin_src emacs-lisp :var table='((:head) hline (:body)) :var notes='() :var align='() :var env="tabular" :var width='() :var lspace='() :noweb yes :results latex
|
#+begin_src emacs-lisp :var table='((:head) hline (:body)) :var notes='() :var align='() :var env="tabular" :var width='() :var lspace='() :noweb yes :results latex
|
||||||
(flet ((to-tab (tab)
|
(flet ((to-tab (tab)
|
||||||
(orgtbl-to-generic
|
(orgtbl-to-generic
|
||||||
@ -356,7 +356,7 @@ span. Note the use of LaTeX, rather than Org-mode, markup.
|
|||||||
| 1 | 2 | 3 |
|
| 1 | 2 | 3 |
|
||||||
| 4 | 5 | 6 |
|
| 4 | 5 | 6 |
|
||||||
|
|
||||||
#+srcname: transpose
|
#+name: transpose
|
||||||
#+begin_src emacs-lisp :var table=transpose-example
|
#+begin_src emacs-lisp :var table=transpose-example
|
||||||
(apply #'mapcar* #'list table)
|
(apply #'mapcar* #'list table)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -372,7 +372,7 @@ span. Note the use of LaTeX, rather than Org-mode, markup.
|
|||||||
| 1 | 2 | 3 |
|
| 1 | 2 | 3 |
|
||||||
| a | b | c |
|
| a | b | c |
|
||||||
|
|
||||||
#+source: all-to-string
|
#+name: all-to-string
|
||||||
#+begin_src emacs-lisp :var tbl='()
|
#+begin_src emacs-lisp :var tbl='()
|
||||||
(defun all-to-string (tbl)
|
(defun all-to-string (tbl)
|
||||||
(if (listp tbl)
|
(if (listp tbl)
|
||||||
@ -387,7 +387,7 @@ span. Note the use of LaTeX, rather than Org-mode, markup.
|
|||||||
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
|
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
| nil | nil | nil |
|
| nil | nil | nil |
|
||||||
| t | t | t |
|
| t | t | t |
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ span. Note the use of LaTeX, rather than Org-mode, markup.
|
|||||||
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
|
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
| t | t | t |
|
| t | t | t |
|
||||||
| t | t | t |
|
| t | t | t |
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ export. The function uses the Emacs VC commands to interface to the
|
|||||||
local version control system, but has only been tested to work with
|
local version control system, but has only been tested to work with
|
||||||
Git. 'limit' is currently unsupported.
|
Git. 'limit' is currently unsupported.
|
||||||
|
|
||||||
#+source: vc-log
|
#+name: vc-log
|
||||||
#+headers: :var limit=-1
|
#+headers: :var limit=-1
|
||||||
#+headers: :var buf=(buffer-name (current-buffer))
|
#+headers: :var buf=(buffer-name (current-buffer))
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -440,34 +440,34 @@ Git. 'limit' is currently unsupported.
|
|||||||
|
|
||||||
** Trivial python code blocks
|
** Trivial python code blocks
|
||||||
|
|
||||||
#+srcname: python-identity(a=1)
|
#+name: python-identity(a=1)
|
||||||
#+begin_src python
|
#+begin_src python
|
||||||
a
|
a
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+srcname: python-add(a=1, b=2)
|
#+name: python-add(a=1, b=2)
|
||||||
#+begin_src python
|
#+begin_src python
|
||||||
a + b
|
a + b
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Arithmetic
|
** Arithmetic
|
||||||
|
|
||||||
#+source: lob-add
|
#+name: lob-add
|
||||||
#+begin_src emacs-lisp :var a=0 :var b=0
|
#+begin_src emacs-lisp :var a=0 :var b=0
|
||||||
(+ a b)
|
(+ a b)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+source: lob-minus
|
#+name: lob-minus
|
||||||
#+begin_src emacs-lisp :var a=0 :var b=0
|
#+begin_src emacs-lisp :var a=0 :var b=0
|
||||||
(- a b)
|
(- a b)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+source: lob-times
|
#+name: lob-times
|
||||||
#+begin_src emacs-lisp :var a=0 :var b=0
|
#+begin_src emacs-lisp :var a=0 :var b=0
|
||||||
(* a b)
|
(* a b)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+source: lob-div
|
#+name: lob-div
|
||||||
#+begin_src emacs-lisp :var a=0 :var b=0
|
#+begin_src emacs-lisp :var a=0 :var b=0
|
||||||
(/ a b)
|
(/ a b)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -477,7 +477,7 @@ a + b
|
|||||||
The =elispgantt= source block was sent to the mailing list by Eric
|
The =elispgantt= source block was sent to the mailing list by Eric
|
||||||
Fraga. It was modified slightly by Tom Dye.
|
Fraga. It was modified slightly by Tom Dye.
|
||||||
|
|
||||||
#+source: elispgantt
|
#+name: elispgantt
|
||||||
#+begin_src emacs-lisp :var table=gantttest
|
#+begin_src emacs-lisp :var table=gantttest
|
||||||
(let ((dates "")
|
(let ((dates "")
|
||||||
(entries (nthcdr 2 table))
|
(entries (nthcdr 2 table))
|
||||||
|
@ -147,7 +147,7 @@ options and are taken from `org-babel-default-inline-header-args'."
|
|||||||
(forward-char 2)))))))))
|
(forward-char 2)))))))))
|
||||||
|
|
||||||
(defun org-exp-res/src-name-cleanup ()
|
(defun org-exp-res/src-name-cleanup ()
|
||||||
"Clean up #+results and #+srcname lines for export.
|
"Clean up #+results and #+name lines for export.
|
||||||
This function should only be called after all block processing
|
This function should only be called after all block processing
|
||||||
has taken place."
|
has taken place."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -61,24 +61,15 @@ To add files to this list use the `org-babel-lob-ingest' command."
|
|||||||
lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
|
lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
|
||||||
lob-ingest-count))
|
lob-ingest-count))
|
||||||
|
|
||||||
(defconst org-babel-lob-call-aliases '("lob" "call")
|
|
||||||
"Aliases to call a source block function.
|
|
||||||
If you change the value of this variable then your files may
|
|
||||||
become unusable by other org-babel users, and vice versa.")
|
|
||||||
|
|
||||||
(defconst org-babel-block-lob-one-liner-regexp
|
(defconst org-babel-block-lob-one-liner-regexp
|
||||||
(concat
|
(concat
|
||||||
"^\\([ \t]*\\)#\\+\\(?:"
|
"^\\([ \t]*\\)#\\+call:[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
|
||||||
(mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
|
|
||||||
"\\):[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
|
|
||||||
"\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
|
"\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
|
||||||
"Regexp to match non-inline calls to predefined source block functions.")
|
"Regexp to match non-inline calls to predefined source block functions.")
|
||||||
|
|
||||||
(defconst org-babel-inline-lob-one-liner-regexp
|
(defconst org-babel-inline-lob-one-liner-regexp
|
||||||
(concat
|
(concat
|
||||||
"\\([^\n]*\\)\\(?:"
|
"\\([^\n]*\\)call_\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
|
||||||
(mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
|
|
||||||
"\\)_\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
|
|
||||||
"\(\\([^\n]*\\)\)\\(\\[\\(.*?\\)\\]\\)?")
|
"\(\\([^\n]*\\)\)\\(\\[\\(.*?\\)\\]\\)?")
|
||||||
"Regexp to match inline calls to predefined source block functions.")
|
"Regexp to match inline calls to predefined source block functions.")
|
||||||
|
|
||||||
|
@ -173,6 +173,11 @@ the variable."
|
|||||||
(cond
|
(cond
|
||||||
(lob-info (setq type 'lob))
|
(lob-info (setq type 'lob))
|
||||||
(id (setq type 'id))
|
(id (setq type 'id))
|
||||||
|
((and (looking-at org-babel-src-name-regexp)
|
||||||
|
(progn (forward-line 1)
|
||||||
|
(or (looking-at org-babel-src-block-regexp)
|
||||||
|
(looking-at org-babel-multi-line-header-regexp))))
|
||||||
|
(setq type 'source-block))
|
||||||
(t (while (not (setq type (org-babel-ref-at-ref-p)))
|
(t (while (not (setq type (org-babel-ref-at-ref-p)))
|
||||||
(forward-line 1)
|
(forward-line 1)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
;; (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
|
;; (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
|
||||||
;; #+end_src
|
;; #+end_src
|
||||||
|
|
||||||
;; #+srcname: fibbd
|
;; #+name: fibbd
|
||||||
;; #+begin_src emacs-lisp :var n=2 :results silent
|
;; #+begin_src emacs-lisp :var n=2 :results silent
|
||||||
;; (fibbd n)
|
;; (fibbd n)
|
||||||
;; #+end_src
|
;; #+end_src
|
||||||
|
31
lisp/ob.el
31
lisp/ob.el
@ -114,7 +114,7 @@ remove code block execution from the C-c C-c keybinding."
|
|||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defvar org-babel-src-name-regexp
|
(defvar org-babel-src-name-regexp
|
||||||
"^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*"
|
"^[ \t]*#\\+name:[ \t]*"
|
||||||
"Regular expression used to match a source name line.")
|
"Regular expression used to match a source name line.")
|
||||||
|
|
||||||
(defvar org-babel-multi-line-header-regexp
|
(defvar org-babel-multi-line-header-regexp
|
||||||
@ -217,8 +217,8 @@ Returns a list
|
|||||||
(nth 2 info)
|
(nth 2 info)
|
||||||
(org-babel-parse-header-arguments (match-string 1)))))
|
(org-babel-parse-header-arguments (match-string 1)))))
|
||||||
(when (looking-at org-babel-src-name-w-name-regexp)
|
(when (looking-at org-babel-src-name-w-name-regexp)
|
||||||
(setq name (org-babel-clean-text-properties (match-string 4)))
|
(setq name (org-babel-clean-text-properties (match-string 3)))
|
||||||
(when (match-string 6)
|
(when (match-string 5)
|
||||||
(setf (nth 2 info) ;; merge functional-syntax vars and header-args
|
(setf (nth 2 info) ;; merge functional-syntax vars and header-args
|
||||||
(org-babel-merge-params
|
(org-babel-merge-params
|
||||||
(mapcar
|
(mapcar
|
||||||
@ -230,7 +230,7 @@ Returns a list
|
|||||||
(error
|
(error
|
||||||
"variable \"%s\"%s must be assigned a default value"
|
"variable \"%s\"%s must be assigned a default value"
|
||||||
var (if name (format " in block \"%s\"" name) ""))))
|
var (if name (format " in block \"%s\"" name) ""))))
|
||||||
(org-babel-ref-split-args (match-string 6))))
|
(org-babel-ref-split-args (match-string 5))))
|
||||||
(nth 2 info))))))
|
(nth 2 info))))))
|
||||||
;; inline source block
|
;; inline source block
|
||||||
(when (org-babel-get-inline-src-block-matches)
|
(when (org-babel-get-inline-src-block-matches)
|
||||||
@ -397,7 +397,7 @@ specific header arguments as well.")
|
|||||||
'((:session . "none") (:results . "replace") (:exports . "results"))
|
'((:session . "none") (:results . "replace") (:exports . "results"))
|
||||||
"Default arguments to use when evaluating an inline source block.")
|
"Default arguments to use when evaluating an inline source block.")
|
||||||
|
|
||||||
(defvar org-babel-data-names '("TBLNAME" "RESNAME" "RESULTS" "DATA"))
|
(defvar org-babel-data-names '("TBLNAME" "RESULTS" "NAME"))
|
||||||
|
|
||||||
(defvar org-babel-result-regexp
|
(defvar org-babel-result-regexp
|
||||||
(concat "^[ \t]*#\\+"
|
(concat "^[ \t]*#\\+"
|
||||||
@ -1367,7 +1367,7 @@ org-babel-named-src-block-regexp."
|
|||||||
(regexp (org-babel-named-src-block-regexp-for-name name)) msg)
|
(regexp (org-babel-named-src-block-regexp-for-name name)) msg)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(when (or (re-search-forward regexp nil t)
|
(when (or (re-search-forward regexp nil t)
|
||||||
(re-search-backward regexp nil t))
|
(re-search-backward regexp nil t))
|
||||||
(match-beginning 0)))))
|
(match-beginning 0)))))
|
||||||
|
|
||||||
(defun org-babel-src-block-names (&optional file)
|
(defun org-babel-src-block-names (&optional file)
|
||||||
@ -1376,7 +1376,7 @@ org-babel-named-src-block-regexp."
|
|||||||
(when file (find-file file)) (goto-char (point-min))
|
(when file (find-file file)) (goto-char (point-min))
|
||||||
(let (names)
|
(let (names)
|
||||||
(while (re-search-forward org-babel-src-name-w-name-regexp nil t)
|
(while (re-search-forward org-babel-src-name-w-name-regexp nil t)
|
||||||
(setq names (cons (match-string 4) names)))
|
(setq names (cons (match-string 3) names)))
|
||||||
names)))
|
names)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@ -1392,16 +1392,21 @@ org-babel-named-src-block-regexp."
|
|||||||
(progn (goto-char point) (org-show-context))
|
(progn (goto-char point) (org-show-context))
|
||||||
(message "result '%s' not found in this buffer" name))))
|
(message "result '%s' not found in this buffer" name))))
|
||||||
|
|
||||||
(defun org-babel-find-named-result (name)
|
(defun org-babel-find-named-result (name &optional point)
|
||||||
"Find a named result.
|
"Find a named result.
|
||||||
Return the location of the result named NAME in the current
|
Return the location of the result named NAME in the current
|
||||||
buffer or nil if no such result exists."
|
buffer or nil if no such result exists."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (or point (point-min)))
|
||||||
(when (re-search-forward
|
(catch 'is-a-code-block
|
||||||
(concat org-babel-result-regexp
|
(when (re-search-forward
|
||||||
"[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
|
(concat org-babel-result-regexp
|
||||||
(beginning-of-line 0) (point))))
|
"[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
|
||||||
|
(when (and (string= "name" (match-string 1))
|
||||||
|
(or (looking-at org-babel-src-block-regexp)
|
||||||
|
(looking-at org-babel-multi-line-header-regexp)))
|
||||||
|
(throw 'is-a-code-block (org-babel-find-named-result name (point))))
|
||||||
|
(beginning-of-line 0) (point)))))
|
||||||
|
|
||||||
(defun org-babel-result-names (&optional file)
|
(defun org-babel-result-names (&optional file)
|
||||||
"Returns the names of results in FILE or the current buffer."
|
"Returns the names of results in FILE or the current buffer."
|
||||||
|
@ -5425,9 +5425,8 @@ will be prompted for."
|
|||||||
'(font-lock-fontified t face org-meta-line))
|
'(font-lock-fontified t face org-meta-line))
|
||||||
t)
|
t)
|
||||||
((or (member dc1 '("begin:" "end:" "caption:" "label:"
|
((or (member dc1 '("begin:" "end:" "caption:" "label:"
|
||||||
"orgtbl:" "tblfm:" "tblname:" "result:"
|
"orgtbl:" "tblfm:" "tblname:" "results:"
|
||||||
"results:" "source:" "srcname:" "call:"
|
"call:" "header:" "headers:"))
|
||||||
"data:" "header:" "headers:"))
|
|
||||||
(and (match-end 4) (equal dc3 "attr")))
|
(and (match-end 4) (equal dc3 "attr")))
|
||||||
(add-text-properties
|
(add-text-properties
|
||||||
beg (match-end 0)
|
beg (match-end 0)
|
||||||
@ -10998,10 +10997,8 @@ This function can be used in a hook."
|
|||||||
"BEGIN_CENTER" "END_CENTER"
|
"BEGIN_CENTER" "END_CENTER"
|
||||||
"BEGIN_SRC" "END_SRC"
|
"BEGIN_SRC" "END_SRC"
|
||||||
"BEGIN_RESULT" "END_RESULT"
|
"BEGIN_RESULT" "END_RESULT"
|
||||||
"SOURCE:" "SRCNAME:" "FUNCTION:"
|
"NAME:" "RESULTS:"
|
||||||
"RESULTS:" "DATA:"
|
|
||||||
"HEADER:" "HEADERS:"
|
"HEADER:" "HEADERS:"
|
||||||
"BABEL:"
|
|
||||||
"CATEGORY:" "COLUMNS:" "PROPERTY:"
|
"CATEGORY:" "COLUMNS:" "PROPERTY:"
|
||||||
"CAPTION:" "LABEL:"
|
"CAPTION:" "LABEL:"
|
||||||
"SETUPFILE:"
|
"SETUPFILE:"
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
There is no default value assigned to =x= variable. This is not permitted
|
There is no default value assigned to =x= variable. This is not permitted
|
||||||
anymore.
|
anymore.
|
||||||
|
|
||||||
#+source: carre(x)
|
#+name: carre(x)
|
||||||
#+begin_src python
|
#+begin_src python
|
||||||
return x*x
|
return x*x
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
#+name: carre
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
:ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
|
:ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: noweb-example
|
#+name: noweb-example
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(message "expanded")
|
(message "expanded")
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -39,7 +39,7 @@
|
|||||||
prop
|
prop
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
: 4
|
: 4
|
||||||
|
|
||||||
* excessive id links on tangling
|
* excessive id links on tangling
|
||||||
@ -64,7 +64,7 @@
|
|||||||
:ID: f68821bc-7f49-4389-85b5-914791ee3718
|
:ID: f68821bc-7f49-4389-85b5-914791ee3718
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: four
|
#+name: four
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(list 1 2 3 4)
|
(list 1 2 3 4)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -73,7 +73,7 @@
|
|||||||
(length four)
|
(length four)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
: 4
|
: 4
|
||||||
|
|
||||||
* multi-line header arguments
|
* multi-line header arguments
|
||||||
@ -86,7 +86,7 @@
|
|||||||
(map 'list #'list numbers letters)
|
(map 'list #'list numbers letters)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
| 1 | a |
|
| 1 | a |
|
||||||
| 2 | b |
|
| 2 | b |
|
||||||
| 3 | c |
|
| 3 | c |
|
||||||
@ -100,15 +100,15 @@
|
|||||||
:ID: 0d82b52d-1bb9-4916-816b-2c67c8108dbb
|
:ID: 0d82b52d-1bb9-4916-816b-2c67c8108dbb
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: i-have-a-name
|
#+name: i-have-a-name
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
42
|
42
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
: 42
|
: 42
|
||||||
|
|
||||||
#+results: i-have-a-name
|
#+name: i-have-a-name
|
||||||
: 42
|
: 42
|
||||||
|
|
||||||
* Pascal's Triangle -- export test
|
* Pascal's Triangle -- export test
|
||||||
@ -116,7 +116,7 @@
|
|||||||
:ID: 92518f2a-a46a-4205-a3ab-bcce1008a4bb
|
:ID: 92518f2a-a46a-4205-a3ab-bcce1008a4bb
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: pascals-triangle
|
#+name: pascals-triangle
|
||||||
#+begin_src emacs-lisp :var n=5 :exports both
|
#+begin_src emacs-lisp :var n=5 :exports both
|
||||||
(defun pascals-triangle (n)
|
(defun pascals-triangle (n)
|
||||||
(if (= n 0)
|
(if (= n 0)
|
||||||
@ -136,7 +136,7 @@
|
|||||||
:ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
|
:ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: take-sqrt
|
#+name: take-sqrt
|
||||||
#+begin_src emacs-lisp :var n=9
|
#+begin_src emacs-lisp :var n=9
|
||||||
(sqrt n)
|
(sqrt n)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -159,7 +159,7 @@ This is an inline call call_echo(input="testing")[:results vector] embedded in p
|
|||||||
call_echo("testing")
|
call_echo("testing")
|
||||||
call_concat(1,2,3)
|
call_concat(1,2,3)
|
||||||
|
|
||||||
#+source: concat
|
#+name: concat
|
||||||
#+begin_src emacs-lisp :var a=0 :var b=0 :var c=0
|
#+begin_src emacs-lisp :var a=0 :var b=0 :var c=0
|
||||||
(format "%S%S%S" a b c)
|
(format "%S%S%S" a b c)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -169,7 +169,7 @@ call_concat(1,2,3)
|
|||||||
:ID: 72ddeed3-2d17-4c7f-8192-a575d535d3fc
|
:ID: 72ddeed3-2d17-4c7f-8192-a575d535d3fc
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+source: double
|
#+name: double
|
||||||
#+begin_src emacs-lisp :var it=0
|
#+begin_src emacs-lisp :var it=0
|
||||||
(* 2 it)
|
(* 2 it)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -214,7 +214,7 @@ src_sh{echo 3} Here is one at the beginning of a line.
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 5daa4d03-e3ea-46b7-b093-62c1b7632df3
|
:ID: 5daa4d03-e3ea-46b7-b093-62c1b7632df3
|
||||||
:END:
|
:END:
|
||||||
#+results: a-list
|
#+name: a-list
|
||||||
- a
|
- a
|
||||||
- b
|
- b
|
||||||
- c
|
- c
|
||||||
@ -298,13 +298,13 @@ src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
|
|||||||
echo "[[file:./cv.cls]]"
|
echo "[[file:./cv.cls]]"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
: [[file:./cv.cls]]
|
: [[file:./cv.cls]]
|
||||||
|
|
||||||
#+begin_src sh :results raw scalar
|
#+begin_src sh :results raw scalar
|
||||||
echo "[[file:./cv.cls]]"
|
echo "[[file:./cv.cls]]"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+results:
|
#+name:
|
||||||
[[file:./cv.cls]]
|
[[file:./cv.cls]]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Use a code block ouput as an input
|
|||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Use input file
|
Use input file
|
||||||
#+srcname: genfile
|
#+name: genfile
|
||||||
#+begin_src awk :in-file ob-awk-test.in :results silent
|
#+begin_src awk :in-file ob-awk-test.in :results silent
|
||||||
$0~/[\t]*#/{
|
$0~/[\t]*#/{
|
||||||
# skip comments
|
# skip comments
|
||||||
@ -33,7 +33,7 @@ Use input file
|
|||||||
|
|
||||||
* Input data generators
|
* Input data generators
|
||||||
A code block to generate input stream
|
A code block to generate input stream
|
||||||
#+srcname: genseq
|
#+name: genseq
|
||||||
#+begin_src emacs-lisp :results silent
|
#+begin_src emacs-lisp :results silent
|
||||||
(print "1")
|
(print "1")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 459384e8-1797-4f11-867e-dde0473ea7cc
|
:ID: 459384e8-1797-4f11-867e-dde0473ea7cc
|
||||||
:END:
|
:END:
|
||||||
#+source: hello
|
#+name: hello
|
||||||
#+begin_src fortran :results silent
|
#+begin_src fortran :results silent
|
||||||
print *, 'Hello world'
|
print *, 'Hello world'
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+source: fortran_parameter
|
#+name: fortran_parameter
|
||||||
#+begin_src fortran :results silent
|
#+begin_src fortran :results silent
|
||||||
integer, parameter :: i = 10
|
integer, parameter :: i = 10
|
||||||
write (*, '(i2)') i
|
write (*, '(i2)') i
|
||||||
|
@ -13,36 +13,6 @@
|
|||||||
(require 'org-test)
|
(require 'org-test)
|
||||||
(require 'org-test-ob-consts))
|
(require 'org-test-ob-consts))
|
||||||
|
|
||||||
(ert-deftest test-org-babel/src-name-regexp ()
|
|
||||||
(should(equal "^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*"
|
|
||||||
org-babel-src-name-regexp))
|
|
||||||
(mapcar (lambda (name)
|
|
||||||
(should (org-test-string-exact-match
|
|
||||||
org-babel-src-name-regexp
|
|
||||||
(concat
|
|
||||||
" \t #+"
|
|
||||||
name
|
|
||||||
": \t src-name \t blah blah blah ")))
|
|
||||||
(should (string-match
|
|
||||||
org-babel-src-name-regexp
|
|
||||||
(concat
|
|
||||||
"#+" (upcase name)
|
|
||||||
": src-name")))
|
|
||||||
;;TODO This should fail no?
|
|
||||||
(should (org-test-string-exact-match
|
|
||||||
org-babel-src-name-regexp
|
|
||||||
(concat
|
|
||||||
"#+" name ":")))
|
|
||||||
;;TODO Check - should this pass?
|
|
||||||
(should (not (org-test-string-exact-match
|
|
||||||
org-babel-src-name-regexp
|
|
||||||
(concat
|
|
||||||
"#+" name " : src-name")))))
|
|
||||||
'("srcname" "source" "function"))
|
|
||||||
(should (not (org-test-string-exact-match
|
|
||||||
org-babel-src-name-regexp
|
|
||||||
"#+invalid-name: src-name"))))
|
|
||||||
|
|
||||||
(ert-deftest test-org-babel/multi-line-header-regexp ()
|
(ert-deftest test-org-babel/multi-line-header-regexp ()
|
||||||
(should(equal "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
|
(should(equal "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
|
||||||
org-babel-multi-line-header-regexp))
|
org-babel-multi-line-header-regexp))
|
||||||
@ -63,18 +33,6 @@
|
|||||||
org-babel-multi-line-header-regexp
|
org-babel-multi-line-header-regexp
|
||||||
" \t #+headers : blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))))
|
" \t #+headers : blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))))
|
||||||
|
|
||||||
(ert-deftest test-org-babel/src-name-w-name-regexp ()
|
|
||||||
(should(equal
|
|
||||||
(concat org-babel-src-name-regexp "\\("
|
|
||||||
org-babel-multi-line-header-regexp "\\)*"
|
|
||||||
"\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)")
|
|
||||||
org-babel-src-name-w-name-regexp))
|
|
||||||
(should (org-test-string-exact-match
|
|
||||||
org-babel-src-name-w-name-regexp
|
|
||||||
(concat
|
|
||||||
"#+srcname: src-name "
|
|
||||||
"#+headers: blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))))
|
|
||||||
|
|
||||||
(ert-deftest test-org-babel/src-block-regexp ()
|
(ert-deftest test-org-babel/src-block-regexp ()
|
||||||
(let ((test-block
|
(let ((test-block
|
||||||
(concat
|
(concat
|
||||||
|
Loading…
Reference in New Issue
Block a user