;;;;;;;;;;;;;;;;;;;;; Time-stamp: "2006-01-06 22:58:06 AST" ;;;;;;;;;;;;;;; ;; ;; Stuff to help launching processes different ways; uses "!!" to mean ;; the current buffer's filename. (defun buffer-basename-or (orelse) (if (buffer-file-name) (file-name-nondirectory (buffer-file-name)) orelse)) (defun rep!!basename (str) (replace-regexp-in-string "!!" (buffer-basename-or "WHATFILE") str)) (defun launch (cmd &rest args) "Launch cmd with given arguments, neither waiting for completion, nor saving its output." (unwind-protect (progn (setenv "UNDER_EMACS") (apply 'call-process (rep!!basename cmd) nil 0 nil args)) (setenv "UNDER_EMACS" "1"))) (setq shell-buffer-counter 100) ;My suggestions: ; (global-set-key "\M-!" 'shell-command-to-new-scratch ) ; (global-set-key "\M->" 'shell-command-into-void ) (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 (rep!!basename command) (concat ; "Shell Command Output " (int-to-string shell-buffer-counter) "\242 " (rep!!basename command) ))) (defun shell-command-into-void (&optional cmd) "Execute shell command COMMAND and return its output as a string." (interactive) (setq cmd (or cmd (read-from-minibuffer "Program to launch: " nil nil nil 'shell-command-history))) (message "Launching: %s" cmd) (unwind-protect (progn (setenv "UNDER_EMACS") (call-process shell-file-name nil 0 nil shell-command-switch (rep!!basename cmd)) (setenv "UNDER_EMACS" "1")))) ;;End.