all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Command to execute in a shell
Date: Fri, 31 Jul 2009 04:46:41 +0200	[thread overview]
Message-ID: <871vnxefhq.fsf@galatea.local> (raw)
In-Reply-To: 87tz0t68ln.fsfhello@somewhere.com

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__


  reply	other threads:[~2009-07-31  2:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-30 23:42 Command to execute in a shell Rafael
2009-07-31  2:46 ` Pascal J. Bourguignon [this message]
2009-07-31  4:18   ` Rafael
2009-08-01 23:57     ` Xah Lee
2010-02-19  5:41       ` Rafael

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871vnxefhq.fsf@galatea.local \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.