我正在学习如何在 Emacs 中使用 Perl。我曾经用 R-Studio 运行 R。
如何在不离开 Emacs 的情况下执行命令?
示例:在 R-studio 我输入
print("hello world")
然后按 Ctrl+Enter 和 R-studio 执行命令并打印
"hello world"
.如何在 Emacs 中为 Perl 命令执行相同的操作?
我通常输入 Ctrl+X Ctrl+F test.pl
print "hello world";
然后我不知道该怎么做才能让 Emacs 执行命令。
最佳答案
对于各种解释性语言,我使用 isend-mode ,它允许将缓冲区的一部分发送到另一个缓冲区中的终端。
以下是您将如何使用它(安装后):
ansi-term
缓冲:M-x
ansi-term
返回 /bin/bash
可再生能源并在里面运行一个交互式 perl session :
perl -d -e 42
返回或者,安装 term-run.el并在
term
中直接启动交互式 perl session 缓冲:M-x
term-run-shell-command
返回 perl -d -e 42
返回 M-x
isend
返回 *ansi-term*
返回 ansi-term
中的解释器缓冲。如果区域处于事件状态,则将发送跨越该区域的所有线路。 下面是一个建议的设置,可以更好地利用 perl 调试器特定的命令。通过以下自定义,
x
除了 print
之外的所有指令(以便您看到结果)都前置命令。(defun isend--perl (buf-name)
"Prepend 'x ' to normal perl instructions.
Leave 'print' instructions untouched."
(with-current-buffer buf-name
(goto-char (point-min))
(unless (looking-at "[[:space:]]*print")
(insert "x ")))
(insert-buffer-substring buf-name))
(defun isend-default-perl-setup ()
(when (eq major-mode 'perl-mode)
(set (make-local-variable 'isend-send-line-function) #'isend--perl)))
(add-hook 'isend-mode-hook #'isend-default-perl-setup)
关于perl - 在 Emacs 中执行 Perl,最基本的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13631915/