[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How automatically/immediately run command in ansi-term *with* *argum
From: |
Michael Heerdegen |
Subject: |
Re: How automatically/immediately run command in ansi-term *with* *arguments* ? |
Date: |
Wed, 11 Feb 2015 00:44:41 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Chris Seberino <cseberino@gmail.com> writes:
> How get arguments to work? This would be quite a nice replacement for
> shell-command if it could for people that like/need ansi-term.
Try this, a hack, but seems to work here, no guarantee though:
--8<---------------cut here---------------start------------->8---
(defun my-shell-command (cmd)
(interactive (list (read-shell-command "Command: ")))
(setq cmd (split-string cmd " "))
(require 'term)
(let* ((buffer (apply #'term-ansi-make-term
"*Shell Command*"
(car cmd)
nil
(cdr cmd)))
(proc (get-buffer-process buffer)))
(set-process-sentinel
proc
(lambda (proc msg)
(let ((buffer (process-buffer proc)))
(when (memq (process-status proc) '(signal exit))
(with-current-buffer buffer
(delete-process proc)
(goto-char (point-min)))))))
(switch-to-buffer buffer)))
--8<---------------cut here---------------end--------------->8---
Michael.