Emacs set spacing for inline (end of line) comments

The python PEP 8 style guide recommends that inline comments be separated by two spaces between the rest of the line . However, Emacs defaults to starting comment-dwimor indent-for-commentplacing only one space between the end of the line and the comment. Is there a way to change this default behavior in emacs?

I am running Emacs 23.3.1

+5
source share
4 answers

This should do what you want:

   (add-hook 'python-mode-hook
      (lambda () (set (make-local-variable 'comment-inline-offset) 2)))
+5
source

Try to set comment-startto " # "(one space before, one basement).

M-x set-variable comment-start " # "
+1
source

, , :

(defun my-comment-indent ()
  (interactive)
  (end-of-line)
  (let ((comment-column (+ 2 (current-column))))
    (comment-indent)))
+1

emacs C-h v RET comment-inline-offset, @And.

Here's a simplified version:

(add-hook 'python-mode-hook
  (lambda () (setq-local comment-inline-offset 2)))
+1
source

All Articles