【问题标题】:Disable ESS fancy comments with R用 R 禁用 ESS 花哨的评论
【发布时间】:2019-07-12 08:18:13
【问题描述】:

在使用 ESS 编辑 R 文件的 Emacs 中,当我按下回车键时想要阻止这种情况发生:

我理解惯例是使用### 用于左对齐的 cmets,## 用于块对齐的 cmets,# 用于这些右对齐的 cmets,per here,但我希望禁用后者。

I understand from other answers, it is common to encourage simply not using single comments #,但是我要如何实现呢?

这是在我的 init.el 中:

(setq ess-smart-S-assign-key nil)
;; (ess-toggle-S-assign nil)
(setq ess-indent-with-fancy-comments nil)
(setq ess-fancy-comments nil)

(require 'ess)
(show-paren-mode 1)
;; (autoload 'R-mode "ess-site.el" "" t)
(add-to-list 'auto-mode-alist '("\\.R\\'" . R-mode))
;; (ess-toggle-underscore nil)

(defun my-ess-settings ()
  (setq ess-indent-with-fancy-comments nil))
(add-hook 'ess-mode-hook #'my-ess-settings)

(add-hook 'ess-mode-hook
          (lambda ()
            (local-set-key (kbd "RET") 'newline)))

我已经看到推荐作为禁用此功能的一种方式,但我仍然在我的 gif 中看到上述行为。

【问题讨论】:

  • 您是否添加了setq 命令之前 (require 'ess)
  • 我都跑过,效果一样。
  • 这不是可重现的,使用emacs -Q 运行一个裸 emacs 打开一个 R 文件,这不会发生。您似乎启用了某种电子缩进选项

标签: r emacs ess


【解决方案1】:

根据manual

最后,以'#'开头的cmets对齐到右边的一列(默认是第40列,但是这个值是由变量comment-column控制的)或者就在包含注释的行的表达式之后如果它超出缩进列。 您可以通过将(setq ess-indent-with-fancy-comments nil) 行添加到您的.emacs 文件来关闭默认行为。

我建议你在你的 emacs 配置中这样工作:

(setq ess-indent-with-fancy-comments nil)

我在我的 spacemacs 配置中设置了这个,当我再次启动 emacs 时问题就消失了。

我正在使用 Emacs 26.3、ESS 20200312 和最近的 spacemacs 运行它。

【讨论】:

  • 您可以在问题中看到这已经包含在我的 emacs 配置中。
  • @Mittenchops 你在运行什么版本的东西?
猜你喜欢
  • 1970-01-01
  • 2010-10-21
  • 1970-01-01
  • 1970-01-01
  • 2011-03-03
  • 1970-01-01
  • 2010-12-22
  • 1970-01-01
相关资源
最近更新 更多