Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion bug#11090: 24.0.94; Allow customization of inline-comment offset

Received: by 10.68.236.170 with SMTP id uv10mr10234259pbc.4.1332802778292;
        Mon, 26 Mar 2012 15:59:38 -0700 (PDT)
Path: z9ni5287pbe.0!nntp.google.com!news1.google.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From: Philipp Haselwarter <philipp.haselwar...@gmx.de>
Newsgroups: gnu.emacs.bug
Subject: bug#11090: 24.0.94; Allow customization of inline-comment offset
Date: Sun, 25 Mar 2012 18:52:35 +0200
Lines: 79
Sender: debbugs-submit-boun...@debbugs.gnu.org
Approved: bug-gnu-em...@gnu.org
Message-ID: <mailman.1655.1332695153.753.bug-gnu-emacs@gnu.org>
NNTP-Posting-Host: lists.gnu.org
Mime-Version: 1.0
X-Trace: usenet.stanford.edu 1332802777 12207 208.118.235.17 (26 Mar 2012 22:59:37 GMT)
X-Complaints-To: action@cs.stanford.edu
To: 11...@debbugs.gnu.org
Envelope-to: bug-gnu-em...@gnu.org
X-Loop: help-debb...@gnu.org
Resent-From: Philipp Haselwarter <philipp.haselwar...@gmx.de>
Original-Sender: debbugs-submit-boun...@debbugs.gnu.org
Resent-CC: bug-gnu-em...@gnu.org
Resent-Date: Sun, 25 Mar 2012 17:25:01 +0000
Resent-Message-ID: <handler.11090.B.133269625128...@debbugs.gnu.org>
Resent-Sender: help-debb...@gnu.org
X-GNU-PR-Message: report 11090
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
X-Debbugs-Original-To: bug-gnu-em...@gnu.org
X-Authenticated: #26138819
X-Provags-ID: V01U2FsdGVkX18BRCsL+EAB0AJW5JoEpHHVxTLheV+EJ0CMuXtew9
	I2Os6sJdfwnPpR
X-NSA-Fodder: Rand Corporation Sundevil Syria AMW espionage PET Defcon argus
X-Y-GMX-Trusted: 0
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-BeenThere: debbugs-sub...@debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
Errors-To: debbugs-submit-boun...@debbugs.gnu.org
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.43
X-BeenThere: bug-gnu-em...@gnu.org
List-Id: "Bug reports for GNU Emacs,
	the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-requ...@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-em...@gnu.org>
List-Help: <mailto:bug-gnu-emacs-requ...@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-requ...@gnu.org?subject=subscribe>
Content-Type: multipart/mixed;
	boundary="Skipjack/asset/computer-terrorism/White-Water/xncJ2WzDoi"

--Skipjack/asset/computer-terrorism/White-Water/xncJ2WzDoi
Content-Type: text/plain



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

--Skipjack/asset/computer-terrorism/White-Water/xncJ2WzDoi
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Allow-customization-of-the-offset-between-code-and-i.patch

>From 15e86f0b218b7a1bd32426c71bad930208e5606a Mon Sep 17 00:00:00 2001
From: Philipp Haselwarter <philipp.haselwar...@gmx.de>
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


--Skipjack/asset/computer-terrorism/White-Water/xncJ2WzDoi--