From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Help: execute scripts form emacs Date: Wed, 14 Oct 2009 02:37:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4881da3a-0643-4a13-936c-2a224b8b04ee@m3g2000pri.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1255566995 25731 80.91.229.12 (15 Oct 2009 00:36:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Oct 2009 00:36:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 15 02:36:24 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 1MyEKL-0001ar-0J for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Oct 2009 02:36:21 +0200 Original-Received: from localhost ([127.0.0.1]:44418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyEKK-0007Qe-FI for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Oct 2009 20:36:20 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!m3g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 65 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1255513020 17331 127.0.0.1 (14 Oct 2009 09:37:00 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 14 Oct 2009 09:37:00 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m3g2000pri.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.25 Safari/532.0, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:173866 comp.emacs:99275 X-Mailman-Approved-At: Wed, 14 Oct 2009 20:35:13 -0400 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:68968 Archived-At: On Oct 12, 3:39 am, wdysun wrote: > Hello dears, > > suppose I have a script in /bin, let us assume it is called mytex. Suppos= e I > am editing a file called filename.tex. > > If I run the following command from the console: > > $ mytex filename > > this will do several things (tex the filename with several options, then > convert the dvi to pdf and it deletes all aux files I don't need). > > There is a way to launch the script from emacs or even to build a functio= n > so that I can run the command just with M - something? have a look here: =E2=80=A2 Elisp Lesson: Execute/Compile Current File http://xahlee.org/emacs/elisp_run_current_file.html excerpt: (defun run-current-file () "Execute or compile the current file. For example, if the current buffer is the file x.pl, then it'll call =E2=80=9Cperl x.pl=E2=80=9D in a shell. The file can be php, perl, python, ruby, javascript, bash, ocaml, java. File suffix is used to determine what program to run." (interactive) (let (ext-map fname suffix progName cmdStr) (setq ext-map ; a keyed list of file suffix to comand-line program to run '( ("php" . "php") ("pl" . "perl") ("py" . "python") ("rb" . "ruby") ("js" . "js") ("sh" . "bash") ("ml" . "ocaml") ("lsl" . "lslint") ("vbs" . "cscript") ("java" . "javac") ) ) (setq fname (buffer-file-name)) (setq suffix (file-name-extension fname)) (setq progName (cdr (assoc suffix ext-map))) (setq cmdStr (concat progName " \"" fname "\"")) (if (string-equal suffix "el") (load-file fname) (progn (message "Running...") (shell-command cmdStr))) )) Xah =E2=88=91 http://xahlee.org/ =E2=98=84