bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21921: New function comment-line also comments first line after regi


From: Rasmus
Subject: bug#21921: New function comment-line also comments first line after region
Date: Sun, 15 Nov 2015 12:45:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi Clément,

Thanks for details report.

Clément Pit--Claudel <clement.pitclaudel@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!






reply via email to

[Prev in Thread] Current Thread [Next in Thread]