ESS:ess-request-a-process 默认为“S”

发布于 2024-10-06 06:26:15 字数 1526 浏览 4 评论 0原文

我经常发现自己有一堆 R 进程在 ESS 缓冲区中运行。有一个方便的 Lisp 函数 ess-request-a-process 可以请求 R 进程,并将其置于前面。唯一的缺点是它以某种方式默认为S,所以每次我要进行切换时,我都必须输入R,令人恶心。

我尝试自定义 ess-language 变量,但即使我将值设置为“R”,即当前会话的 4,或者即使我保存未来会话的设置,只要我输入 Cc CkS 自动再次出现。这非常烦人,我真的不想以 Cx Cb 结束,然后以 Cs 进行所需的 R 会话! =)

我什至尝试在 .emacs 中设置 (setq-default ess-language "R") ,但没有运气......

顺便说一句,我正在运行 Emacs v Linux Mint 上的 23.1.1 和 Arch Linux 上的 Emacs v. 23.2,以及 ESS v. 5.12。如果相关的话,我会使用 -nw 参数从终端运行 Emacs。这是我的 .emacs

;; start server
(server-start)

;; load ESS
(require 'ess-site)
(require 'ess-rutils)

;; set HTML help as default
(setq inferior-ess-r-help-command "help(\"%s\", help_type = \"html\")\n")

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(ess-help-kill-bogus-buffers t)
 '(ess-rutils-keys nil)
 '(show-paren-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
(put 'upcase-region 'disabled nil)

那么...如何一劳永逸地设置 R ? (我不使用 S/S+/SAS)

Quite often I find myself with bunch of R processes running in ESS buffers. There's a convenient Lisp function ess-request-a-process that asks for R process, and brings it to front. The only downside is that it somehow defaults to S, so each time I'm about to make a switch, I have to type R, ad nauseam.

I tried customising the ess-language variable, but even if I set value to "R", i.e. 4 for current session, or even if I save settings for future session, as soon as I type C-c C-k, automagically S appears once again. It's very annoying, and I really don't want to end up with C-x C-b and then C-s for desired R session! =)

I even tried setting (setq-default ess-language "R") in .emacs, but with no luck...

BTW, I'm running Emacs v. 23.1.1 on Linux Mint and Emacs v. 23.2 on Arch Linux, with ESS v. 5.12. If that's relevant, I run Emacs from terminal with -nw argument. Here's my .emacs:

;; start server
(server-start)

;; load ESS
(require 'ess-site)
(require 'ess-rutils)

;; set HTML help as default
(setq inferior-ess-r-help-command "help(\"%s\", help_type = \"html\")\n")

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(ess-help-kill-bogus-buffers t)
 '(ess-rutils-keys nil)
 '(show-paren-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
(put 'upcase-region 'disabled nil)

So... how to set R once and for all? (I don't use S/S+/SAS)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的他你的她 2024-10-13 06:26:15

到目前为止我还不知道这个功能。 Cc Ck 绑定到 ESS 缓冲区中的 ess-force-buffer-current

[编辑:Cc Ck确实绑定到iESS中的ess-request-a-process,在ESS中它是ess-force-buffer-current]

在任何情况下,您的变量必须自定义的是 ess-dialect

(setq-default ess-dialect "R")

它是缓冲区本地变量,ess-mode-hook 中的其他一些内容可能会将其设置为不同的值。

使用 Ch v 在每个缓冲区中检查它 ess-dialect

另外,如果您已经运行多个进程,则 ess-switch-process (抄送 Cs)可能是正确的方法。
[编辑:它不会跳转到进程,而只是重置当前 ESS 缓冲区的关联进程]

[编辑:在深入研究这个问题后,发现 ess-request-a-process 使用ess-language 变量是 ess-dialect 似乎更合适。问题是,每次 ess-inferior 进程启动时,它都会重置 ess-language 的全局值。这就是为什么将其设置在您的情况下不起作用的原因。

这是一个快速修复:

(defun ess-set-language ()
  (setq-default ess-language "R")
  (setq ess-language "R")
  )

(add-hook 'ess-post-run-hook 'ess-set-language t)

]

I did not know about this function so far. C-c C-k is bound to ess-force-buffer-current in ESS buffers.

[edit: C-c C-k is indeed bound to ess-request-a-process in iESS, in ESS it's ess-force-buffer-current]

In any case the variable you have to customize is ess-dialect

(setq-default ess-dialect "R")

It's buffer-local variable and some other stuff in ess-mode-hook might set it a different value.

Check it in each buffer with C-h v ess-dialect

Additionally, if you already running several processes then ess-switch-process (C-c C-s) might be the right way to go.
[edit: it will not jump to a process but just reset the associated process of the current ESS buffer]

[edit: After dwelling deeper on the issue it turned out that ess-request-a-process uses ess-language variable were the ess-dialect seems to be more appropriate. The problem is that each time an ess-inferior process starts it resets the global value of ess-language. This is why setting it in your case didn't work.

Here is a quick fix:

(defun ess-set-language ()
  (setq-default ess-language "R")
  (setq ess-language "R")
  )

(add-hook 'ess-post-run-hook 'ess-set-language t)

]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文