Open mwotton opened 7 years ago
i'm not much of an elisp hacker, so i won't put a PR together, but if there's a more sensible way of dealing with temporary buffers, something with this effect would be nice
(defun hlint-refactor-call-process-region-checked (start end program &optional args)
"Send text from START to END to PROGRAM with ARGS.
This is a wrapper around `call-process-region' that doesn't replace
the region with the output of PROGRAM if it returned a non-zero
exit code."
(let ((exit (apply 'call-process-region
start end
program ; name of program
t ; delete region
'(t "/tmp/hlint-refactor-errors") ; send output to buffer
nil ; no redisplay during output
args
)))
(unless (eq exit 0)
(primitive-undo 1 buffer-undo-list)
(message "something broke in hlint: %s" (with-temp-buffer
(insert-file-contents "/tmp/hlint-refactor-errors")
(buffer-string))))))
(as to the underlying bug: https://github.com/ndmitchell/hlint/issues/281 I think hlint is not passing the needed extensions to the refactor binary)
if you're missing a pragma, C-c , b just fails silently. I realise it isn't your bug to fix and i've lodged an issue with apply-refactor to take in pragmas from another place, but it'd be helpful to have a message when hlint returns a nonzero code.