0

In Emacs using ESS for editing R files, want to stop this from happening when I hit enter:

auto indentation

I understand convention is to use ### for left-aligned comments, ## for block-aligned comments, and # for these right-adjusted comments, per here, but I'm looking to disable the latter.

I understand from other answers, it is common to encourage simply not using single comments #, but how would I achieve this anyway?

This is in my 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)))

which I have seen recommended as a way of disabling this, but still I see the behavior above in my gif.

Mittenchops
  • 18,633
  • 33
  • 128
  • 246

1 Answers1

1

According to the manual:

Finally, comments beginning with ‘#’ are aligned to a column on the right (the 40th column by default, but this value is controlled by the variable comment-column,) or just after the expression on the line containing the comment if it extends beyond the indentation column. You turn off the default behavior by adding the line (setq ess-indent-with-fancy-comments nil) to your .emacs file.

I suggest you work in something like this into your emacs config:

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

I set this in my spacemacs config and when I started emacs again the problem went away.

I am running this with Emacs 26.3, ESS 20200312, and very recent spacemacs.

Russia Must Remove Putin
  • 374,368
  • 89
  • 403
  • 331