From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Geyslan G. Bem" Newsgroups: gmane.emacs.bugs Subject: bug#22369: 24.5; comment-style 'extra-line' doesn't correctly indent with tabs Date: Fri, 15 Jan 2016 09:11:00 -0300 Message-ID: References: <20160115115628.56863.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1452859952 17095 80.91.229.3 (15 Jan 2016 12:12:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Jan 2016 12:12:32 +0000 (UTC) Cc: 22369@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 15 13:12:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aK3Eh-00084i-W5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Jan 2016 13:12:12 +0100 Original-Received: from localhost ([::1]:46502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK3Eg-0003lk-VO for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Jan 2016 07:12:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK3Ec-0003kr-MO for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 07:12:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK3EY-0006B1-Ov for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 07:12:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK3EY-0006Ax-LM; Fri, 15 Jan 2016 07:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aK3EY-000317-A1; Fri, 15 Jan 2016 07:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Geyslan G. Bem" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 15 Jan 2016 12:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22369 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 22369-submit@debbugs.gnu.org id=B22369.145285987111535 (code B ref 22369); Fri, 15 Jan 2016 12:12:02 +0000 Original-Received: (at 22369) by debbugs.gnu.org; 15 Jan 2016 12:11:11 +0000 Original-Received: from localhost ([127.0.0.1]:49672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK3Df-0002zu-0U for submit@debbugs.gnu.org; Fri, 15 Jan 2016 07:11:11 -0500 Original-Received: from mail-vk0-f53.google.com ([209.85.213.53]:35728) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK3Dd-0002zO-K0 for 22369@debbugs.gnu.org; Fri, 15 Jan 2016 07:11:06 -0500 Original-Received: by mail-vk0-f53.google.com with SMTP id k1so297157001vkb.2 for <22369@debbugs.gnu.org>; Fri, 15 Jan 2016 04:11:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=oe+XQ2iMOvIkwnPrRVpGkdP8QSMJuR2omVcsakTFzqo=; b=cFpg52SnyWs4lgdOG/gyzPa7Gd5rRhg1iIIjKtj4OT+k8OtUqDNtVllLk9JblN2o9t u6I9CZRx6Yafao429Dgpp34cEc0ekhS8ocGwFugSoUHZTQLw3ydHr4TkG63poCzq2qZv BndZPxiwWYzCHp90yfshYFP2a1Dzn4fNLdbemOU9K7ZzGLE3Qofds8Nl0GMqUMUHes+v F0+yTzGtpPLuUi0OOwJS9qqsgKGogXqwDkU/fHnWapPUNdg6/3KN0VuSFCrdSGg0FVV+ cOVnwSJI2tMey90SeVXbyNSJVln2afHmKccFqK5XvctuTK/L2jLTioLtvJuqbYN3QlwI hmpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=oe+XQ2iMOvIkwnPrRVpGkdP8QSMJuR2omVcsakTFzqo=; b=LmLtAzOWSpw+jCVI1UwdOVkMnXc9mv9xWjyKQsMUWRysAwnRggDJ5gIeb3bVx12hue mJWB0E+V88VXKeVwxdMIDD1YN38LYSqA1DH696wfNsk0xRMHL/yHT1HoY0WcyBPJx4UD 95g9m/DOG9jhzUKLg2jttS0PzxZXF7PQecdjr7RCS+39Po4cldlfmJ2ZFY2+XL8GvS4Q IUvmXjJiWUi54u3pUYFwGuwXqGMlgw8BYVTnhLMTpePLDDLMwghWTYBnHCjGCwe2uthP RfLp8d5KaP9/jng2GLpSyXX0lFp2m+Uws70sglLi+K6GSRk0cW7mQY+3hd3Y/lFFwOGT Okog== X-Gm-Message-State: ALoCoQnxkkxxc8DC5kiYV6cyYlOGrvZgyL+V5xBxvf7VipuXfVD3v4PS1SHs4M4YU55lqezdL/Y7EzCIMW0wvKmffqd87Uj7xw== X-Received: by 10.31.162.200 with SMTP id l191mr7425520vke.69.1452859860123; Fri, 15 Jan 2016 04:11:00 -0800 (PST) Original-Received: by 10.31.47.130 with HTTP; Fri, 15 Jan 2016 04:11:00 -0800 (PST) In-Reply-To: <20160115115628.56863.qmail@mail.muc.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:111636 Archived-At: 2016-01-15 8:56 GMT-03:00 Alan Mackenzie : > Hello, Geyslan. > > In article you wrote: >> (setq c-basic-offset 8 >> tab-width 8 >> indent-tabs-mode t >> comment-style 'extra-line) >> (c-set-style "linux") > >> Using the above settings the comment-dwim (with region active) indent >> the second and last lines with spaces instead of tabs. > >> /* >> * void main() >> * { >> * int i; >> * int b; >> * printf("format string"); >> * } >> */ > > Yes. Thanks for taking the trouble to report this. The following patch > should fix this bug. After applying the patch (in .../emacs-24.5/lisp), > byte-compile the file with: > > $ emacs -Q -batch -f batch-byte-compile newcomment.el > > on the command line. If you then load the file (with M-x load-file) it > should then work. > > However, the complication is that newcomment.el is a built-in part of > Emacs rather than being a file loaded at runtime. So you then have the > choice of either putting "(load newcomment.elc)" into your .emacs, or > rebuilding Emacs entirely (which isn't that time-consuming or difficult). > To do this, in directory .../emacs-24.5, do: > > $ make > You're welcome and thank you for patching. > . > > If there are still problems with the fix, please report these to the bug > mailing list at 22369@debbugs.gnu.org. > >> For better comprehension check out this >> http://stackoverflow.com/questions/34710840/c-comment-in-emacs-linux-kernel-style-v2 > >> May I suggest the addition of a new comment-style option that does like this? > >> /* void main() >> * { >> * int i; >> * int b; >> * printf("format string"); >> * } >> */ > > OK, because of this feature request, I'll leave the bug open. This would > indeed not be difficult to implement, but it'll have to be discussed on > the developers' mailing list. Ok, I think that would be great have extra-lines (as it already is) and the suggested option named extra-bottom-line. > >> In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6) >> of 2015-09-09 on foutrelis >> Windowing system distributor `The X.Org Foundation', version 11.0.11800000 >> System Description: Arch Linux > > [ .... ] > > Here's the patch: I'll test later. Thank you so much again. > > > --- newcomment.el~ 2015-04-02 07:23:06.000000000 +0000 > +++ newcomment.el 2016-01-15 11:41:24.912588709 +0000 > @@ -969,6 +969,14 @@ > (goto-char (point-max)))))) > (set-marker end nil)) > > +(defun comment-make-bol-ws (len) > + "Make a white-space string of width LEN for use at BOL. > +When `indent-tabs-mode' is non-nil, tab characters will be used." > + (if (and indent-tabs-mode (> tab-width 0)) > + (concat (make-string (/ len tab-width) ?\t) > + (make-string (% len tab-width) ? )) > + (make-string len ? ))) > + > (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block) > "Make the leading and trailing extra lines. > This is used for `extra-line' style (or `box' style if BLOCK is specified)." > @@ -1004,8 +1012,8 @@ > (setq cs (replace-match fill t t s))) > (string-match re e) > (setq ce (replace-match fill t t e)))) > - (cons (concat cs "\n" (make-string min-indent ? ) ccs) > - (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce)))) > + (cons (concat cs "\n" (comment-make-bol-ws min-indent) ccs) > + (concat cce "\n" (comment-make-bol-ws (+ min-indent eindent)) ce)))) > > (defmacro comment-with-narrowing (beg end &rest body) > "Execute BODY with BEG..END narrowing. > > > -- > Alan Mackenzie (Nuremberg, Germany). > -- Regards, Geyslan G. Bem hackingbits.com