Force stop or halt on error

2019-03-15 23:07发布

I was wondering if anyone knew of a good way to get R or ESS to stop executing the rest of the code beyond the point at which an error occurs if I am evaluating a region or buffer (I've only found the opposite request in the help archives). I was looking in the R help files but option(error=stop) will only stop execution of the offending function or statement but not those that follow it. Thanks!

标签: r emacs ess
3条回答
▲ chillily
2楼-- · 2019-03-15 23:41

According to the ESS manual, this should work: C-c C-c (comint-interrupt-subjob) Sends a Control-C signal to the ESS process. This has the effect of aborting the current command.

John Fox has a website where he offers a configuration for ESS. In it, he has this function:

(defun stop-R ()

"Interrupt R process in lower window."

(interactive)

(select-window win2)

(comint-interrupt-subjob)

(select-window win1))

You should be able to add this function to the menu in XEmacs using:

(defun R-menu ()

  "Hook to install R menu and sub-menus"

  (add-menu-item '("ESS" "R") "Interrupt computation" 'stop-R
)
)
(add-hook 'ess-mode-hook 'R-menu)

You might check out the rest of his configuration file and documentation to see if it interests you. I haven't tried this yet, but I hope that it works for you!

Charlie

查看更多
小情绪 Triste *
3楼-- · 2019-03-16 00:00

If R/ESS is hogging up so much compute time that your emacs/ESS is unresponsive to C-c C-c, you can also save it by sending an INTERRUPT signal from the terminal.

First: figure out R's processID using top or ps. (mine was 98490 Then: kill -2 98490 That sends an interrupt signal and you get your ESS/Emacs and R session back

查看更多
走好不送
4楼-- · 2019-03-16 00:05

?break

Only gets you out of loop.

?try

Lets you set up code that might fail and gracefully recover.

查看更多
登录 后发表回答