help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Inserting output from a program into a buffer


From: jpkotta
Subject: Re: Inserting output from a program into a buffer
Date: Mon, 22 Feb 2010 15:06:15 -0800 (PST)
User-agent: G2/1.0

On Feb 21, 10:45 pm, Tim Johnson <t...@johnsons-web.com> wrote:
> On 2010-02-22, Pascal J. Bourguignon <p...@informatimago.com> wrote:
> <..>> You could get a string without attribute using the function
> > buffer-substring-no-properties instead of buffer-substring.
>
>  Oh! Deja vu here... I believe that what I really need is
>  buffer-substring-<etc> to copy the region directly to a
>  variable.
>  thanks Pascal
>
> --
> Tim
> t...@johnsons-web.comhttp://www.akwebsoft.com

I wrote this a couple of weeks ago, and just extended it to work when
the region is active.

,----
| ;; see also C-u M-|
| (defun insert-from-shell-current-line ()
|   "Run the current line as a shell command, and put the output
|   immediately after it.  If the region is active, use for the
|   command."
|   (interactive "*")
|   (let ((start (line-beginning-position))
|         (stop (line-end-position)))
|     (when (region-active-p)
|       (setq start (region-beginning))
|       (setq stop (region-end)))
|     (goto-char stop)
|     (insert "\n")
|     (insert (shell-command-to-string
|              (buffer-substring start stop)))))
`----



reply via email to

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