我已經寫了一些函數附加到我的F5和F6鍵,以便按下時,這些函數評估perl或python的緩衝區內容。異步評估整個python或perl緩衝區
;; 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
異步?
由於提前,
貂
你看看[quickrun]( https://github.com/syohex/emacs-quickrun)?我發現在emacs上測試我的腳本非常方便。 – ale 2014-09-01 07:14:51
您不能在emacs 24.3.1中異步使用'shell-command-on-region'。在那裏,只有使用同步的命令「call-process-region」才能調用shell。要有一個異步命令,你需要'start-process'和sentinels來觀察啓動進程的執行情況。一個有趣的問題是:如果在腳本運行期間修改了輸入區域,會發生什麼情況? – Tobias 2014-09-01 10:24:22