bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7260: 24.0.50; DEL screwed up


From: Lars Magne Ingebrigtsen
Subject: bug#7260: 24.0.50; DEL screwed up
Date: Thu, 21 Oct 2010 22:30:20 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

Chong Yidong <cyd@stupidchicken.com> writes:

> Ah yes, now I recall: the idea was to flip the meaning of ARG in
> exchange-point-and-mark, yes?

Yup.

> This is not a bad idea in principle.  But the effects may be strange.
> It would mean that, when the mark is active, you need to do C-u C-x
> C-x to exchange point and mark without deactivating the mark, which is
> inconvenient.  So this may need tweaking.

Ah, yes, true.  

> For this change, please post your proposed change as a patch to
> emacs-devel, for others to comment, instead of checking it in directly.

Sure.

I've spelled out all the cases instead of using the
(xor arg (not (region-active-p))) logic for clarity.

It seems to do the trick in all the use cases (transient with active
mark, without active mark, with and without prefix, and non-transient
with and without prefix).  Unless there was some combination I forgot to
check. 

=== modified file 'lisp/simple.el'
*** lisp/simple.el      2010-10-19 15:43:27 +0000
--- lisp/simple.el      2010-10-21 20:27:22 +0000
***************
*** 3966,3993 ****
    'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
  (defun exchange-point-and-mark (&optional arg)
    "Put the mark where point is now, and point where the mark is now.
- This command works even when the mark is not active,
- and it reactivates the mark.
  
! If Transient Mark mode is on, a prefix ARG deactivates the mark
! if it is active, and otherwise avoids reactivating it.  If
! Transient Mark mode is off, a prefix ARG enables Transient Mark
! mode temporarily."
    (interactive "P")
    (let ((omark (mark t))
        (temp-highlight (eq (car-safe transient-mark-mode) 'only)))
      (if (null omark)
          (error "No mark set in this buffer"))
      (deactivate-mark)
!     (set-mark (point))
      (goto-char omark)
      (if set-mark-default-inactive (deactivate-mark))
      (cond (temp-highlight
           (setq transient-mark-mode (cons 'only transient-mark-mode)))
!         ((or (and arg (region-active-p)) ; (xor arg (not (region-active-p)))
!              (not (or arg (region-active-p))))
!          (deactivate-mark))
!         (t (activate-mark)))
      nil))
  
  (defcustom shift-select-mode t
--- 3966,3999 ----
    'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
  (defun exchange-point-and-mark (&optional arg)
    "Put the mark where point is now, and point where the mark is now.
  
! If Transient Mark mode is on, a prefix ARG activates the mark if
! it is inactive.  If Transient Mark mode is off, a prefix ARG
! enables Transient Mark mode temporarily."
    (interactive "P")
    (let ((omark (mark t))
+       (active (region-active-p))
        (temp-highlight (eq (car-safe transient-mark-mode) 'only)))
      (if (null omark)
          (error "No mark set in this buffer"))
      (deactivate-mark)
!     (push-mark (point))
      (goto-char omark)
      (if set-mark-default-inactive (deactivate-mark))
      (cond (temp-highlight
           (setq transient-mark-mode (cons 'only transient-mark-mode)))
!         ;; Transient mode and active region -- activate.
!         ((and active
!               (not arg))
!          (activate-mark))
!         ;; Transient mode and no prefix -- leave deactivated.
!         ((and (not active)
!               (not arg))
!          )
!         ;; Non-transient mode, but prefix -- activate.
!         ((and (not transient-mark-mode)
!               arg)
!          (activate-mark)))
      nil))
  
  (defcustom shift-select-mode t


-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]