* Command to execute in a shell
@ 2009-07-30 23:42 Rafael
2009-07-31 2:46 ` Pascal J. Bourguignon
0 siblings, 1 reply; 5+ messages in thread
From: Rafael @ 2009-07-30 23:42 UTC (permalink / raw)
To: help-gnu-emacs
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)
)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command to execute in a shell
2009-07-30 23:42 Command to execute in a shell Rafael
@ 2009-07-31 2:46 ` Pascal J. Bourguignon
2009-07-31 4:18 ` Rafael
0 siblings, 1 reply; 5+ messages in thread
From: Pascal J. Bourguignon @ 2009-07-31 2:46 UTC (permalink / raw)
To: help-gnu-emacs
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__
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command to execute in a shell
2009-07-31 2:46 ` Pascal J. Bourguignon
@ 2009-07-31 4:18 ` Rafael
2009-08-01 23:57 ` Xah Lee
0 siblings, 1 reply; 5+ messages in thread
From: Rafael @ 2009-07-31 4:18 UTC (permalink / raw)
To: help-gnu-emacs
pjb@informatimago.com (Pascal J. Bourguignon) writes:
> 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))))
Thank you very much, this is exactly what I wanted at this point.
Since the picture files are usually small, most of the time I just want
to know if the compilation was successful. The result of this can be
seen at
http://farm4.static.flickr.com/3424/3774270402_81b58c6909_o.png
and the function I have so far is:
(defun split-for-tikz2pdf ()
(interactive)
(TeX-run-style-hooks "tikz")
(split-window-horizontally 60)
(other-window 1)
(split-window-vertically 15)
(find-file "tikz2pdf_temp.pdf")
(doc-view-mode)
(auto-revert-mode 1)
(other-window 1)
(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))))
)
and the only wish I have now is to have doc-view-mode actually chosen
for the buffer of the .pdf file, (which is a new file at the moment).
As it is, it is in text mode (the default-major-mode). I would
appreciate any comments.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command to execute in a shell
2009-07-31 4:18 ` Rafael
@ 2009-08-01 23:57 ` Xah Lee
2010-02-19 5:41 ` Rafael
0 siblings, 1 reply; 5+ messages in thread
From: Xah Lee @ 2009-08-01 23:57 UTC (permalink / raw)
To: help-gnu-emacs
On Jul 30, 9:18 pm, Rafael <rvf0...@gmail.com> wrote:
> ...
> The result of this can be
> seen at
>
> http://farm4.static.flickr.com/3424/3774270402_81b58c6909_o.png
Nice graph. :D
what software is it?
> and the function I have so far is:
>
> (defun split-for-tikz2pdf ()
> (interactive)
> (TeX-run-style-hooks "tikz")
> (split-window-horizontally 60)
> (other-window 1)
> (split-window-vertically 15)
> (find-file "tikz2pdf_temp.pdf")
> (doc-view-mode)
> (auto-revert-mode 1)
> (other-window 1)
> (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))))
> )
>
> and the only wish I have now is to have doc-view-mode actually chosen
> for the buffer of the .pdf file, (which is a new file at the moment).
> As it is, it is in text mode (the default-major-mode). I would
> appreciate any comments.
haven't fully read this thread, but if you want elisp code to activate
a particular mode, use:
(funcall (intern "doc-view-mode"))
It is pulled from
• Using Emacs To Syntax Color Source Code In HTML
http://xahlee.org/emacs/elisp_htmlize.html
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-19 5:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-30 23:42 Command to execute in a shell Rafael
2009-07-31 2:46 ` Pascal J. Bourguignon
2009-07-31 4:18 ` Rafael
2009-08-01 23:57 ` Xah Lee
2010-02-19 5:41 ` Rafael
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).