Skip to content

Conversation

@wraithm
Copy link
Contributor

@wraithm wraithm commented Apr 6, 2016

So, I made stylish-haskell run on the current buffer. Now, when there's an error, stderr gets dumped to the buffer at the top of the file... This is probably not ideal, but it's the best I could manage with call-process-region.

@wraithm
Copy link
Contributor Author

wraithm commented Apr 6, 2016

Another way to possibly do this would be make a temporary file, save the current buffer to that temp file, then run stylish-haskell on that temp file with call-process (instead of call-process-region). You can get a separate stdout and stderr file with call-process, you can't get that with call-process-region.

@wraithm
Copy link
Contributor Author

wraithm commented Apr 6, 2016

Yeah, this solution is a hack. I don't think we should go with this solution.

@wraithm wraithm closed this Apr 6, 2016
@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

Docs say:

(call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY
&rest ARGS)

Send text from START to END to a synchronous process running PROGRAM.
The remaining arguments are optional.
Delete the text if fourth arg DELETE is non-nil.

Insert output in BUFFER before point; t means current buffer; nil for
 BUFFER means discard it; 0 means discard and don't wait; and `(:file
 FILE)', where FILE is a file name string, means that it should be
 written to that file (if the file already exists it is overwritten).
BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
REAL-BUFFER says what to do with standard output, as above,
while STDERR-FILE says what to do with standard error in the child.
STDERR-FILE may be nil (discard standard error output),
t (mix it with ordinary output), or a file name string.

Note that BUFFER may separate STDERR from STDOUT.

@wraithm
Copy link
Contributor Author

wraithm commented Apr 6, 2016

I made a new PR where stdout and stderr are handled. #1268

(tmp-file (make-temp-file cmd-prefix))
(err-file (make-temp-file cmd-prefix))
(let* ((cmd-prefix (replace-regexp-in-string " .*" "" cmd))
(tmp-buf (generate-new-buffer cmd-prefix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This temp buffer can be the same buffer as the one created with with-temp-buffer below, I think.

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

Does look pretty close to good solution to me...

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

I see. Do you know that in github you can just add commits to already open PR or even do a force push? No need to open new PRs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants