* bug#15573: 24.3.50; `comment-end' in c mode
@ 2013-10-09 15:55 Drew Adams
2013-10-09 18:17 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2013-10-09 15:55 UTC (permalink / raw)
To: 15573
I don't work in C anymore, but I recently noticed that `comment-end' for
C mode seems to be " */", not "*/". That presumably makes sense for the
use of `comment-end' as "String to insert to end a new comment.", per
the doc string.
But `comment-end' can also be used to recognize the end of a comment,
and in that case I would think that "*/", not " */", would be
appropriate for C.
Case in point: I have some code that does this:
(while (and (< start end) (setq cbeg (comment-search-forward end 'NOERROR)))
(setq cend (if (string= "" comment-end)
(min (1+ (line-end-position)) (point-max))
(search-forward comment-end end 'NOERROR)))
(when (and cbeg cend)...))
But that fails to DTRT with a comment such as this, because `comment-end'
is not found:
/*
Some comment.
*/
So my question is whether `comment-end' should not perhaps be "*/" for C
code.
I do realize that `comment-skip' is available. Perhaps I should just
use that somehow in my code, above? Advice welcome.
I also see that there is `comment-padding', and that "the strings used
as comment ends are built from `comment-end' and `comment-padding'" (doc
string of `comment-region'). Perhaps `comment-end' should be "*/" and
`comment-padding' as " " should be used with it to do what is done now
using " */" as `comment-end' (and "" as `comment-padding')?
Presumably, since lots of people have been using this for a long time, I
just have something to learn wrt my code, above. Again, please let me
know. Thx.
In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
of 2013-09-30 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15573: 24.3.50; `comment-end' in c mode
2013-10-09 15:55 bug#15573: 24.3.50; `comment-end' in c mode Drew Adams
@ 2013-10-09 18:17 ` Stefan Monnier
[not found] ` <52565D50.5070706@easy-emacs.de>
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-10-09 18:17 UTC (permalink / raw)
To: Drew Adams; +Cc: 15573-done
> But `comment-end' can also be used to recognize the end of a comment,
No: that's what comment-end-skip is for.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15573: 24.3.50; `comment-end' in c mode
[not found] ` <jwvwqiruh77.fsf-monnier+emacsbugs@gnu.org>
@ 2013-12-28 17:09 ` Drew Adams
[not found] ` <b63dc9a7-7c49-4cd4-b256-8be93a5a6dea@default>
1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2013-12-28 17:09 UTC (permalink / raw)
To: 15573
> > There seems to be no good regexp variable to use, to search for the
> > end of a comment (e.g. in C mode, but therefore generally).
>
> There can't be. The syntax of the end of a comment depends on the
> comment-starter that was used. So don't look for a regexp. Look for
> a function instead, e.g. comment-forward.
Actually, that's what I have been using, `comment-search-forward' and
`comment-forward'.
> C also accepts //...\n
Right. Forgot about that.
I still don't see why `comment-end' should not match "*/" without
a SPC preceding it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#15573: 24.3.50; `comment-end' in c mode
[not found] ` <b63dc9a7-7c49-4cd4-b256-8be93a5a6dea@default>
@ 2014-01-02 2:45 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-01-02 2:45 UTC (permalink / raw)
To: Drew Adams; +Cc: 15573
> I still don't see why `comment-end' should not match "*/" without
comment-end doesn't *match* anything. It's a string that is meant to be
inserted in a buffer. It's not a regular expression, "substring
pattern", or something to which things are "matched".
It's very much correct for the user to set comment-end to "-- TOTO */"
if she so wishes.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-02 2:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-09 15:55 bug#15573: 24.3.50; `comment-end' in c mode Drew Adams
2013-10-09 18:17 ` Stefan Monnier
[not found] ` <52565D50.5070706@easy-emacs.de>
[not found] ` <e6ecb48c-3d29-44b7-bfd2-49be3ee6aeaa@default>
[not found] ` <jwvwqiruh77.fsf-monnier+emacsbugs@gnu.org>
2013-12-28 17:09 ` Drew Adams
[not found] ` <b63dc9a7-7c49-4cd4-b256-8be93a5a6dea@default>
2014-01-02 2:45 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).