GNU bug report logs - #21119
comment-dwim should have behavior on active, empty regions

Previous Next

Package: emacs;

Reported by: Zachary Kanfer <zkanfer <at> gmail.com>

Date: Wed, 22 Jul 2015 20:39:01 UTC

Severity: minor

Tags: patch

Done: Artur Malabarba <bruce.connor.am <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21119 in the body.
You can then email your comments to 21119 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21119; Package emacs. (Wed, 22 Jul 2015 20:39:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zachary Kanfer <zkanfer <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 Jul 2015 20:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: comment-dwim should have behavior on active, empty regions
Date: Wed, 22 Jul 2015 16:37:42 -0400
This patch is for the function comment-dwim, which is bound to C-; by default.

Currently, when the region is not active, comment-dwim puts a comment
at the end of the line. When the region is active, comment-dwim
comments out the region by calling comment-or-uncomment-region.
However, when the region is active, but empty,
comment-or-uncomment-region does nothing; no text is inserted. I think
this last action (upon active, empty region) is a bug. If the active
region is empty, we should insert a comment at the end of the line, as
we do when there's no region.

This patch calls use-region-p to detect whether the region is active,
rather than checking mark-active transient-mark-mode explicitly. The
effect of this is, when the region is active, but empty, comment-dwim
now acts as though the region was not active -- it puts a comment at
the end of the line. Use-region-p does do the previous behavior (of
checking mark-active and transient-mark-mode) by calling
region-active-p.

The patch follows:

From 6bdd96b07775c5c2fd0f3d6595b6655b4093dcf2 Mon Sep 17 00:00:00 2001
From: Zachary Kanfer <zkanfer <at> gmail.com>
Date: Mon, 20 Jul 2015 01:36:56 -0400
Subject: [PATCH] Make comment-dwim treat empty regions as inactive.

When the region is active, but is empty (length 0), comment-dwim now
acts as though the region was not active; that is, it puts a comment
at the end of the line.
---
 lisp/newcomment.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 172a563..8d17a69 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1266,7 +1266,7 @@ Else, call `comment-indent'.
 You can configure `comment-style' to change the way regions are commented."
   (interactive "*P")
   (comment-normalize-vars)
-  (if (and mark-active transient-mark-mode)
+  (if (use-region-p)
       (comment-or-uncomment-region (region-beginning) (region-end) arg)
     (if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$")))
     ;; FIXME: If there's no comment to kill on this line and ARG is
--
1.9.1




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21119; Package emacs. (Wed, 26 Aug 2015 05:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 21119 <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: 21119 <at> debbugs.gnu.org
Subject: Re: comment-dwim should have behavior on active, empty regions
Date: Wed, 26 Aug 2015 01:12:10 -0400
[Message part 1 (text/plain, inline)]
Is there anything I can do to make it easier to look at this patch?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21119; Package emacs. (Fri, 28 Aug 2015 10:09:01 GMT) Full text and rfc822 format available.

Message #11 received at 21119 <at> debbugs.gnu.org (full text, mbox):

From: Artur Malabarba <bruce.connor.am <at> gmail.com>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: 21119 <at> debbugs.gnu.org
Subject: Re: bug#21119: comment-dwim should have behavior on active,
 empty regions
Date: Fri, 28 Aug 2015 11:08:41 +0100
Looks reasonable. If nobody opposes I'll apply it tomorrow.

2015-08-26 6:12 GMT+01:00 Zachary Kanfer <zkanfer <at> gmail.com>:
> Is there anything I can do to make it easier to look at this patch?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21119; Package emacs. (Sun, 30 Aug 2015 22:19:01 GMT) Full text and rfc822 format available.

Message #14 received at 21119 <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: bruce.connor.am <at> gmail.com
Cc: 21119 <at> debbugs.gnu.org
Subject: Re: bug#21119: comment-dwim should have behavior on active,
 empty regions
Date: Sun, 30 Aug 2015 18:17:48 -0400
[Message part 1 (text/plain, inline)]
Thanks!

On Fri, Aug 28, 2015 at 6:08 AM, Artur Malabarba <bruce.connor.am <at> gmail.com>
wrote:

> Looks reasonable. If nobody opposes I'll apply it tomorrow.
>
> 2015-08-26 6:12 GMT+01:00 Zachary Kanfer <zkanfer <at> gmail.com>:
> > Is there anything I can do to make it easier to look at this patch?
>
[Message part 2 (text/html, inline)]

Reply sent to bruce.connor.am <at> gmail.com:
You have taken responsibility. (Tue, 01 Sep 2015 02:18:01 GMT) Full text and rfc822 format available.

Notification sent to Zachary Kanfer <zkanfer <at> gmail.com>:
bug acknowledged by developer. (Tue, 01 Sep 2015 02:18:02 GMT) Full text and rfc822 format available.

Message #19 received at 21119-done <at> debbugs.gnu.org (full text, mbox):

From: Artur Malabarba <bruce.connor.am <at> gmail.com>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: 21119-done <at> debbugs.gnu.org
Subject: Re: bug#21119: comment-dwim should have behavior on active,
 empty regions
Date: Tue, 1 Sep 2015 03:17:11 +0100
Fixed.

Just FYI, Zachary. Your patch did not apply. Did you create it with
git format-patch?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21119; Package emacs. (Tue, 01 Sep 2015 02:36:01 GMT) Full text and rfc822 format available.

Message #22 received at 21119-done <at> debbugs.gnu.org (full text, mbox):

From: Zachary Kanfer <zkanfer <at> gmail.com>
To: bruce.connor.am <at> gmail.com
Cc: 21119-done <at> debbugs.gnu.org
Subject: Re: bug#21119: comment-dwim should have behavior on active,
 empty regions
Date: Mon, 31 Aug 2015 22:35:25 -0400
[Message part 1 (text/plain, inline)]
Weird. I did use git format-patch. Might it be because I'm using git
version 1.9?

On Mon, Aug 31, 2015 at 10:17 PM, Artur Malabarba <bruce.connor.am <at> gmail.com
> wrote:

> Fixed.
>
> Just FYI, Zachary. Your patch did not apply. Did you create it with
> git format-patch?
>
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 29 Sep 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 265 days ago.

Previous Next


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