all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* launching external program with (buffer filename as parameter)
@ 2009-05-04  1:21 ex
  2009-05-04  8:35 ` Anselm Helbig
  2009-05-08 15:13 ` William Xu
  0 siblings, 2 replies; 3+ messages in thread
From: ex @ 2009-05-04  1:21 UTC (permalink / raw)
  To: help-gnu-emacs

Hi fellows :D

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)

(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.

So please help me!
How can I make this to work?

;;------------------------------------------------------------------------------
(defun my-simple-ruby-shell
  (save-active-buffer)
  (shell "ruby -w %f" (active-buffer-file-path))
;;------------------------------------------------------------------------------

I guess I'm just missing some glue there, sorry about my elisp
ignorance,
I'm just tired of trying this thing to work.

Best regards
Laurens



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: launching external program with (buffer filename as parameter)
  2009-05-04  1:21 launching external program with (buffer filename as parameter) ex
@ 2009-05-04  8:35 ` Anselm Helbig
  2009-05-08 15:13 ` William Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Anselm Helbig @ 2009-05-04  8:35 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: launching external program with (buffer filename as parameter)
  2009-05-04  1:21 launching external program with (buffer filename as parameter) ex
  2009-05-04  8:35 ` Anselm Helbig
@ 2009-05-08 15:13 ` William Xu
  1 sibling, 0 replies; 3+ messages in thread
From: William Xu @ 2009-05-08 15:13 UTC (permalink / raw)
  To: help-gnu-emacs

ex <exeQtor@gmail.com> writes:

> 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:

Is the "arguments question" asking you to confirm the compile command?
If that is the case, you may try buffer-action.el[1] -- "Perform
actions(compile/run, etc) in buffer based on mode/filename".  It will
only bother you the first time launching it.  (And you can edit it again
with C-u prefix) And it's small, just 254 lines...


[1], http://xwl.appspot.com/ref/buffer-action.el

-- 
William

http://xwl.appspot.com





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-08 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-04  1:21 launching external program with (buffer filename as parameter) ex
2009-05-04  8:35 ` Anselm Helbig
2009-05-08 15:13 ` William Xu

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.