all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: 10899@debbugs.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	[thread overview]
Message-ID: <87399v2qsp.fsf@mail.jurta.org> (raw)
In-Reply-To: <CAH8Pv0hF+yd5ui3gmFfBAtyT3i0kB=q3Vz=59-fdtder_jZN1A@mail.gmail.com> (Dani Moncayo's message of "Tue, 28 Feb 2012 08:42:43 +0100")

> 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)






  reply	other threads:[~2012-02-28 10:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 19:06 bug#10899: 24.0.93; c-forward-conditional should not move the mark Dani Moncayo
2012-02-27 19:29 ` Dani Moncayo
2012-02-27 20:28   ` Eli Zaretskii
2012-02-27 20:59     ` Dani Moncayo
2012-02-28  7:42       ` Dani Moncayo
2012-02-28 10:30         ` Juri Linkov [this message]
2012-02-28 11:12           ` Dani Moncayo
2012-02-29  0:14             ` Juri Linkov
2012-02-28 21:59         ` Stefan Monnier
2020-08-25 12:34           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87399v2qsp.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=10899@debbugs.gnu.org \
    --cc=dmoncayo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.