help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launching external program with (buffer filename as parameter)


From: Anselm Helbig
Subject: Re: launching external program with (buffer filename as parameter)
Date: Mon, 04 May 2009 10:35:02 +0200
User-agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.7 Emacs/22.3 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hi!

> I'm used to run my scripts with only one keyboard touch (F5), (F6),
> (F7), etc...
> I was using Editplus that allowed me to define user-tools
> the idea is very simple:
> 
> 1) save current document
> 2) launch system command: [name_program] [document_path]
> 3) [name_program] runs in his own window, output/errors are printed in
> that window...
> 
> with this simple schema I could run my perl, python, ruby, etc scripts
> just changing the program name, i.e:
>   ruby my/ruby/script/path
> It's very simple and convenient, I'm even able to send by email the
> current document using perl (forgive please!)
> perl_mailing_script [document_path]
> 
> Of course I now have a python-mode with lots of things to play, and it
> could be easy just use that, but I think in order to really learn
> emacs I need to know how to emulate the above steps.
> The other problem is that with ruby the mode-compile uses lots of code
> to do just 3 simple steps (and is annoying me with the arguments
> question), this is my .emacs:
> 
> ;;------------------------------------------------------------------------------
> ;; Install mode-compile
> (require 'mode-compile)

The "require" line is not necessary since you're also using
autoloads. Using autoloads is generally preferable as it results in
faster startup times and doesn't throw an error for libraries that are
not installed until you try to use them. 

> (autoload 'mode-compile "mode-compile"
>     "Command to compile current buffer file based on the major mode"
> t)
> (global-set-key [(f5)] 'mode-compile)
> 
> (autoload 'mode-compile-kill "mode-compile"
>     "Command to kill a compilation launched by `mode-compile'" t)
> (global-set-key [(pause)] 'mode-compile-kill)
> 
> (setq mode-compile-always-save-buffer-p t) ;; Always save
> ;;------------------------------------------------------------------------------
> 
> AS you can see, I was able to always save the buffer, but can not
> disable the arguments question.

For a normal M-x compile the confimation dialog is turned off with

  (setq compilation-read-command nil)

Don't know if this also works with mode-compile, I didn't have time to
look at it in more detail. However, the functionality you're looking
could easily be implemented in a few lines of elisp, but that depends
on what you're really trying to do. Do you need a background job, are
you interested in the output, or do you want to run a syntax checker?
If it is the latter, have a look at flymake-mode as well:
http://www.emacswiki.org/emacs/FlyMake

HTH, 

Anselm


-- 
Anselm Helbig 
mailto:anselm.helbig+news2009@googlemail.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]