Skip to content

Commit

Permalink
Fixes ananthakumaran#103: Use `make-process' to start cmdserver.
Browse files Browse the repository at this point in the history
This allows to redirect stderr to a buffer from within Emacs rather
than using a shell to redirect.  This works even under Windows.
  • Loading branch information
ncalexan committed Feb 5, 2021
1 parent 96fae55 commit bef4e3b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions monky.el
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,19 @@ refreshes buffers."
'ido-completing-read)
args))

(defun monky-start-cmdserver-process (name buffer program &rest program-args)
"Just like `start-process', but with stderr routed to buffer
`monky-cmd-process-stderr-buffer-name'."
(unless (fboundp 'make-process)
(error "Emacs was compiled without subprocess support"))
(monky-with-process-environment
(apply #'make-process
(append (list :name name :buffer buffer
:stderr (get-buffer-create monky-cmd-process-stderr-buffer-name)
:file-handler t)
(if program
(list :command (cons program program-args)))))))

(defun monky-start-process (&rest args)
(monky-with-process-environment
(apply (if (functionp 'start-file-process)
Expand All @@ -390,6 +403,7 @@ refreshes buffers."

(defvar monky-cmd-process nil)
(defvar monky-cmd-process-buffer-name "*monky-cmd-process*")
(defvar monky-cmd-process-stderr-buffer-name "*monky-cmd-process-stderr*")
(defvar monky-cmd-process-input-buffer nil)
(defvar monky-cmd-process-input-point nil)
(defvar monky-cmd-error-message nil)
Expand Down Expand Up @@ -452,9 +466,10 @@ refreshes buffers."
(with-current-buffer buffer
(bury-buffer))))
(setq default-directory dir)
(let ((monky-cmd-process (monky-start-process
"monky-hg" buf "sh" "-c"
(format "%s --config extensions.mq= serve --cmdserver pipe 2> /dev/null" monky-hg-executable))))
(let ((monky-cmd-process (monky-start-cmdserver-process
"monky-hg" buf
monky-hg-executable
"--config" "extensions.mq=" "serve" "--cmdserver" "pipe")))
(set-process-coding-system monky-cmd-process 'no-conversion 'no-conversion)
(set-process-sentinel monky-cmd-process #'monky-cmdserver-sentinel)
(setq monky-cmd-hello-message
Expand Down

0 comments on commit bef4e3b

Please sign in to comment.