Skip to content
This repository
Browse code

Use a temporary buffer for stylish (refs #54).

  • Loading branch information...
commit 4bd22d04e297d2a9ae76c487b30a7bce7be35cd7 1 parent 344c0e1
Chris Done chrisdone authored

Showing 1 changed file with 9 additions and 4 deletions. Show diff stats Hide diff stats

  1. +9 4 haskell-mode.el
13 haskell-mode.el
@@ -763,10 +763,15 @@ This function will be called with no arguments.")
763 763 (defun haskell-mode-buffer-apply-command (cmd)
764 764 "Execute shell command CMD with current buffer as input and
765 765 replace the whole buffer with the output. If CMD fails the
766   - buffer remains unchanged"
767   - (when (= 0 (shell-command-on-region (point-min) (point-max) cmd))
768   - (erase-buffer)
769   - (insert-buffer "*Shell Command Output*")))
  766 + buffer remains unchanged."
  767 + (let ((target-buffer (current-buffer)))
  768 + (with-temp-buffer
  769 + (let ((tmp-buffer (current-buffer)))
  770 + (when (= 0 (with-current-buffer target-buffer
  771 + (shell-command-on-region (point-min) (point-max) cmd tmp-buffer)))
  772 + (with-current-buffer target-buffer
  773 + (erase-buffer)
  774 + (insert-buffer tmp-buffer)))))))
770 775
771 776 (defun haskell-mode-stylish-buffer ()
772 777 "Apply stylish-haskell to the current buffer."

0 comments on commit 4bd22d0

Please sign in to comment.
Something went wrong with that request. Please try again.