From ccabffc7cd3dd20886a0579d151aad3bd2221082 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Fri, 8 Jun 2012 15:04:36 +0200 Subject: [PATCH] Fix haskell-mode-buffer-apply-command to not mess with the windows. --- haskell-mode.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/haskell-mode.el b/haskell-mode.el index 0dbb24460..3bd81945a 100644 --- a/haskell-mode.el +++ b/haskell-mode.el @@ -764,14 +764,16 @@ This function will be called with no arguments.") "Execute shell command CMD with current buffer as input and replace the whole buffer with the output. If CMD fails the buffer remains unchanged." - (let ((target-buffer (current-buffer))) - (with-temp-buffer - (let ((tmp-buffer (current-buffer))) - (when (= 0 (with-current-buffer target-buffer - (shell-command-on-region (point-min) (point-max) cmd tmp-buffer))) - (with-current-buffer target-buffer - (erase-buffer) - (insert-buffer tmp-buffer))))))) + (let* ((file (buffer-file-name (current-buffer))) + (output (with-temp-buffer + (call-process cmd + file + (list t nil) + nil) + (buffer-substring-no-properties (point-min) (point-max))))) + (unless (string= "" output) + (erase-buffer) + (insert output)))) (defun haskell-mode-stylish-buffer () "Apply stylish-haskell to the current buffer."