[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Command to execute in a shell
From: |
Pascal J. Bourguignon |
Subject: |
Re: Command to execute in a shell |
Date: |
Fri, 31 Jul 2009 04:46:41 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
Rafael <rvf0068@gmail.com> writes:
> Hello,
>
> In the following function, I would like to execute a command in the
> shell window (tikz2pdf -v (buffer-name)). How could I do that?
> Thanks.
>
> (defun split-for-tikz2pdf ()
> (interactive)
> (split-window-horizontally 60)
> (other-window 1)
> (split-window-vertically 15)
> (other-window 1)
> (shell)
> )
I assume you want to substitute "(buffer-name)" by the name of the
buffer in the shell command. But what tikz2pdf would do of an emacs
buffer name? Have you read the manual of tikz2pdf? Doesn't it expect
rather a file path? You will probably want to give it the result of
(buffer-file-name).
(format "tikz2pdf -v %S" (buffer-file-name))
will build the shell command.
Do you want to keep the shell after the command is run, or do you just
want to run the command? In the later case, there's shell-command.
;; instead of (shell):
(when (buffer-file-name)
(shell-command (format "tikz2pdf -v %S" (buffer-file-name))))
If you really want shell, then you will have to send the command to
the shell process:
;; instead of (shell):
(let ((file-path (buffer-file-name)))
(when file-path
(shell)
(comint-send-string (get-buffer-process (current-buffer))
(format "tikz2pdf -v %S \n" file-path))))
Notice that if tikz2pdf may issue errors while processing the file,
you may rather consider it like a compilation:
(when (buffer-file-name)
(compile (format "tikz2pdf -v %S" (buffer-file-name))))
so you can skip to the error lines (assuming the errors are issued
with the standard format, or that you have configured the
variable compilation-error-regexp-alist-alist to match them).
--
__Pascal Bourguignon__