Extend Emacs for easy execution of Perl programs

xiaoxiao2021-03-06  25

When writing the Perl program with Emacs, there is a shortcut to run the Perl program that is writing directly, it is very convenient.

Add the following code to ~ / .emacs, the Perl program you are writing can use M-O to run.

(Defun RunperL ()

"Run Perl, execute the Perl program of the current buffer"

(Interactive)

Save-buffer

(LET (FileName Buffer-file-name)

(cmd ")

(Current-buffer)

(End (Point-max)))))

(if FileName

Save-buffer

(Save-ExcURSION

(SetQ filename (Concat (GetENV "TMP") "/TEMP.PL"))

(Set-buffer (Create-file-buffer filename))

(INSERT-BUFFER-SUBSTRING OLDBUF 1 END)

(Write-file filename)

(Current-buffer))))))))

(SetQ cmd (control "perl -w" filename))

(Message "% s ..." cmd)

(Shell-Command CMD))))))

(GLOBAL-SET-Key [(Meta O)] 'Runperl); Bind-Key Alt O: Runperl

转载请注明原文地址:https://www.9cbs.com/read-40601.html

New Post(0)