From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Help: execute scripts form emacs
Date: Wed, 14 Oct 2009 02:37:00 -0700 (PDT) [thread overview]
Message-ID: <4881da3a-0643-4a13-936c-2a224b8b04ee@m3g2000pri.googlegroups.com> (raw)
In-Reply-To: mailman.8598.1255354671.2239.help-gnu-emacs@gnu.org
On Oct 12, 3:39 am, wdysun <grammopho...@gmail.com> wrote:
> Hello dears,
>
> suppose I have a script in /bin, let us assume it is called mytex. Suppose 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 function
> so that I can run the command just with M - something?
have a look here:
• 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 “perl x.pl” 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
∑ http://xahlee.org/
☄
next prev parent reply other threads:[~2009-10-14 9:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.8598.1255354671.2239.help-gnu-emacs@gnu.org>
2009-10-12 14:10 ` Help: execute scripts form emacs Olivier Sirven
2009-10-12 17:30 ` Pascal J. Bourguignon
2009-10-14 9:37 ` Xah Lee [this message]
2009-10-14 16:01 ` Raymond Wiker
2009-10-12 10:39 wdysun
2009-10-12 18:37 ` wdysun
2009-10-13 20:49 ` Maurizio Vitale
2009-10-13 23:10 ` Andreas Politz
2009-10-14 8:24 ` wdysun
[not found] ` <mailman.8700.1255466814.2239.help-gnu-emacs@gnu.org>
2009-10-13 22:49 ` Jon Solberg
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=4881da3a-0643-4a13-936c-2a224b8b04ee@m3g2000pri.googlegroups.com \
--to=xahlee@gmail.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.