首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >异步计算整个python或perl缓冲区

异步计算整个python或perl缓冲区
EN

Stack Overflow用户
提问于 2014-09-01 09:55:49
回答 1查看 197关注 0票数 2

我已经编写了一些附加到Perl键和F6键的函数,以便在按下时,这些函数可以计算F5或Python键的缓冲区内容。

代码语言:javascript
复制
;; 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异步的方法吗?

提前谢谢你,

马丁

EN

回答 1

Stack Overflow用户

发布于 2014-09-02 15:27:53

我使用compileM-x compileperl <file-name>。在第一次运行之后,您可以使用重新编译来重新运行它。

输入文件名的时间稍微多一点,但是你得到了很多有用的东西,当然,它是异步的。

编辑: Bonus helper函数自动使用第一次编译,然后重新编译:

代码语言:javascript
复制
(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")))

并在适当的钩子中绑定类似于

代码语言:javascript
复制
(local-set-key (kbd "<f5>") 'my-recompile)
(local-set-key (kbd "<C-f5>") 'compile)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25597958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档