更改 emacs 中 R 会话中的 home 键行为

发布于 2024-12-03 23:44:16 字数 185 浏览 1 评论 0原文

我想更改从 emacs 运行的 R 会话中 home 键的行为。当我按下 home 键时,它会一直显示 > 提示符。我希望使用主页键将我带到命令条目的开头(即从行开头开始的两个点)。我假设我可以通过我的 .emacs 文件进行此调整;对于我需要添加到该文件中的命令的任何指导,我们将不胜感激。谢谢!

I would like to change the behavior of the home key within an R session run from emacs. When I press the home key, it takes me all the way to the > prompt. I'd like the home key to take me to the start of the command entry (i.e., two points in from the start of the line). I assume that I can make this adjustments via my .emacs file; any guidance for the commands that I would need to add to that file would be appreciated. Thanks!

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

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

发布评论

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

评论(1

飞烟轻若梦 2024-12-10 23:44:16

您想要的行为已作为 Ca 提供。您可以使用以下行重新绑定 home 键:

(local-set-key (kbd "<home>") 'comint-bol)

当您使用 R 会话时,有多种方法可以自动实现此操作。我使用如下内容:

;; Define the keybinding you want
(defun my-inferior-ess-mode-hook ()
  (local-set-key (kbd "<home>") 'comint-bol))

;; add the key-binding to the hook that gets called whenever you start an R session:
(add-hook 'inferior-ess-mode-hook 'my-inferior-ess-mode-hook)

这对于单个键绑定来说有点多,但您可以扩展 my-inferior-ess-mode-hook 的定义以包含您需要的许多自定义项喜欢用。

The behaviour you want is already available as C-a. You can rebind the home key with the following line:

(local-set-key (kbd "<home>") 'comint-bol)

There are a number of ways to get this to happen automatically when you are using the R session. I use something like the following:

;; Define the keybinding you want
(defun my-inferior-ess-mode-hook ()
  (local-set-key (kbd "<home>") 'comint-bol))

;; add the key-binding to the hook that gets called whenever you start an R session:
(add-hook 'inferior-ess-mode-hook 'my-inferior-ess-mode-hook)

That's a bit much for a single key-binding, but you can extend the definition of my-inferior-ess-mode-hook to include a number of customizations you'd like to use.

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