emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exit status inserted in shell command output buffer


From: Kim F. Storm
Subject: Re: Exit status inserted in shell command output buffer
Date: 25 Feb 2002 14:58:30 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

I recently wrote:
> I don't like the new `functionality' which adds the line
> "...Shell command failed with code X"
> to the *Shell Command Output* buffer when a command returns
> a non-zero exit status.
> 
> In my mind, if a command produces output, emacs shouldn't modify
> (i.e. add to) the output from the command!


The following patch places the Exit code in the mode line of the
*Shell Command Output* buffer (using the `mode-line-process' variable).

So it's shown to the users interested in such things, but don't
mess with the buffer...

What do you think? 

(The following patch was inserted here with insert-buffer without
manually having to delete the ...Shell command failed  line :-)


Index: simple.el
===================================================================
RCS file: /cvs/emacs/lisp/simple.el,v
retrieving revision 1.522
diff -c -r1.522 simple.el
*** simple.el   20 Feb 2002 22:33:01 -0000      1.522
--- simple.el   25 Feb 2002 13:56:02 -0000
***************
*** 1475,1490 ****
                                         nil shell-command-switch command)))
          (setq success (and exit-status (equal 0 exit-status)))
          ;; Report the output.
          (if (with-current-buffer buffer (> (point-max) (point-min)))
              ;; There's some output, display it
!             (progn
!               (if (not success)
!                   (with-current-buffer buffer
!                     (save-excursion
!                       (goto-char (point-max))
!                       (insert (format "...Shell command failed with code %d"
!                                       exit-status)))))
!               (display-message-or-buffer buffer))
            ;; No output; error?
            (let ((output
                   (if (and error-file
--- 1475,1487 ----
                                         nil shell-command-switch command)))
          (setq success (and exit-status (equal 0 exit-status)))
          ;; Report the output.
+         (with-current-buffer buffer
+           (setq mode-line-process 
+                 (if (not success)
+                   (concat (format " - Exit [%d]" exit-status)))))
          (if (with-current-buffer buffer (> (point-max) (point-min)))
              ;; There's some output, display it
!             (display-message-or-buffer buffer)
            ;; No output; error?
            (let ((output
                   (if (and error-file


-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]