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

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

Re: launching a perl script


From: Mart Zirnask
Subject: Re: launching a perl script
Date: Thu, 22 Sep 2011 19:02:36 +0300

Okay,
I got everything working using "compile" instead :) Like this:

-----------------
;;; --- Perl tag-cloud --- ;;;
(defun tagcloud ()
(interactive)
(compile (concat "perl c:/tags.pl "  (shell-quote-argument
(buffer-file-name)) " &")))
(global-set-key (kbd "<f2>") 'tagcloud) ; hotkey: f2
-----------------

Now, a question: how could I assign the same hotkey (F2) to "refresh"
the compilaton when it's running?

Namely, the script generates a tag cloud based on a text file. But
when I happen to change something in the file, the cloud isn't updated
automatically. I need to kill the Perl process and start everything
anew in order to get a "fresh cloud". A workaround for this would be
great.

Thanks for your help!

I'm an absolute newbie but, really, Emacs rocks!
Best,
Mart



2011/9/22 Mart Zirnask <martzirnask@gmail.com>:
> Hi,
>
> Thanks for advice.
> shell-command-on-region worked, but also provided the following in minibuffer:
>
> -------------------
> "tagcloud: Wrong number of arguments: #[(start end command &optional
> output-buffer replace error-buffer display-error-buffer) "
>
>  [error-buffer small-temporary-file-directory temporary-file-directory
> exit-status error-file replace make-temp-file expand-file-name "scor"
> nil ...] 9 1940772 (let (string) (unless (mark) (error "The mark is
> not set now, so there is no region")) (setq string (read-shell-command
> "Shell command on region: ")) (list (region-beginning) (region-end)
> string current-prefix-arg current-prefix-arg
> shell-command-default-error-buffer t))], 1
> --------------------
>
> Basically, what I want to do is to run this great script through
> Emacs: http://perlmonks.org/?node_id=707360
>
> Everything seems to work fine when I hand-type the command ("perl
> tags#.pl current-buffer-filename.txt") in eshell or Windows native
> shell launched through Emacs. But I'd like to assign  the script to a
> hotkey (using the current buffer as input for Perl), and this is where
> I'm facing problems at the moment. Might this somehow be related to
> Windows' filenames (because they include spaces)?
>
> However, a workaround would be binding my hotkey to the eshell
> command. But I haven't found reference for doing this. So, what should
> I put into my .emacs in order to launch the script via a hotkey using
> eshell?
>
> Thanks,
>
> Mart,
> in trouble, but still
>
> -------------------------------------------------
> Am 21.09.2011 14:54, schrieb Mart Zirnask:
>
>    Hello everybody,
>
>    Probably an issue not very complicated: when I try to launch an
>    external Perl script ("tags#.pl") from Emacs, providing it with the
>    current buffer name, the editor freezes.
>
>    I'm on Windows and here's what I have in my .emacs:
>
>    --------------------------------------------------------------------
>    ;; Perl tagcloud
>    (global-set-key (kbd "<f2>")
>                           (lambda ()
>                             (interactive)
>                             (shell-command (concat "perl
>    ~/.emacs.d/tags#.pl " buffer-file-name))))
>    --------------------------------------------------------------------
>
>    I'm not a programmer and I started using Emacs for text editing only
>    recently. What's wrong?
>
>    Thanks for any help,
>    best,
>    Mart Zirnask,
>    from Estonia
>
> -----------------------------
>
> Hi,
>
>
> assume the file is locked by your buffer, so if perl trys to change, it fails.
>
> BTW open Emacs and try to access the file, see what happens.
>
>
> If you want to change the current content, shell-command-on-region should 
> DTRT.
>
> HTH,
>
> Andreas
>



reply via email to

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