-
Notifications
You must be signed in to change notification settings - Fork 347
Stylish haskell after save #1268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -806,31 +806,21 @@ inferior GHCi process." | |
Use buffer as input and replace the whole buffer with the | ||
output. If CMD fails the buffer remains unchanged." | ||
(set-buffer-modified-p t) | ||
(let* ((chomp (lambda (str) | ||
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str) | ||
(setq str (replace-match "" t t str))) | ||
str)) | ||
(_errout (lambda (fmt &rest args) | ||
(let* ((warning-fill-prefix " ")) | ||
(display-warning cmd (apply 'format fmt args) :warning)))) | ||
(filename (buffer-file-name (current-buffer))) | ||
(cmd-prefix (replace-regexp-in-string " .*" "" cmd)) | ||
(tmp-file (make-temp-file cmd-prefix)) | ||
(err-file (make-temp-file cmd-prefix)) | ||
(let* ((tmp-buf (generate-new-buffer " output")) | ||
(err-buf (generate-new-buffer " error")) | ||
(default-directory (if (and (boundp 'haskell-session) | ||
haskell-session) | ||
(haskell-session-cabal-dir haskell-session) | ||
default-directory)) | ||
(_errcode (with-temp-file tmp-file | ||
(call-process cmd filename | ||
(list (current-buffer) err-file) nil))) | ||
(_errcode | ||
(call-process-region (point-min) (point-max) cmd nil (list (buffer-name tmp-buf) (buffer-name err-buf)) nil)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK can't have buffer for STDERR, has to be a file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This worked as expected. I tested it. I could do a few more tests or something to be absolutely certain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. It should be more like: (call-process-region (point-min) (point-max) cmd nil
(list tmp-buf (make-temp-name "tempxx")) nil)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again, temp file has to be deleted using |
||
(stderr-output | ||
(with-temp-buffer | ||
(insert-file-contents err-file) | ||
(funcall chomp (buffer-substring-no-properties (point-min) (point-max))))) | ||
(insert-buffer err-buf) | ||
(buffer-substring-no-properties (point-min) (point-max)))) | ||
(stdout-output | ||
(with-temp-buffer | ||
(insert-file-contents tmp-file) | ||
(insert-buffer tmp-buf) | ||
(buffer-substring-no-properties (point-min) (point-max))))) | ||
(if (string= "" stderr-output) | ||
(if (string= "" stdout-output) | ||
|
@@ -839,14 +829,15 @@ output. If CMD fails the buffer remains unchanged." | |
(widen) | ||
;; command successful, insert file with replacement to preserve | ||
;; markers. | ||
(insert-file-contents tmp-file nil nil nil t))) | ||
(erase-buffer) | ||
(insert-buffer tmp-buf))) | ||
(progn | ||
;; non-null stderr, command must have failed | ||
(message "Error: %s ended with errors, leaving buffer alone" cmd) | ||
;; use (warning-minimum-level :debug) to see this | ||
(display-warning cmd stderr-output :debug))) | ||
(delete-file tmp-file) | ||
(delete-file err-file))) | ||
(kill-buffer err-buf) | ||
(kill-buffer tmp-buf))) | ||
|
||
;;;###autoload | ||
(defun haskell-mode-find-uses () | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this has to be protected by
unwind-protect
.