* bug#21119: comment-dwim should have behavior on active, empty regions
@ 2015-07-22 20:37 Zachary Kanfer
2015-08-26 5:12 ` Zachary Kanfer
0 siblings, 1 reply; 6+ messages in thread
From: Zachary Kanfer @ 2015-07-22 20:37 UTC (permalink / raw)
To: 21119
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@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.
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#21119: comment-dwim should have behavior on active, empty regions
2015-07-22 20:37 bug#21119: comment-dwim should have behavior on active, empty regions Zachary Kanfer
@ 2015-08-26 5:12 ` Zachary Kanfer
2015-08-28 10:08 ` Artur Malabarba
0 siblings, 1 reply; 6+ messages in thread
From: Zachary Kanfer @ 2015-08-26 5:12 UTC (permalink / raw)
To: 21119
[-- Attachment #1: Type: text/plain, Size: 68 bytes --]
Is there anything I can do to make it easier to look at this patch?
[-- Attachment #2: Type: text/html, Size: 93 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#21119: comment-dwim should have behavior on active, empty regions
2015-08-26 5:12 ` Zachary Kanfer
@ 2015-08-28 10:08 ` Artur Malabarba
2015-08-30 22:17 ` Zachary Kanfer
0 siblings, 1 reply; 6+ messages in thread
From: Artur Malabarba @ 2015-08-28 10:08 UTC (permalink / raw)
To: Zachary Kanfer; +Cc: 21119
Looks reasonable. If nobody opposes I'll apply it tomorrow.
2015-08-26 6:12 GMT+01:00 Zachary Kanfer <zkanfer@gmail.com>:
> Is there anything I can do to make it easier to look at this patch?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#21119: comment-dwim should have behavior on active, empty regions
2015-08-28 10:08 ` Artur Malabarba
@ 2015-08-30 22:17 ` Zachary Kanfer
2015-09-01 2:17 ` Artur Malabarba
0 siblings, 1 reply; 6+ messages in thread
From: Zachary Kanfer @ 2015-08-30 22:17 UTC (permalink / raw)
To: bruce.connor.am; +Cc: 21119
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
Thanks!
On Fri, Aug 28, 2015 at 6:08 AM, Artur Malabarba <bruce.connor.am@gmail.com>
wrote:
> Looks reasonable. If nobody opposes I'll apply it tomorrow.
>
> 2015-08-26 6:12 GMT+01:00 Zachary Kanfer <zkanfer@gmail.com>:
> > Is there anything I can do to make it easier to look at this patch?
>
[-- Attachment #2: Type: text/html, Size: 663 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#21119: comment-dwim should have behavior on active, empty regions
2015-08-30 22:17 ` Zachary Kanfer
@ 2015-09-01 2:17 ` Artur Malabarba
2015-09-01 2:35 ` Zachary Kanfer
0 siblings, 1 reply; 6+ messages in thread
From: Artur Malabarba @ 2015-09-01 2:17 UTC (permalink / raw)
To: Zachary Kanfer; +Cc: 21119-done
Fixed.
Just FYI, Zachary. Your patch did not apply. Did you create it with
git format-patch?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#21119: comment-dwim should have behavior on active, empty regions
2015-09-01 2:17 ` Artur Malabarba
@ 2015-09-01 2:35 ` Zachary Kanfer
0 siblings, 0 replies; 6+ messages in thread
From: Zachary Kanfer @ 2015-09-01 2:35 UTC (permalink / raw)
To: bruce.connor.am; +Cc: 21119-done
[-- Attachment #1: Type: text/plain, Size: 273 bytes --]
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@gmail.com
> wrote:
> Fixed.
>
> Just FYI, Zachary. Your patch did not apply. Did you create it with
> git format-patch?
>
[-- Attachment #2: Type: text/html, Size: 591 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-01 2:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 20:37 bug#21119: comment-dwim should have behavior on active, empty regions Zachary Kanfer
2015-08-26 5:12 ` Zachary Kanfer
2015-08-28 10:08 ` Artur Malabarba
2015-08-30 22:17 ` Zachary Kanfer
2015-09-01 2:17 ` Artur Malabarba
2015-09-01 2:35 ` Zachary Kanfer
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.