From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Command to execute in a shell Date: Fri, 31 Jul 2009 04:46:41 +0200 Organization: Informatimago Message-ID: <871vnxefhq.fsf@galatea.local> References: <87tz0t68ln.fsfhello@somewhere.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1249011649 24897 80.91.229.12 (31 Jul 2009 03:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Jul 2009 03:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 31 05:40:42 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MWiz3-0001kl-MD for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Jul 2009 05:40:41 +0200 Original-Received: from localhost ([127.0.0.1]:43790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MWiz3-0001FP-06 for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jul 2009 23:40:41 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-X-Trace: individual.net Ekolhr8DABqz9xVxTCtASQlD2PoSqTCqJ7xfEb+owd1f1rsLGt Cancel-Lock: sha1:MzBmMzJkYTIwNzk2OTNhNjExOTFhZDg5ODVlZjdlZGNkMTJkNzQ3Mw== sha1:V3pyt6+7nfgeto5XzscNqLSz6qQ= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:171366 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:66551 Archived-At: Rafael 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__