Use blocking call-process instead of non-blocking start-process
In the `ob-tmux--execute' and `ob-tmux--start-terminal-window' functions, replace the non-blocking `start-process' function with the blocking `call-process' function to ensure that the operation is completed before returning. This also allows the function to handle errors by checking the return value of `call-process'. - Use `call-process' instead of `start-process' - Check return value of `call-process' and handle errorpull/19/head
parent
4c71e77b83
commit
fb833c72bb
33
ob-tmux.el
33
ob-tmux.el
|
@ -174,17 +174,17 @@ Argument OB-SESSION: the current ob-tmux session."
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun ob-tmux--execute (ob-session &rest args)
|
||||
"Execute a tmux command with arguments as given.
|
||||
"Execute a tmux command with the given arguments.
|
||||
|
||||
Argument OB-SESSION: the current ob-tmux session.
|
||||
OB-SESSION: the current ob-tmux session.
|
||||
Optional command-line arguments can be passed in ARGS."
|
||||
(if (ob-tmux--socket ob-session)
|
||||
(apply 'start-process "ob-tmux" "*Messages*"
|
||||
org-babel-tmux-location
|
||||
"-S" (ob-tmux--socket ob-session)
|
||||
args)
|
||||
(apply 'start-process
|
||||
"ob-tmux" "*Messages*" org-babel-tmux-location args)))
|
||||
(let ((socket (ob-tmux--socket ob-session)))
|
||||
(unless (zerop (apply #'call-process org-babel-tmux-location
|
||||
nil nil nil
|
||||
(if socket
|
||||
(append `("-S" ,socket) args)
|
||||
args)))
|
||||
(error "Error executing tmux command"))))
|
||||
|
||||
(defun ob-tmux--execute-string (ob-session &rest args)
|
||||
"Execute a tmux command with arguments as given.
|
||||
|
@ -203,16 +203,13 @@ automatically space separated."
|
|||
"Start a TERMINAL window with tmux attached to session.
|
||||
|
||||
Argument OB-SESSION: the current ob-tmux session."
|
||||
(let ((start-process-mandatory-args `("org-babel: terminal"
|
||||
"*Messages*"
|
||||
,terminal))
|
||||
(tmux-cmd `(,org-babel-tmux-location
|
||||
"attach-session"
|
||||
"-t" ,(ob-tmux--target ob-session))))
|
||||
(let ((tmux-cmd `(,org-babel-tmux-location
|
||||
"attach-session" "-t" ,(ob-tmux--target ob-session))))
|
||||
(unless (ob-tmux--socket ob-session)
|
||||
(apply 'start-process (append start-process-mandatory-args
|
||||
org-babel-tmux-terminal-opts
|
||||
tmux-cmd)))))
|
||||
(unless (zerop (apply #'call-process terminal nil nil nil
|
||||
(append org-babel-tmux-terminal-opts
|
||||
tmux-cmd)))
|
||||
(error "Error executing tmux command")))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Tmux interaction
|
||||
|
|
Loading…
Reference in New Issue