[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10899: 24.0.93; c-forward-conditional should not move the mark
From: |
Juri Linkov |
Subject: |
bug#10899: 24.0.93; c-forward-conditional should not move the mark |
Date: |
Tue, 28 Feb 2012 12:30:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (x86_64-pc-linux-gnu) |
> 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)