GNU bug report logs - #21921
New function comment-line also comments first line after region

Previous Next

Package: emacs;

Reported by: Clément Pit--Claudel <clement.pitclaudel <at> live.com>

Date: Sat, 14 Nov 2015 18:25:02 UTC

Severity: minor

Tags: notabug, wontfix

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Rasmus <rasmus <at> gmx.us>
To: 21921 <at> debbugs.gnu.org
Subject: bug#21921: New function comment-line also comments first line after region
Date: Sun, 15 Nov 2015 12:45:02 +0100
Hi Clément,

Thanks for details report.

Clément Pit--Claudel <clement.pitclaudel <at> live.com> writes:

> Its documentation says:
>
>   If region is active, comment lines in active region instead.
>
> However, it seems that it also comments out the line just after the end
> of the region.
>
> For example, given the following text
>
> abc
> def
> ghi
>
> Placing the cursor before `a', then pressing C-SPC C-n C-n, causes two
> lines to be marked: (> is highlighting, | is point)
>
>>abc
>>def
> |ghi
>
> Yet pressing C-x C-; (comment-region) comments out all three lines.

Because the end of region is at point.  Try to run this:

        (list (point)  (region-beginning) (region-end))

Also, from the docstring,

      Unlike ‘comment-dwim’, this always comments whole lines.

You'd get what you'd expect if you run comment-dwim (M-;)

> Similarly, again starting from 
>
> abc
> def
> ghi
>
> placing the point before `g' and pressing C-SPC C-p C-p causes two lines
> to be marked:

Again, in fact the region start at 'g'.  Check e.g. with C-x C-x.  But
it's not obvious from the face.

>>|abc
>>def
> ghi
>
> Yet pressing C-x C-; comments out all three lines. I find this second example especially confusing.
>
> Is this behaviour only surprising to me?

Perhaps the confusion is caused by region not being displayed at column
zero.

The behavior is correct IMO.

For your particular examples, comment-dwim does what you want, it seems.

Hope it helps,
Rasmus

-- 
Spil noget med Slayer!





This bug report was last modified 8 years and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.