Subject: bug#11090: closed (Re: bug#11090: 24.0.94; Allow customization of inline-comment offset)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 25 Mar 2012 19:13:01 +0000

Your bug report

#11090: 24.0.94; Allow customization of inline-comment offset

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
11090: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11090
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#11090: 24.0.94; Allow customization of inline-comment offset
From: Stefan Monnier <[email-masked]>
To: Philipp Haselwarter <[email-masked]>
Cc: [email-masked]
Date: Sun, 25 Mar 2012 14:41:27 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> The attached patch allows for `comment-indent' to configure that offset,
> that is currently hard-coded to one space, by introducing the new
> variable `comment-inline-offset'.

I think it's a good idea, thank you.
Installed in the `pending' branch, for 24.2.
I also installed the following patch on top of it.

        Stefan

=== modified file 'lisp/newcomment.el'
--- lisp/newcomment.el	2012-03-25 18:37:24 +0000
+++ lisp/newcomment.el	2012-03-25 18:38:46 +0000
@@ -268,7 +268,6 @@
   :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.
@@ -598,7 +597,7 @@
                    (save-excursion (end-of-line) (current-column)))))
         (other nil)
         (min (save-excursion (skip-chars-backward " \t")
-                             (1+ (current-column)))))
+                             (+ comment-inline-offset (current-column)))))
     ;; Fix up the range.
     (if (< max min) (setq max min))
     ;; Don't move past the fill column.
@@ -698,7 +697,8 @@
 	  (save-excursion
 	    (skip-chars-backward " \t")
 	    (unless (bolp)
-	      (setq indent (max indent (+ (current-column) comment-inline-offset)))))
+	      (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)))

Subject: 24.0.94; Allow customization of inline-comment offset
From: Philipp Haselwarter <[email-masked]>
To: [email-masked]
Date: Sun, 25 Mar 2012 18:52:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

When I ran pep8 over some python code it indicated that the offset
between code and comments on the same line should be at least two
whitespace characters.
Ref.:
http://www.python.org/dev/peps/pep-0008/#inline-comments

The attached patch allows for `comment-indent' to configure that offset,
that is currently hard-coded to one space, by introducing the new
variable `comment-inline-offset'.

The default behavior remains unchanged.

-- 
Philipp Haselwarter
>From 15e86f0b218b7a1bd32426c71bad930208e5606a Mon Sep 17 00:00:00 2001
From: Philipp Haselwarter <[email-masked]>
Date: Sun, 25 Mar 2012 18:32:11 +0200
Subject: [PATCH] Allow customization of the offset between code and
 inline-comments.

* lisp/newcomment.el (comment-inline-offset): New variable.
(comment-indent): Honor comment-inline-offset.
---
 lisp/newcomment.el |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 40bb36d..c78a3a1 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -270,6 +270,19 @@ makes the comment easier to read.  Default is 1.  nil means 0."
   :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.
 That is, it inserts no new terminator or starter.
@@ -687,7 +700,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)))
-- 
1.7.9.4