diff options
author | Glenn Morris <rgm@gnu.org> | 2012-04-16 20:06:56 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2012-04-16 20:06:56 -0700 |
commit | 2311d8e5a62b8b6dd7dde45b4b8059d443e2abac (patch) | |
tree | 9e526bc6f88f88c2925e05db797570cbc5ad7ee2 /lisp/newcomment.el | |
parent | fc72b15c777af496e9dcbc240f424135379ba955 (diff) | |
parent | 699c782b7668c44d0fa4446331b0590a6d5dac82 (diff) | |
download | emacs-2311d8e5a62b8b6dd7dde45b4b8059d443e2abac.tar.gz emacs-2311d8e5a62b8b6dd7dde45b4b8059d443e2abac.tar.bz2 emacs-2311d8e5a62b8b6dd7dde45b4b8059d443e2abac.zip |
Merge from pending; try to fix-up suboptimal ses ChangeLog.
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))) |