I am having difficulties ignoring the stderr stream of my call to LuaFormatter from Emacs (see call-shell-region):
(defun rpo-lua-format-buffer ()
(let ((formatter-cfg-file ".lua-format")
(formatter-cfg-dir (locate-dominating-file "." ".lua-format")))
(if formatter-cfg-dir
(let* (tmp-buffer-name (make-temp-name "tmp")
(tmp-buffer (get-buffer-create tmp-buffer-name)))
(if (eq 0 (call-shell-region
(point-min) (point-max) (concat "lua-format --config=" (expand-file-name (concat formatter-cfg-dir formatter-cfg-file))) nil '(tmp-buffer nil)))
(replace-buffer-contents tmp-buffer 3)
(error "lua-format failed."))
(kill-buffer tmp-buffer))
#'er-indent-and-cleanup-region-or-buffer)))
The error I get, when calling this function (from a before-save-hook
) is:
Error: (wrong-type-argument stringp nil)
However, when I replace the last argument '(tmp-buffer nil)
of shell-call-region
with tmp-buffer
alone, I get stdout and stderr merged in the new buffer.
How can I get rid of the stream content of stderr and only keep stdout?