shell-command-to-new-scratch

TorgoX on 2005-05-11T07:10:12

Dear Log,

I don't like how emacs's shell-command keeps overwriting whatever is in the "*Shell Command Output*" buffer. So I wrote this function that writes to an always-new scratch buffer:

(setq shell-buffer-counter 1000)

(defun shell-command-to-new-scratch (command)
  (interactive (list (read-from-minibuffer
		      "Shell command: "
		      nil nil nil 'shell-command-history)))
  (setq shell-buffer-counter (+ 1 shell-buffer-counter ))
  (shell-command command
		 (concat "*scratch "
			 (int-to-string shell-buffer-counter)
			 "% "
			 command
			 )))
And I bound it to a happy place;
(global-set-key "\M-!" 'shell-command-to-new-scratch)