mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 09:02:52 +00:00
Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode
This commit is contained in:
commit
2aaad50393
|
@ -81,16 +81,13 @@ called by `org-babel-execute-src-block'."
|
||||||
(defun org-babel-latex-body-to-tex-file (tex-file body &optional height width)
|
(defun org-babel-latex-body-to-tex-file (tex-file body &optional height width)
|
||||||
"Extracted from `org-create-formula-image' in org.el."
|
"Extracted from `org-create-formula-image' in org.el."
|
||||||
(with-temp-file tex-file
|
(with-temp-file tex-file
|
||||||
(insert org-format-latex-header
|
(insert (org-splice-latex-header
|
||||||
(if org-export-latex-packages-alist
|
org-format-latex-header
|
||||||
(concat "\n"
|
(remove-if
|
||||||
(mapconcat (lambda(p)
|
(lambda (el) (and (listp el) (string= "hyperref" (cadr el))))
|
||||||
(if (equal "" (car p))
|
org-export-latex-default-packages-alist)
|
||||||
(format "\\usepackage{%s}" (cadr p))
|
org-export-latex-packages-alist
|
||||||
(format "\\usepackage[%s]{%s}"
|
org-format-latex-header-extra)
|
||||||
(car p) (cadr p))))
|
|
||||||
org-export-latex-packages-alist "\n"))
|
|
||||||
"")
|
|
||||||
(if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
|
(if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
|
||||||
(if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
|
(if width (concat "\n" (format "\\pdfpagewidth %s" width)) "")
|
||||||
(if org-format-latex-header-extra
|
(if org-format-latex-header-extra
|
||||||
|
|
|
@ -100,9 +100,16 @@ then create. Return the initialized session."
|
||||||
(rename-buffer (if (bufferp session) (buffer-name session)
|
(rename-buffer (if (bufferp session) (buffer-name session)
|
||||||
(if (stringp session) session (buffer-name)))) (current-buffer))))))
|
(if (stringp session) session (buffer-name)))) (current-buffer))))))
|
||||||
|
|
||||||
(defvar org-babel-octave-wrapper-method
|
(defvar org-babel-octave-wrapper-method
|
||||||
"%s
|
"%s
|
||||||
save -ascii %s ans")
|
if ischar(ans)
|
||||||
|
fid = fopen('%s', 'w')
|
||||||
|
fprintf(fid, ans)
|
||||||
|
fprintf(fid, '\\n')
|
||||||
|
fclose(fid)
|
||||||
|
else
|
||||||
|
save -ascii %s ans
|
||||||
|
end")
|
||||||
|
|
||||||
(defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'")
|
(defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'")
|
||||||
|
|
||||||
|
@ -130,12 +137,12 @@ value of the last statement in BODY, as elisp."
|
||||||
(let* ((tmp-file (make-temp-file "org-babel-results-")) exit-code
|
(let* ((tmp-file (make-temp-file "org-babel-results-")) exit-code
|
||||||
(stderr
|
(stderr
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert (format org-babel-octave-wrapper-method body tmp-file))
|
(insert (format org-babel-octave-wrapper-method body tmp-file tmp-file))
|
||||||
(setq exit-code (org-babel-shell-command-on-region
|
(setq exit-code (org-babel-shell-command-on-region
|
||||||
(point-min) (point-max) cmd nil 'replace (current-buffer)))
|
(point-min) (point-max) cmd nil 'replace (current-buffer)))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
(if (> exit-code 0) (org-babel-error-notify exit-code stderr))
|
(if (> exit-code 0) (org-babel-error-notify exit-code stderr))
|
||||||
(org-babel-import-elisp-from-file (org-babel-maybe-remote-file tmp-file))))))))
|
(org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file))))))))
|
||||||
|
|
||||||
(defun org-babel-octave-evaluate-session (session body result-type &optional matlabp)
|
(defun org-babel-octave-evaluate-session (session body result-type &optional matlabp)
|
||||||
(let* ((tmp-file (make-temp-file "org-babel-results-"))
|
(let* ((tmp-file (make-temp-file "org-babel-results-"))
|
||||||
|
@ -148,13 +155,13 @@ value of the last statement in BODY, as elisp."
|
||||||
(value
|
(value
|
||||||
(mapconcat
|
(mapconcat
|
||||||
#'org-babel-chomp
|
#'org-babel-chomp
|
||||||
(list (format org-babel-octave-wrapper-method body tmp-file) org-babel-octave-eoe-indicator) "\n"))))
|
(list (format org-babel-octave-wrapper-method body tmp-file tmp-file) org-babel-octave-eoe-indicator) "\n"))))
|
||||||
(raw (org-babel-comint-with-output session
|
(raw (org-babel-comint-with-output session
|
||||||
(if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t
|
(if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t
|
||||||
(insert full-body) (comint-send-input nil t))) results)
|
(insert full-body) (comint-send-input nil t))) results)
|
||||||
(case result-type
|
(case result-type
|
||||||
(value
|
(value
|
||||||
(org-babel-import-elisp-from-file (org-babel-maybe-remote-file tmp-file)))
|
(org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file)))
|
||||||
(output
|
(output
|
||||||
(progn
|
(progn
|
||||||
(setq results
|
(setq results
|
||||||
|
@ -166,6 +173,19 @@ value of the last statement in BODY, as elisp."
|
||||||
(mapcar #'org-babel-trim raw)))))))
|
(mapcar #'org-babel-trim raw)))))))
|
||||||
(mapconcat #'identity (reverse results) "\n"))))))
|
(mapconcat #'identity (reverse results) "\n"))))))
|
||||||
|
|
||||||
|
(defun org-babel-octave-import-elisp-from-file (file-name)
|
||||||
|
"Import data written to file by octave.
|
||||||
|
This removes initial blank and comment lines and then calls
|
||||||
|
`org-babel-import-elisp-from-file'."
|
||||||
|
(let ((temp-file (make-temp-file "org-babel-results-")) beg end)
|
||||||
|
(with-temp-file temp-file
|
||||||
|
(insert-file-contents file-name)
|
||||||
|
(re-search-forward "^[ \t]*[^# \t]" nil t)
|
||||||
|
(if (< (setq beg (point-min))
|
||||||
|
(setq end (point-at-bol)))
|
||||||
|
(delete-region beg end)))
|
||||||
|
(org-babel-import-elisp-from-file temp-file)))
|
||||||
|
|
||||||
(defun org-babel-octave-read-string (string)
|
(defun org-babel-octave-read-string (string)
|
||||||
"Strip \\\"s from around octave string"
|
"Strip \\\"s from around octave string"
|
||||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||||
|
|
Loading…
Reference in a new issue