我已经编写了一些附加到Perl键和F6键的函数,以便在按下时,这些函数可以计算F5或Python键的缓冲区内容。
;; F5 = perlevaluatie
(defun perl-eval ()
"Run whole buffer as Perl code"
(interactive)
(shell-command-on-region (point-min) (point-max) "perl") ; feeds the region to perl on STDIN
)
(global-set-key (kbd "<f5>") 'perl-eval)
;; F6 = pythonevaluatie
(defun python-eval ()
"Run whole buffer as Python code"
(interactive)
(shell-command-on-region (point-min) (point-max) "python")
)
(global-set-key (kbd "<f6>") 'python-eval)但是,当我将这些函数用于长时间运行的脚本时,emacs挂起。附加一个&并不像shell-command函数那样有帮助。有谁知道让shell-command-on-region异步的方法吗?
提前谢谢你,
马丁
发布于 2014-09-02 15:27:53
我使用compile:M-x compile,perl <file-name>。在第一次运行之后,您可以使用重新编译来重新运行它。
输入文件名的时间稍微多一点,但是你得到了很多有用的东西,当然,它是异步的。
编辑: Bonus helper函数自动使用第一次编译,然后重新编译:
(defun my-recompile ()
"Recompile if possible, otherwise compile current buffer."
(interactive)
;; If recompile exists do it, else compile
(if (fboundp 'recompile) (recompile)
(compile "make -k")))并在适当的钩子中绑定类似于
(local-set-key (kbd "<f5>") 'my-recompile)
(local-set-key (kbd "<C-f5>") 'compile)https://stackoverflow.com/questions/25597958
复制相似问题