branch: elpa/sass-mode commit 7f0df85fd1b90e40e019a0f2e4ea6661169ceb65 Author: Steve Purcell <st...@sanityinc.com> Commit: Steve Purcell <st...@sanityinc.com>
Nicer buffer handling for sass-output-region - Ensure error buffer is shown when relevant - Put that buffer into view-mode - Only show output buffer when the output command succeeded --- sass-mode.el | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/sass-mode.el b/sass-mode.el index 49cf88f..e271907 100644 --- a/sass-mode.el +++ b/sass-mode.el @@ -232,18 +232,25 @@ Called from a program, START and END specify the region to indent." (let ((output-buffer "*sass-output*") (errors-buffer "*sass-errors*") (region-contents (buffer-substring start end))) - (with-temp-buffer - (insert region-contents) - (newline-and-indent) - (sass--remove-leading-indent) - (shell-command-on-region (point-min) (point-max) "sass --stdin" - output-buffer - nil - errors-buffer)) - (when (fboundp 'css-mode) - (with-current-buffer output-buffer - (css-mode))) - (switch-to-buffer-other-window output-buffer))) + (let ((exit-code + (with-temp-buffer + (insert region-contents) + (newline-and-indent) + (sass--remove-leading-indent) + (shell-command-on-region (point-min) (point-max) "sass --stdin" + output-buffer + nil + errors-buffer + t)))) + + (if (zerop exit-code) + (progn + (when (fboundp 'css-mode) + (with-current-buffer output-buffer + (css-mode))) + (switch-to-buffer-other-window output-buffer)) + (with-current-buffer errors-buffer + (view-mode)))))) (defun sass-output-buffer () "Displays the CSS output for entire buffer."