]> code.delx.au - gnu-emacs/commitdiff
* lisp/newcomment.el (comment-inline-offset): New custom var.
authorPhilipp Haselwarter <philipp.haselwarter@gmx.de>
Sun, 25 Mar 2012 18:37:24 +0000 (14:37 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 25 Mar 2012 18:37:24 +0000 (14:37 -0400)
(comment-indent): Use it.

Fixes: debbugs:11090
lisp/ChangeLog
lisp/newcomment.el

index 581ddc3788e9b40201cdb8ad5b579ab6917bbb68..729795b9bab0d3461124723a8f7d7b66871b88c3 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-25  Philipp Haselwarter  <philipp.haselwarter@gmx.de>  (tiny change)
+
+       * newcomment.el (comment-inline-offset): New custom var (bug#11090).
+       (comment-indent): Use it.
+
 2012-02-15  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/smie.el: Provide smarter auto-filling.
index a1d77ccc6e0ffc2486a5eea72801da6f6ec97739..2d5608cb2253570697cefc305748da00cf127018 100644 (file)
@@ -268,6 +268,19 @@ makes the comment easier to read.  Default is 1.  nil means 0."
   :type '(choice string integer (const nil))
   :group 'comment)
 
+;;;###autoload
+(defcustom comment-inline-offset 1
+  "Inline comments have to be preceded by at least this many spaces.
+This is usefull 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 nil (set (make-local-variable 'comment-inline-offset) 2)))
+
+See `comment-padding' for whole-line comments."
+  :type 'integer
+  :group 'comment)
+
 ;;;###autoload
 (defcustom comment-multi-line nil
   "Non-nil means `comment-indent-new-line' continues comments.
@@ -685,7 +698,7 @@ 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)))