* [babel] Property engine can't be set globally
@ 2011-10-26 10:33 Sebastien Vauban
2011-10-26 12:22 ` Eric Schulte
0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Vauban @ 2011-10-26 10:33 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
#+SEQ_TODO: DOESN'T_WORK | WORKS
#+PROPERTY: eval never
#+PROPERTY: engine msosql
#+PROPERTY: cmdline -S <SERVER> -U <UESR> -P <PASS> -d <DB> -n -w 700
#+PROPERTY: results value
* Overview
Some properties, either set at file level or at tree level, still remain
_invisible_ (unset) to code blocks.
This is at least the case with the =engine= property.
* Test suite
The first 2 cases end in an error:
let: Wrong type argument: stringp, nil
(See [[id:cada6588-de8a-4225-86cf-9ef840e09aa1][Backtrace]])
The 3^rd one succeeds.
** DOESN'T_WORK Buffer-wide properties
#+begin_src sql :eval yes
select getdate()
go
#+end_src
Property engine is unknown.
** DOESN'T_WORK Properties in subtree
:PROPERTIES:
:engine: msosql
:END:
#+begin_src sql :eval yes
select getdate()
go
#+end_src
Property engine is still unknown...
** WORKS Properties at block level
#+begin_src sql :eval yes :engine msosql
select getdate()
go
#+end_src
#+results:
| |
|-------------------------|
| 2011-10-26 12:25:11.347 |
| |
| (1 ligne affectF) |
* Backtrace
:PROPERTIES:
:ID: cada6588-de8a-4225-86cf-9ef840e09aa1
:END:
#+begin_src text
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
intern(nil)
(let ((--cl-var-- (intern engine))) (cond ((member* --cl-var-- (quote (quote msosql))) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((member* --cl-var-- (quote (quote mysql))) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((member* --cl-var-- (quote (quote postgresql))) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine))))
(case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote mysql) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine)))
(let* ((result-params (cdr (assoc :result-params params))) (cmdline (cdr (assoc :cmdline params))) (engine (cdr (assoc :engine params))) (in-file (org-babel-temp-file "sql-in-")) (out-file (or (cdr (assoc :out-file params)) (org-babel-temp-file "sql-out-"))) (header-delim "") (command (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote mysql) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine))))) (with-temp-file in-file (insert (org-babel-expand-body:sql body params))) (message command) (shell-command command) (if (or (member "scalar" result-params) (member "verbatim" result-params) (member "html" result-params) (member "code" result-params) (equal (point-min) (point-max))) (with-temp-buffer (progn (insert-file-contents-literally out-file) (buffer-string))) (with-temp-buffer (with-temp-buffer (insert-file-contents out-file) (goto-char (point-min)) (when (re-search-forward "^\\(-+\\)[^-]" nil t) (setq header-delim (match-string-no-properties 1))) (goto-char (point-max)) (forward-char -1) (while (looking-at "\n") (delete-char 1) (goto-char (point-max)) (forward-char -1)) (write-file out-file)) (org-table-import out-file (quote (16))) (org-babel-reassemble-table (mapcar (lambda (x) (if (string= ... header-delim) (quote hline) x)) (org-table-to-lisp)) (org-babel-pick-name (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) (org-babel-pick-name (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
org-babel-execute:sql("select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
funcall(org-babel-execute:sql "select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params))
(setq result ((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params)))
(if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq (cdr ...) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr (assoc :sep ...)))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)
(progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
(unwind-protect (progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f) (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ... ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result ...)))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--) (fmakunbound (quote call-process-region))))
(let* ((--cl-letf-bound-- (fboundp (quote call-process-region))) (--cl-letf-save-- (and --cl-letf-bound-- (symbol-function (quote call-process-region))))) (unwind-protect (progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply ... args))))) (flet ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--) (fmakunbound (quote call-process-region)))))
(letf (((symbol-function (quote call-process-region)) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
(letf* (((symbol-function (quote call-process-region)) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
(flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
(unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ... ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result ...)))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))
(let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb (cdr ...))) (if (and noweb (or ... ...)) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))
(progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb ...)) (if (and noweb ...) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))))
(if (org-babel-confirm-evaluate info) (progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...) (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (message ...) result) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))))
(when (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb ...)) (if (and noweb ...) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))))
(let ((info (or info (org-babel-get-src-block-info)))) (when (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...) (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (message ...) result) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))))
org-babel-execute-src-block(nil ("sql" "select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")) "" nil 0))
(progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t)
(if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil)
(let ((info (org-babel-get-src-block-info))) (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil))
org-babel-execute-src-block-maybe()
(or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe))
org-babel-execute-maybe()
call-interactively(org-babel-execute-maybe)
#+end_src
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [babel] Property engine can't be set globally
2011-10-26 10:33 [babel] Property engine can't be set globally Sebastien Vauban
@ 2011-10-26 12:22 ` Eric Schulte
2011-10-26 12:41 ` Sebastien Vauban
0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2011-10-26 12:22 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Hi Seb,
This is because engine is a ob-sql specific header argument. Language
specific files a supposed to declare the names of their header arguments
so that they may be inherited through variables with names like
`org-babel-header-arg-names:sql'. I've just added such a variable to
ob-sql with "engine" and "out-file" keywords, so this problem should now
be fixed.
Thanks -- Eric
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
> #+SEQ_TODO: DOESN'T_WORK | WORKS
> #+PROPERTY: eval never
> #+PROPERTY: engine msosql
> #+PROPERTY: cmdline -S <SERVER> -U <UESR> -P <PASS> -d <DB> -n -w 700
> #+PROPERTY: results value
>
> * Overview
>
> Some properties, either set at file level or at tree level, still remain
> _invisible_ (unset) to code blocks.
>
> This is at least the case with the =engine= property.
>
> * Test suite
>
> The first 2 cases end in an error:
>
> let: Wrong type argument: stringp, nil
> (See [[id:cada6588-de8a-4225-86cf-9ef840e09aa1][Backtrace]])
>
> The 3^rd one succeeds.
>
> ** DOESN'T_WORK Buffer-wide properties
>
> #+begin_src sql :eval yes
> select getdate()
> go
> #+end_src
>
> Property engine is unknown.
>
> ** DOESN'T_WORK Properties in subtree
> :PROPERTIES:
> :engine: msosql
> :END:
>
> #+begin_src sql :eval yes
> select getdate()
> go
> #+end_src
>
> Property engine is still unknown...
>
> ** WORKS Properties at block level
>
> #+begin_src sql :eval yes :engine msosql
> select getdate()
> go
> #+end_src
>
> #+results:
> | |
> |-------------------------|
> | 2011-10-26 12:25:11.347 |
> | |
> | (1 ligne affectF) |
>
> * Backtrace
> :PROPERTIES:
> :ID: cada6588-de8a-4225-86cf-9ef840e09aa1
> :END:
>
> #+begin_src text
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> intern(nil)
> (let ((--cl-var-- (intern engine))) (cond ((member* --cl-var-- (quote (quote msosql))) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((member* --cl-var-- (quote (quote mysql))) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((member* --cl-var-- (quote (quote postgresql))) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine))))
> (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote mysql) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine)))
> (let* ((result-params (cdr (assoc :result-params params))) (cmdline (cdr (assoc :cmdline params))) (engine (cdr (assoc :engine params))) (in-file (org-babel-temp-file "sql-in-")) (out-file (or (cdr (assoc :out-file params)) (org-babel-temp-file "sql-out-"))) (header-delim "") (command (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote mysql) (format "mysql %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file) (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support for the %s sql engine" engine))))) (with-temp-file in-file (insert (org-babel-expand-body:sql body params))) (message command) (shell-command command) (if (or (member "scalar" result-params) (member "verbatim" result-params) (member "html" result-params) (member "code" result-params) (equal (point-min) (point-max))) (with-temp-buffer (progn (insert-file-contents-literally out-file) (buffer-string))) (with-temp-buffer (with-temp-buffer (insert-file-contents out-file) (goto-char (point-min)) (when (re-search-forward "^\\(-+\\)[^-]" nil t) (setq header-delim (match-string-no-properties 1))) (goto-char (point-max)) (forward-char -1) (while (looking-at "\n") (delete-char 1) (goto-char (point-max)) (forward-char -1)) (write-file out-file)) (org-table-import out-file (quote (16))) (org-babel-reassemble-table (mapcar (lambda (x) (if (string= ... header-delim) (quote hline) x)) (org-table-to-lisp)) (org-babel-pick-name (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) (org-babel-pick-name (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
> org-babel-execute:sql("select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
> funcall(org-babel-execute:sql "select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
> ((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params))
> (setq result ((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params)))
> (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq (cdr ...) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr (assoc :sep ...)))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)
> (progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
> (unwind-protect (progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f) (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ... ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result ...)))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--) (fmakunbound (quote call-process-region))))
> (let* ((--cl-letf-bound-- (fboundp (quote call-process-region))) (--cl-letf-save-- (and --cl-letf-bound-- (symbol-function (quote call-process-region))))) (unwind-protect (progn (fset (quote call-process-region) (function* (lambda (&rest args) (block call-process-region (apply ... args))))) (flet ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--) (fmakunbound (quote call-process-region)))))
> (letf (((symbol-function (quote call-process-region)) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
> (letf* (((symbol-function (quote call-process-region)) (function* (lambda (&rest args) (block call-process-region (apply (quote org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
> (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
> (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ... ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result result ...)))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))
> (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb (cdr ...))) (if (and noweb (or ... ...)) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let (...) (when ... f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr ...) (insert ...))) (setq result (cdr (assoc :file params)))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))
> (progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb ...)) (if (and noweb ...) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))))
> (if (org-babel-confirm-evaluate info) (progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...) (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (message ...) result) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))))
> (when (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb ...)) (if (and noweb ...) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f) (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original)))))
> (let ((info (or info (org-babel-get-src-block-info)))) (when (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (result-params (cdr (assoc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...) (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory dir)) default-directory)) (org-babel-call-process-region-original (if (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original (symbol-function (quote call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (message ...) result) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-process-region (quote org-babel-call-process-region-original))))))
> org-babel-execute-src-block(nil ("sql" "select getdate()\ngo" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session . "none")) "" nil 0))
> (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t)
> (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil)
> (let ((info (org-babel-get-src-block-info))) (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil))
> org-babel-execute-src-block-maybe()
> (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe))
> org-babel-execute-maybe()
> call-interactively(org-babel-execute-maybe)
> #+end_src
>
> Best regards,
> Seb
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [babel] Property engine can't be set globally
2011-10-26 12:22 ` Eric Schulte
@ 2011-10-26 12:41 ` Sebastien Vauban
0 siblings, 0 replies; 3+ messages in thread
From: Sebastien Vauban @ 2011-10-26 12:41 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
Eric Schulte wrote:
> This is because engine is a ob-sql specific header argument. Language
> specific files a supposed to declare the names of their header arguments
> so that they may be inherited through variables with names like
> `org-babel-header-arg-names:sql'. I've just added such a variable to
> ob-sql with "engine" and "out-file" keywords, so this problem should now
> be fixed.
That works like a charm. Thanks a lot,
Seb
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>
>> #+SEQ_TODO: DOESN'T_WORK | WORKS
>> #+PROPERTY: eval never
>> #+PROPERTY: engine msosql
>> #+PROPERTY: cmdline -S <SERVER> -U <UESR> -P <PASS> -d <DB> -n -w 700
>> #+PROPERTY: results value
>>
>> * Overview
>>
>> Some properties, either set at file level or at tree level, still remain
>> _invisible_ (unset) to code blocks.
>>
>> This is at least the case with the =engine= property.
>>
>> * Test suite
>>
>> The first 2 cases end in an error:
>>
>> let: Wrong type argument: stringp, nil
>> (See [[id:cada6588-de8a-4225-86cf-9ef840e09aa1][Backtrace]])
>>
>> The 3^rd one succeeds.
>>
>> ** DOESN'T_WORK Buffer-wide properties
>>
>> #+begin_src sql :eval yes
>> select getdate()
>> go
>> #+end_src
>>
>> Property engine is unknown.
>>
>> ** DOESN'T_WORK Properties in subtree
>> :PROPERTIES:
>> :engine: msosql
>> :END:
>>
>> #+begin_src sql :eval yes
>> select getdate()
>> go
>> #+end_src
>>
>> Property engine is still unknown...
>>
>> ** WORKS Properties at block level
>>
>> #+begin_src sql :eval yes :engine msosql
>> select getdate()
>> go
>> #+end_src
>>
>> #+results:
>> | |
>> |-------------------------|
>> | 2011-10-26 12:25:11.347 |
>> | |
>> | (1 ligne affectF) |
>>
>> * Backtrace
>> :PROPERTIES:
>> :ID: cada6588-de8a-4225-86cf-9ef840e09aa1
>> :END:
>>
>> #+begin_src text
>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>> intern(nil)
>> (let ((--cl-var-- (intern engine))) (cond ((member* --cl-var-- (quote (quote
> msosql))) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "")
> (org-babel-process-file-name in-file) (org-babel-process-file-name out-file)))
> ((member* --cl-var-- (quote (quote mysql))) (format "mysql %s < %s > %s" (or
> cmdline "") (org-babel-process-file-name in-file) (org-babel-process-file-name
> out-file))) ((member* --cl-var-- (quote (quote postgresql))) (format "psql -A
> -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file)
> (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support
> for the %s sql engine" engine))))
>> (case (intern engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s"
> (or cmdline "") (org-babel-process-file-name in-file)
> (org-babel-process-file-name out-file))) ((quote mysql) (format "mysql %s < %s
>> %s" (or cmdline "") (org-babel-process-file-name in-file)
> (org-babel-process-file-name out-file))) ((quote postgresql) (format "psql -A
> -P footer=off -F \" \" -f %s -o %s %s" (org-babel-process-file-name in-file)
> (org-babel-process-file-name out-file) (or cmdline ""))) (t (error "no support
> for the %s sql engine" engine)))
>> (let* ((result-params (cdr (assoc :result-params params))) (cmdline (cdr
> (assoc :cmdline params))) (engine (cdr (assoc :engine params))) (in-file
> (org-babel-temp-file "sql-in-")) (out-file (or (cdr (assoc :out-file params))
> (org-babel-temp-file "sql-out-"))) (header-delim "") (command (case (intern
> engine) ((quote msosql) (format "osql %s -s \" \" -i %s -o %s" (or cmdline "")
> (org-babel-process-file-name in-file) (org-babel-process-file-name out-file)))
> ((quote mysql) (format "mysql %s < %s > %s" (or cmdline "")
> (org-babel-process-file-name in-file) (org-babel-process-file-name out-file)))
> ((quote postgresql) (format "psql -A -P footer=off -F \" \" -f %s -o %s %s"
> (org-babel-process-file-name in-file) (org-babel-process-file-name out-file)
> (or cmdline ""))) (t (error "no support for the %s sql engine" engine)))))
> (with-temp-file in-file (insert (org-babel-expand-body:sql body params)))
> (message command) (shell-command command) (if (or (member "scalar"
> result-params) (member "verbatim" result-params) (member "html" result-params)
> (member "code" result-params) (equal (point-min) (point-max)))
> (with-temp-buffer (progn (insert-file-contents-literally out-file)
> (buffer-string))) (with-temp-buffer (with-temp-buffer (insert-file-contents
> out-file) (goto-char (point-min)) (when (re-search-forward "^\\(-+\\)[^-]" nil
> t) (setq header-delim (match-string-no-properties 1))) (goto-char (point-max))
> (forward-char -1) (while (looking-at "\n") (delete-char 1) (goto-char
> (point-max)) (forward-char -1)) (write-file out-file)) (org-table-import
> out-file (quote (16))) (org-babel-reassemble-table (mapcar (lambda (x) (if
> (string= ... header-delim) (quote hline) x)) (org-table-to-lisp))
> (org-babel-pick-name (cdr (assoc :colname-names params)) (cdr (assoc :colnames
> params))) (org-babel-pick-name (cdr (assoc :rowname-names params)) (cdr (assoc
> :rownames params)))))))
>> org-babel-execute:sql("select getdate()\ngo" ((:colname-names)
> (:rowname-names) (:result-params "value" "replace") (:result-type . value)
> (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb .
> "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval
> . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700")
> (:padnewline . "yes") (:hlines . "no") (:session . "none")))
>> funcall(org-babel-execute:sql "select getdate()\ngo" ((:colname-names)
> (:rowname-names) (:result-params "value" "replace") (:result-type . value)
> (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb .
> "no") (:tangle . "no") (:exports . "code") (:results . "value replace") (:eval
> . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d pfi-dev -n -w 700")
> (:padnewline . "yes") (:hlines . "no") (:session . "none")))
>> ((lambda (result) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (funcall cmd body params))
>> (setq result ((lambda (result) (if (and (eq (cdr (assoc :result-type
> params)) (quote value)) (or (member "vector" result-params) (member "table"
> result-params)) (not (listp result))) (list (list result)) result)) (funcall
> cmd body params)))
>> (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion
> (goto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1)
> (forward-char 1) (setq result (org-babel-read-result)) (message
> (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (message
> "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format "
> (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and (eq (cdr ...)
> (quote value)) (or (member "vector" result-params) (member "table"
> result-params)) (not (listp result))) (list (list result)) result)) (funcall
> cmd body params))) (when (cdr (assoc :file params)) (when result
> (with-temp-file (cdr (assoc :file params)) (insert (org-babel-format-result
> result (cdr (assoc :sep ...)))))) (setq result (cdr (assoc :file params))))
> (org-babel-insert-result result result-params info new-hash indent lang)
> (run-hooks (quote org-babel-after-execute-hook)) result)
>> (progn (fset (quote call-process-region) (function* (lambda (&rest args)
> (block call-process-region (apply (quote
> org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f)
> (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check
> lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error
> "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not
> ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr
> (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params))
> (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc
> :file params)))) (org-babel-insert-result result result-params info new-hash
> indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
>> (unwind-protect (progn (fset (quote call-process-region) (function* (lambda
> (&rest args) (block call-process-region (apply (quote
> org-babel-tramp-handle-call-process-region) args))))) (flet ((lang-check (f)
> (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang)
> (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for
> %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash))
> (save-excursion (goto-char (org-babel-where-is-src-block-result nil info))
> (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result))
> (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
> (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info)
> (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ...
> ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc
> :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert
> (org-babel-format-result result ...)))) (setq result (cdr (assoc :file
> params)))) (org-babel-insert-result result result-params info new-hash indent
> lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (if
> --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--)
> (fmakunbound (quote call-process-region))))
>> (let* ((--cl-letf-bound-- (fboundp (quote call-process-region)))
> (--cl-letf-save-- (and --cl-letf-bound-- (symbol-function (quote
> call-process-region))))) (unwind-protect (progn (fset (quote
> call-process-region) (function* (lambda (&rest args) (block
> call-process-region (apply ... args))))) (flet ((lang-check (f) (let (...)
> (when ... f)))) (setq cmd (or (lang-check lang) (lang-check (symbol-name ...))
> (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg)
> new-hash (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body
> params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr
> ...) (insert ...))) (setq result (cdr (assoc :file params))))
> (org-babel-insert-result result result-params info new-hash indent lang)
> (run-hooks (quote org-babel-after-execute-hook)) result)) (if
> --cl-letf-bound-- (fset (quote call-process-region) --cl-letf-save--)
> (fmakunbound (quote call-process-region)))))
>> (letf (((symbol-function (quote call-process-region)) (function* (lambda
> (&rest args) (block call-process-region (apply (quote
> org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f)
> (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check
> lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error
> "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not
> ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr
> (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params))
> (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc
> :file params)))) (org-babel-insert-result result result-params info new-hash
> indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
>> (letf* (((symbol-function (quote call-process-region)) (function* (lambda
> (&rest args) (block call-process-region (apply (quote
> org-babel-tramp-handle-call-process-region) args)))))) (flet ((lang-check (f)
> (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check
> lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error
> "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not
> ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr
> (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params))
> (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc
> :file params)))) (org-babel-insert-result result result-params info new-hash
> indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
>> (flet ((call-process-region (&rest args) (apply (quote
> org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f)
> (let ((f (intern ...))) (when (fboundp f) f)))) (setq cmd (or (lang-check
> lang) (lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error
> "No org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if (and (eq ... ...) (or ... ...) (not
> ...)) (list (list result)) result)) (funcall cmd body params))) (when (cdr
> (assoc :file params)) (when result (with-temp-file (cdr (assoc :file params))
> (insert (org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc
> :file params)))) (org-babel-insert-result result result-params info new-hash
> indent lang) (run-hooks (quote org-babel-after-execute-hook)) result))
>> (unwind-protect (flet ((call-process-region (&rest args) (apply (quote
> org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f)
> (let ((f ...)) (when (fboundp f) f)))) (setq cmd (or (lang-check lang)
> (lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for
> %s!" lang)))) (if (and (not arg) new-hash (equal new-hash old-hash))
> (save-excursion (goto-char (org-babel-where-is-src-block-result nil info))
> (end-of-line 1) (forward-char 1) (setq result (org-babel-read-result))
> (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
> (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info)
> (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (if (and ...
> ... ...) (list ...) result)) (funcall cmd body params))) (when (cdr (assoc
> :file params)) (when result (with-temp-file (cdr (assoc :file params)) (insert
> (org-babel-format-result result ...)))) (setq result (cdr (assoc :file
> params)))) (org-babel-insert-result result result-params info new-hash indent
> lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (setq
> call-process-region (quote org-babel-call-process-region-original)))
>> (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params
> (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and
> (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache
> params))))) (result-params (cdr (assoc :result-params params))) (new-hash
> (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\?
> (org-babel-current-result-hash))) (body (setf (nth 1 info) (let ((noweb (cdr
> ...))) (if (and noweb (or ... ...)) (org-babel-expand-noweb-references info)
> (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and
> dir (file-name-as-directory dir)) default-directory))
> (org-babel-call-process-region-original (if (boundp (quote
> org-babel-call-process-region-original))
> org-babel-call-process-region-original (symbol-function (quote
> call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect
> (flet ((call-process-region (&rest args) (apply (quote
> org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f)
> (let (...) (when ... f)))) (setq cmd (or (lang-check lang) (lang-check
> (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (if
> (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" (format "%S" result))) result) (message "executing %s code
> block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info))
> "")) (setq result ((lambda (result) (if ... ... result)) (funcall cmd body
> params))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr
> ...) (insert ...))) (setq result (cdr (assoc :file params))))
> (org-babel-insert-result result result-params info new-hash indent lang)
> (run-hooks (quote org-babel-after-execute-hook)) result)) (setq
> call-process-region (quote org-babel-call-process-region-original))))
>> (progn (let* ((lang (nth 0 info)) (params (if params
> (org-babel-process-params (org-babel-merge-params (nth 2 info) params)) (nth 2
> info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes"
> (cdr (assoc :cache params))))) (result-params (cdr (assoc :result-params
> params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when
> cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let
> ((noweb ...)) (if (and noweb ...) (org-babel-expand-noweb-references info)
> (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and
> dir (file-name-as-directory dir)) default-directory))
> (org-babel-call-process-region-original (if (boundp (quote
> org-babel-call-process-region-original))
> org-babel-call-process-region-original (symbol-function (quote
> call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect
> (flet ((call-process-region (&rest args) (apply (quote
> org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f)
> (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No
> org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize
> lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ...
> ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result
> (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result
> result result-params info new-hash indent lang) (run-hooks (quote
> org-babel-after-execute-hook)) result)) (setq call-process-region (quote
> org-babel-call-process-region-original)))))
>> (if (org-babel-confirm-evaluate info) (progn (let* ((lang (nth 0 info))
> (params (if params (org-babel-process-params (org-babel-merge-params ...
> params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params))
> (string= "yes" (cdr ...)))) (result-params (cdr (assoc :result-params
> params))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when
> cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...)
> (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or
> (and dir (file-name-as-directory dir)) default-directory))
> (org-babel-call-process-region-original (if (boundp (quote
> org-babel-call-process-region-original))
> org-babel-call-process-region-original (symbol-function (quote
> call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect
> (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check
> ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal
> new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1)
> (forward-char 1) (setq result ...) (message ...) result) (message "executing
> %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...))
> (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result
> result result-params info new-hash indent lang) (run-hooks (quote
> org-babel-after-execute-hook)) result)) (setq call-process-region (quote
> org-babel-call-process-region-original))))))
>> (when (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params
> (if params (org-babel-process-params (org-babel-merge-params (nth 2 info)
> params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params))
> (string= "yes" (cdr (assoc :cache params))))) (result-params (cdr (assoc
> :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash info)))
> (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf (nth 1
> info) (let ((noweb ...)) (if (and noweb ...)
> (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc
> :dir params))) (default-directory (or (and dir (file-name-as-directory dir))
> default-directory)) (org-babel-call-process-region-original (if (boundp (quote
> org-babel-call-process-region-original))
> org-babel-call-process-region-original (symbol-function (quote
> call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect
> (flet ((call-process-region (&rest args) (apply (quote
> org-babel-tramp-handle-call-process-region) args))) (flet ((lang-check (f)
> (let ... ...))) (setq cmd (or (lang-check lang) (lang-check ...) (error "No
> org-babel-execute function for %s!" lang)))) (if (and (not arg) new-hash
> (equal new-hash old-hash)) (save-excursion (goto-char
> (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char
> 1) (setq result (org-babel-read-result)) (message (replace-regexp-in-string
> "%" "%%" ...)) result) (message "executing %s code block%s..." (capitalize
> lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((lambda ...
> ...) (funcall cmd body params))) (when (cdr (assoc :file params)) (when result
> (with-temp-file ... ...)) (setq result (cdr ...))) (org-babel-insert-result
> result result-params info new-hash indent lang) (run-hooks (quote
> org-babel-after-execute-hook)) result)) (setq call-process-region (quote
> org-babel-call-process-region-original)))))
>> (let ((info (or info (org-babel-get-src-block-info)))) (when
> (org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (params (if
> params (org-babel-process-params (org-babel-merge-params ... params)) (nth 2
> info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (string= "yes"
> (cdr ...)))) (result-params (cdr (assoc :result-params params))) (new-hash
> (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\?
> (org-babel-current-result-hash))) (body (setf (nth 1 info) (let (...) (if ...
> ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir
> (file-name-as-directory dir)) default-directory))
> (org-babel-call-process-region-original (if (boundp (quote
> org-babel-call-process-region-original))
> org-babel-call-process-region-original (symbol-function (quote
> call-process-region)))) (indent (car (last info))) result cmd) (unwind-protect
> (flet ((call-process-region (&rest args) (apply ... args))) (flet ((lang-check
> ... ...)) (setq cmd (or ... ... ...))) (if (and (not arg) new-hash (equal
> new-hash old-hash)) (save-excursion (goto-char ...) (end-of-line 1)
> (forward-char 1) (setq result ...) (message ...) result) (message "executing
> %s code block%s..." (capitalize lang) (if ... ... "")) (setq result (... ...))
> (when (cdr ...) (when result ...) (setq result ...)) (org-babel-insert-result
> result result-params info new-hash indent lang) (run-hooks (quote
> org-babel-after-execute-hook)) result)) (setq call-process-region (quote
> org-babel-call-process-region-original))))))
>> org-babel-execute-src-block(nil ("sql" "select getdate()\ngo"
> ((:colname-names) (:rowname-names) (:result-params "value" "replace")
> (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no")
> (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results
> . "value replace") (:eval . "yes") (:cmdline . "-S cauchy -U sa -P LpmdlP -d
> pfi-dev -n -w 700") (:padnewline . "yes") (:hlines . "no") (:session .
> "none")) "" nil 0))
>> (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t)
>> (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil)
>> (let ((info (org-babel-get-src-block-info))) (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info) t) nil))
>> org-babel-execute-src-block-maybe()
>> (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe))
>> org-babel-execute-maybe()
>> call-interactively(org-babel-execute-maybe)
>> #+end_src
>>
>> Best regards,
>> Seb
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-26 12:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 10:33 [babel] Property engine can't be set globally Sebastien Vauban
2011-10-26 12:22 ` Eric Schulte
2011-10-26 12:41 ` Sebastien Vauban
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).