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

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

Re: What does 'run' do in cperl-mode?


From: Xah
Subject: Re: What does 'run' do in cperl-mode?
Date: Fri, 25 Jul 2008 07:55:29 -0700 (PDT)
User-agent: G2/1.0

On Jul 24, 10:36 am, formido <form...@gmail.com> wrote:
> So, I've got:
>
> print "Hello World\n";
>
> ... in the buffer and it's saved. I can use the debugger command to
> run it. Strangely to me, 'run' is disabled. What does 'run' do? In
> other IDEs I've used, I type some code, then I either compile or don't
> depending on the language, and then I run. What's different here?

I don't know. But you can run it by typing Alt+x shell-command
(shortcut Alt+x !) then type “perl ‹filename›”.

Or, you can write a short elisp so that pressing a key will run the
program in current buffer.

(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, bash, java.
File suffix is used to determine what program to run."
(interactive)
  (let (ext-map file-name file-ext prog-name cmd-str)
; get the file name
; get the program name
; run it
    (setq ext-map
          '(
            ("php" . "php")
            ("pl" . "perl")
            ("py" . "python")
            ("sh" . "bash")
            ("java" . "javac")
            )
          )
    (setq file-name (buffer-file-name))
    (setq file-ext (file-name-extension file-name))
    (setq prog-name (cdr (assoc file-ext ext-map)))
    (setq cmd-str (concat prog-name " " file-name))
    (shell-command cmd-str)))


(global-set-key (kbd "<f7>") 'run-current-file)

for detail, see:
http://xahlee.org/emacs/elisp_run_current_file.html


> More generally, when confronted by a menu command, how can I easily go
> to its definition?

Type Alt+x describe-key, then pull the menu. Then, you'll get the
command name run by that menu. Then, type Alt+x describe-function.
It'll pop up the online doc of the function with link to the source
code where the function is defined.

  Xah
∑ http://xahlee.org/

reply via email to

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