Mercurial > emacs
diff lisp/simple.el @ 109471:1135ec86232d
Merge from mainline.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Mon, 19 Jul 2010 22:55:12 +0000 |
parents | 406b2d52ff00 |
children | 5b1f706a7622 |
line wrap: on
line diff
--- a/lisp/simple.el Thu Jul 15 22:44:54 2010 +0000 +++ b/lisp/simple.el Mon Jul 19 22:55:12 2010 +0000 @@ -3670,7 +3670,7 @@ "If non-nil, an active region automatically becomes the window selection." :type 'boolean :group 'killing - :version "23.1") + :version "24.1") (declare-function x-selection-owner-p "xselect.c" (&optional selection)) @@ -3687,7 +3687,6 @@ mark-active (display-selections-p) (x-selection-owner-p 'PRIMARY) - (not (eq (region-beginning) (region-end))) (x-set-selection 'PRIMARY (buffer-substring-no-properties (region-beginning) (region-end)))) (if (and (null force) @@ -3708,9 +3707,13 @@ (setq mark-active t) (unless transient-mark-mode (setq transient-mark-mode 'lambda)) - (when (and select-active-regions - (display-selections-p)) - (x-set-selection 'PRIMARY (current-buffer))))) + (select-active-region))) + +(defsubst select-active-region () + "Set the PRIMARY X selection if `select-active-regions' is non-nil." + (and select-active-regions + (display-selections-p) + (x-set-selection 'PRIMARY (current-buffer)))) (defun set-mark (pos) "Set this buffer's mark to POS. Don't use this function! @@ -3733,9 +3736,7 @@ (progn (setq mark-active t) (run-hooks 'activate-mark-hook) - (when (and select-active-regions - (display-selections-p)) - (x-set-selection 'PRIMARY (current-buffer))) + (select-active-region) (set-marker (mark-marker) pos (current-buffer))) ;; Normally we never clear mark-active except in Transient Mark mode. ;; But when we actually clear out the mark value too, we must @@ -3761,10 +3762,9 @@ This is used by commands that act specially on the region under Transient Mark mode. -The return value is t provided Transient Mark mode is enabled and -the mark is active; and, when `use-empty-active-region' is -non-nil, provided the region is empty. Otherwise, the return -value is nil. +The return value is t if Transient Mark mode is enabled and the +mark is active; furthermore, if `use-empty-active-region' is nil, +the region must not be empty. Otherwise, the return value is nil. For some commands, it may be appropriate to ignore the value of `use-empty-active-region'; in that case, use `region-active-p'." @@ -3820,8 +3820,7 @@ (push-mark nil nomsg t) (setq mark-active t) (run-hooks 'activate-mark-hook) - (and select-active-regions (display-selections-p) - (x-set-selection 'PRIMARY (current-buffer))) + (select-active-region) (unless nomsg (message "Mark activated"))))) @@ -4009,9 +4008,12 @@ deactivate it, and restore the variable `transient-mark-mode' to its earlier value." (cond ((and shift-select-mode this-command-keys-shift-translated) - (unless (and mark-active - (eq (car-safe transient-mark-mode) 'only)) - (setq transient-mark-mode + (if (and mark-active + (eq (car-safe transient-mark-mode) 'only)) + ;; Another program may have grabbed the selection; make + ;; sure we get it back now. + (select-active-region) + (setq transient-mark-mode (cons 'only (unless (eq transient-mark-mode 'lambda) transient-mark-mode)))