diff options
Diffstat (limited to 'lisp/newcomment.el')
-rw-r--r-- | lisp/newcomment.el | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 37a76e0309c..0862427c3ba 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -269,6 +269,19 @@ makes the comment easier to read. Default is 1. nil means 0." :type '(choice string integer (const nil)) :group 'comment) +(defcustom comment-inline-offset 1 + "Inline comments have to be preceded by at least this many spaces. +This is useful when style-conventions require a certain minimal offset. +Python's PEP8 for example recommends two spaces, so you could do: + +\(add-hook 'python-mode-hook + (lambda () (set (make-local-variable 'comment-inline-offset) 2))) + +See `comment-padding' for whole-line comments." + :version "24.2" + :type 'integer + :group 'comment) + ;;;###autoload (defcustom comment-multi-line nil "Non-nil means `comment-indent-new-line' continues comments. @@ -587,7 +600,7 @@ Point is expected to be at the start of the comment." (save-excursion (end-of-line) (current-column))))) (other nil) (min (save-excursion (skip-chars-backward " \t") - (if (bolp) 0 (1+ (current-column)))))) + (if (bolp) 0 (+ comment-inline-offset (current-column)))))) ;; Fix up the range. (if (< max min) (setq max min)) ;; Don't move past the fill column. @@ -687,7 +700,8 @@ If CONTINUE is non-nil, use the `comment-continue' markers if any." (save-excursion (skip-chars-backward " \t") (unless (bolp) - (setq indent (max indent (1+ (current-column)))))) + (setq indent (max indent + (+ (current-column) comment-inline-offset))))) ;; If that's different from comment's current position, change it. (unless (= (current-column) indent) (delete-region (point) (progn (skip-chars-backward " \t") (point))) |