[Top][All Lists]

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

Re: command output into buffer

From: Lee Doolan
Subject: Re: command output into buffer
Date: Sat, 13 Apr 2002 12:42:51 -0700
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/20.7 (i386--freebsd)

i have this in my .emacs file.

;;I found this relly useful snippet on USENET (comp.emacs) posted by:
;;    From: Tim Christian <>
(defun my-shell-command-on-region nil
  "Replace region with ``shell-command-on-region''.
By default, this will make mark active if it is not and then prompt
you for a shell command to run and replaces region with the results.
This is handy for doing things like getting external program locations
in scripts and running grep and whatnot on a region."
    (if (equal mark-active nil)
        (push-mark nil nil -1))
    (setq string
          (read-from-minibuffer "Shell command on region: " nil nil nil
    (shell-command-on-region (region-beginning) (region-end) string -1)
    ; Get rid of final newline cause I normally did by hand anyway.
    (delete-char -1)))

(defun insert-output-from-shell-command (commandstr)
  "Insert output from a shell command at point"
  (interactive "*sInsert From Command:")
  (shell-command commandstr 1))

(global-set-key "\M-oi" 'insert-output-from-shell-command)
(global-set-key "\M-or" 'my-shell-command-on-region)

no toll on the internet; there are paths of many kinds;
whoever passes this portal will travel freely in the world

reply via email to

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