GNU bug report logs - #10899
24.0.93; c-forward-conditional should not move the mark

Previous Next

Packages: cc-mode, emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Mon, 27 Feb 2012 19:10:02 UTC

Severity: minor

Found in version 24.0.93

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> jurta.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 10899 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#10899: 24.0.93; c-forward-conditional should not move the mark
Date: Tue, 28 Feb 2012 12:30:46 +0200
> Summarizing:
> a. `c-forward-conditional' and `c-backward-conditional' should not set
> the mark, because each one has an inverse movement command.
> b. Even if you disagree, those commands should not set the mark when
> it is active.

All similar movement commands like `c-beginning-of-defun' and `c-end-of-defun'
take precautions against the behavior you found.  They do this by using
the following condition before leaving mark behind:

  (and transient-mark-mode mark-active)

The patch below fixes the remaining movement commands to do the same,
except `c-mark-function' that needs to be rewritten to follow the logic
of `mark-defun' for setting the mark.

=== modified file 'lisp/progmodes/cc-cmds.el'
--- lisp/progmodes/cc-cmds.el	2012-01-25 17:54:01 +0000
+++ lisp/progmodes/cc-cmds.el	2012-02-28 10:27:49 +0000
@@ -2910,7 +2910,8 @@ (defun c-up-conditional (count)
 forward."
   (interactive "p")
   (let ((new-point (c-scan-conditionals (- count) -1)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point))
   (c-keep-region-active))
 
@@ -2920,7 +2921,8 @@ (defun c-up-conditional-with-else (count
 directives."
   (interactive "p")
   (let ((new-point (c-scan-conditionals (- count) -1 t)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point))
   (c-keep-region-active))
 
@@ -2934,7 +2936,8 @@ (defun c-down-conditional (count)
 backward."
   (interactive "p")
   (let ((new-point (c-scan-conditionals count 1)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point))
   (c-keep-region-active))
 
@@ -2944,7 +2947,8 @@ (defun c-down-conditional-with-else (cou
 directives."
   (interactive "p")
   (let ((new-point (c-scan-conditionals count 1 t)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point))
   (c-keep-region-active))
 
@@ -2959,7 +2963,8 @@ (defun c-backward-conditional (count &op
 to call `c-scan-conditionals' directly instead."
   (interactive "p")
   (let ((new-point (c-scan-conditionals (- count) target-depth with-else)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point))
   (c-keep-region-active))
 
@@ -2980,7 +2985,8 @@ (defun c-forward-conditional (count &opt
 to call `c-scan-conditionals' directly instead."
   (interactive "p")
   (let ((new-point (c-scan-conditionals count target-depth with-else)))
-    (push-mark)
+    (or (and transient-mark-mode mark-active)
+	(push-mark))
     (goto-char new-point)))
 
 (defun c-scan-conditionals (count &optional target-depth with-else)





This bug report was last modified 4 years and 295 days ago.

Previous Next


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