aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-03-26 03:40:40 +0000
committerStefan Monnier2008-03-26 03:40:40 +0000
commit2977fc373a9c76ec5e3441b45e76f88e6a6e246d (patch)
tree8b6525a08082783175ae732b5ab905ab01d35e1a
parent04509548fd053f498ee40769ef9779c5e0cccb0a (diff)
downloademacs-2977fc373a9c76ec5e3441b45e76f88e6a6e246d.tar.gz
emacs-2977fc373a9c76ec5e3441b45e76f88e6a6e246d.zip
(activate-mark): New function.
(set-mark-command): Use it with region-active-p to clean up the code. (exchange-point-and-mark): Invert the meaning of C-u when transient-mark-mode is active.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el44
2 files changed, 30 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a2c1eb502bf..0f5c870a00f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12008-03-26 Stefan Monnier <monnier@iro.umontreal.ca> 12008-03-26 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * simple.el (activate-mark): New function.
4 (set-mark-command): Use it with region-active-p to clean up the code.
5 (exchange-point-and-mark): Invert the meaning of C-u when
6 transient-mark-mode is active.
7
3 * dired-aux.el (dired-create-files): Use dolist. 8 * dired-aux.el (dired-create-files): Use dolist.
4 9
5 * bindings.el (mode-line-change-eol): Use with-selected-window. 10 * bindings.el (mode-line-change-eol): Use with-selected-window.
diff --git a/lisp/simple.el b/lisp/simple.el
index 82c741f54fb..8b9ab8c0622 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3347,6 +3347,13 @@ Also runs the hook `deactivate-mark-hook'."
3347 (setq mark-active nil) 3347 (setq mark-active nil)
3348 (run-hooks 'deactivate-mark-hook)))) 3348 (run-hooks 'deactivate-mark-hook))))
3349 3349
3350(defun activate-mark ()
3351 "Activate the mark."
3352 (when (mark t)
3353 (setq mark-active t)
3354 (unless transient-mark-mode
3355 (setq transient-mark-mode 'lambda))))
3356
3350(defcustom select-active-regions nil 3357(defcustom select-active-regions nil
3351 "If non-nil, an active region automatically becomes the window selection." 3358 "If non-nil, an active region automatically becomes the window selection."
3352 :type 'boolean 3359 :type 'boolean
@@ -3520,13 +3527,13 @@ purposes. See the documentation of `set-mark' for more information."
3520 (arg 3527 (arg
3521 (setq this-command 'pop-to-mark-command) 3528 (setq this-command 'pop-to-mark-command)
3522 (pop-to-mark-command)) 3529 (pop-to-mark-command))
3523 ((and (eq last-command 'set-mark-command) 3530 ((eq last-command 'set-mark-command)
3524 mark-active (null transient-mark-mode)) 3531 (if (region-active-p)
3525 (setq transient-mark-mode 'lambda) 3532 (progn
3526 (message "Transient-mark-mode temporarily enabled")) 3533 (deactivate-mark)
3527 ((and (eq last-command 'set-mark-command) 3534 (message "Mark deactivated"))
3528 transient-mark-mode) 3535 (activate-mark)
3529 (deactivate-mark)) 3536 (message "Mark activated")))
3530 (t 3537 (t
3531 (push-mark-command nil)))) 3538 (push-mark-command nil))))
3532 3539
@@ -3580,18 +3587,17 @@ This command works even when the mark is not active,
3580and it reactivates the mark. 3587and it reactivates the mark.
3581With prefix arg, `transient-mark-mode' is enabled temporarily." 3588With prefix arg, `transient-mark-mode' is enabled temporarily."
3582 (interactive "P") 3589 (interactive "P")
3583 (if arg 3590 (deactivate-mark)
3584 (if mark-active 3591 (let ((omark (mark t)))
3585 (if (null transient-mark-mode) 3592 (if (null omark)
3586 (setq transient-mark-mode 'lambda)) 3593 (error "No mark set in this buffer"))
3587 (setq arg nil))) 3594 (set-mark (point))
3588 (unless arg 3595 (goto-char omark)
3589 (let ((omark (mark t))) 3596 (if (or (and arg (region-active-p)) ; (xor arg (not (region-active-p)))
3590 (if (null omark) 3597 (not (or arg (region-active-p))))
3591 (error "No mark set in this buffer")) 3598 (deactivate-mark)
3592 (set-mark (point)) 3599 (activate-mark))
3593 (goto-char omark) 3600 nil))
3594 nil)))
3595 3601
3596(define-minor-mode transient-mark-mode 3602(define-minor-mode transient-mark-mode
3597 "Toggle Transient Mark mode. 3603 "Toggle Transient Mark mode.