From: Alan Mackenzie <acm@muc.de>
To: "Geyslan G. Bem" <geyslan@gmail.com>
Cc: 22369@debbugs.gnu.org
Subject: bug#22369: 24.5; comment-style 'extra-line' doesn't correctly indent with tabs
Date: 15 Jan 2016 11:56:28 -0000 [thread overview]
Message-ID: <20160115115628.56863.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.2326.1452736388.843.bug-gnu-emacs@gnu.org>
Hello, Geyslan.
In article <mailman.2326.1452736388.843.bug-gnu-emacs@gnu.org> 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
.
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.
> 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:
--- 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).
next prev parent reply other threads:[~2016-01-15 11:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-14 1:44 bug#22369: 24.5; comment-style 'extra-line' doesn't correctly indent with tabs Geyslan G. Bem
[not found] ` <mailman.2326.1452736388.843.bug-gnu-emacs@gnu.org>
2016-01-15 11:56 ` Alan Mackenzie [this message]
2016-01-15 12:11 ` Geyslan G. Bem
2020-09-17 17:38 ` Lars Ingebrigtsen
2020-09-17 19:21 ` Alan Mackenzie
2022-01-29 17:01 ` Lars Ingebrigtsen
2016-01-15 12:42 ` Alan Mackenzie
[not found] ` <20160115124231.67454.qmail@mail.muc.de>
2016-01-15 21:59 ` Geyslan G. Bem
[not found] ` <CAGG-pUQ8yN-VDKkfFq2-34PWfrpLtbSjRVXuJ_cQk8z-Edw=SQ@mail.gmail.com>
2016-01-18 11:14 ` Geyslan G. Bem
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160115115628.56863.qmail@mail.muc.de \
--to=acm@muc.de \
--cc=22369@debbugs.gnu.org \
--cc=geyslan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.