Skip to content

Commit

Permalink
org-babel: Fix usage of `org-babel-temporary-directory'
Browse files Browse the repository at this point in the history
* lisp/ob-core.el (org-babel-temp-directory): New macro, returning
suitable temporary directory.  The macro considers remote
`default-directory' and nil values of
`org-babel-temporary-directory'.
* lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars):
* lisp/ob-java.el (org-babel-execute:java):
* lisp/ob-processing.el (org-babel-processing-view-sketch): Use the
new macro.

Reported-by: Christian Köstlin <christian.koestlin@gmail.com>
  • Loading branch information
yantar92 committed Oct 9, 2022
1 parent ba8fbd0 commit f414968
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions lisp/ob-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -3273,6 +3273,15 @@ Emacs shutdown.")
,scalar-form
,@table-forms))))

(defmacro org-babel-temp-directory ()
"Return temporary directory suitable for `default-directory'."
`(if (file-remote-p default-directory)
org-babel-remote-temporary-directory
(or (and org-babel-temporary-directory
(file-exists-p org-babel-temporary-directory)
org-babel-temporary-directory)
temporary-file-directory)))

(defun org-babel-temp-file (prefix &optional suffix)
"Create a temporary file in the `org-babel-temporary-directory'.
Passes PREFIX and SUFFIX directly to `make-temp-file' with the
Expand Down
2 changes: 1 addition & 1 deletion lisp/ob-gnuplot.el
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ code."
(file-remote-p val) ;; check if val is a remote file
(file-exists-p val)) ;; call to file-exists-p is slow, maybe remove it
(let* ((local-name (concat ;; create a unique filename to avoid multiple downloads
org-babel-temporary-directory
(org-babel-temp-directory)
"/gnuplot/"
(file-remote-p val 'host)
(org-babel-local-file-name val))))
Expand Down
2 changes: 1 addition & 1 deletion lisp/ob-java.el
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ replaced in this string.")
(concat
(file-remote-p default-directory)
org-babel-remote-temporary-directory)
org-babel-temporary-directory)
(org-babel-temp-directory))
default-directory)))
;; the dir to write the source file
(packagedir (if (and (not run-from-temp) packagename)
Expand Down
2 changes: 1 addition & 1 deletion lisp/ob-processing.el
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
;; make-temp-file is repeated until no hyphen is in the
;; name; also sketch dir name must be the same as the
;; basename of the sketch file.
(let* ((temporary-file-directory org-babel-temporary-directory)
(let* ((temporary-file-directory (org-babel-temp-directory))
(sketch-dir
(let (sketch-dir-candidate)
(while
Expand Down

0 comments on commit f414968

Please sign in to comment.