diff options
| author | Chong Yidong | 2009-07-15 01:25:32 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-07-15 01:25:32 +0000 |
| commit | f9be2e356915fd56496dc2583e4856b5ccf95664 (patch) | |
| tree | 0c618bbfeca73e3583da5a02204238c3e9f851a7 | |
| parent | cbd61418b367a9329ed51b5748019a75a5c7e9cf (diff) | |
| download | emacs-f9be2e356915fd56496dc2583e4856b5ccf95664.tar.gz emacs-f9be2e356915fd56496dc2583e4856b5ccf95664.zip | |
* simple.el (deactivate-mark): Optional argument FORCE.
(set-mark): Use deactivate-mark.
* info.el (Info-search): No need to check transient-mark-mode
before calling deactivate-mark.
* select.el (x-set-selection): Doc fix.
(x-valid-simple-selection-p): Allow buffer values.
(xselect--selection-bounds): Handle buffer values. Suggested by
David De La Harpe Golden.
* mouse.el (mouse-set-region, mouse-drag-track): Call
copy-region-as-kill before setting the mark, to let
select-active-regions work.
* simple.el (deactivate-mark): If select-active-regions is
non-nil, copy the selection data into a string.
(activate-mark): If select-active-regions is non-nil, set the
selection to the current buffer.
(set-mark): Update selection if select-active-regions is non-nil.
* select.el (x-valid-simple-selection-p): Allow buffer values.
| -rw-r--r-- | lisp/ChangeLog | 27 | ||||
| -rw-r--r-- | lisp/info.el | 3 | ||||
| -rw-r--r-- | lisp/mouse.el | 48 | ||||
| -rw-r--r-- | lisp/select.el | 28 | ||||
| -rw-r--r-- | lisp/simple.el | 51 |
5 files changed, 100 insertions, 57 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5ccc6988ad2..0215d0aead6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2009-07-15 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * simple.el (deactivate-mark): Optional argument FORCE. | ||
| 4 | (set-mark): Use deactivate-mark. | ||
| 5 | |||
| 6 | * info.el (Info-search): No need to check transient-mark-mode | ||
| 7 | before calling deactivate-mark. | ||
| 8 | |||
| 9 | * select.el (x-set-selection): Doc fix. | ||
| 10 | (x-valid-simple-selection-p): Allow buffer values. | ||
| 11 | (xselect--selection-bounds): Handle buffer values. Suggested by | ||
| 12 | David De La Harpe Golden. | ||
| 13 | |||
| 14 | * mouse.el (mouse-set-region, mouse-drag-track): Call | ||
| 15 | copy-region-as-kill before setting the mark, to let | ||
| 16 | select-active-regions work. | ||
| 17 | |||
| 18 | 2009-06-28 David De La Harpe Golden <david@harpegolden.net> | ||
| 19 | |||
| 20 | * simple.el (deactivate-mark): If select-active-regions is | ||
| 21 | non-nil, copy the selection data into a string. | ||
| 22 | (activate-mark): If select-active-regions is non-nil, set the | ||
| 23 | selection to the current buffer. | ||
| 24 | (set-mark): Update selection if select-active-regions is non-nil. | ||
| 25 | |||
| 26 | * select.el (x-valid-simple-selection-p): Allow buffer values. | ||
| 27 | |||
| 1 | 2009-07-14 Stefan Monnier <monnier@iro.umontreal.ca> | 28 | 2009-07-14 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 29 | ||
| 3 | * simple.el (mail-user-agent): Default to the upwardly-UI-compatible | 30 | * simple.el (mail-user-agent): Default to the upwardly-UI-compatible |
diff --git a/lisp/info.el b/lisp/info.el index 03618cc098d..af4e0b141bd 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -1693,8 +1693,7 @@ If DIRECTION is `backward', search in the reverse direction." | |||
| 1693 | (format "Regexp search%s: " | 1693 | (format "Regexp search%s: " |
| 1694 | (if case-fold-search "" " case-sensitively"))) | 1694 | (if case-fold-search "" " case-sensitively"))) |
| 1695 | nil 'Info-search-history))) | 1695 | nil 'Info-search-history))) |
| 1696 | (when transient-mark-mode | 1696 | (deactivate-mark) |
| 1697 | (deactivate-mark)) | ||
| 1698 | (when (equal regexp "") | 1697 | (when (equal regexp "") |
| 1699 | (setq regexp (car Info-search-history))) | 1698 | (setq regexp (car Info-search-history))) |
| 1700 | (when regexp | 1699 | (when regexp |
diff --git a/lisp/mouse.el b/lisp/mouse.el index cdb89caeeca..03f73ba8d9c 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -681,26 +681,26 @@ This should be bound to a mouse click event type." | |||
| 681 | This should be bound to a mouse drag event." | 681 | This should be bound to a mouse drag event." |
| 682 | (interactive "e") | 682 | (interactive "e") |
| 683 | (mouse-minibuffer-check click) | 683 | (mouse-minibuffer-check click) |
| 684 | (let ((posn (event-start click)) | 684 | (select-window (posn-window (event-start click))) |
| 685 | (end (event-end click))) | 685 | (let ((beg (posn-point (event-start click))) |
| 686 | (select-window (posn-window posn)) | 686 | (end (posn-point (event-end click)))) |
| 687 | (if (numberp (posn-point posn)) | 687 | (and mouse-drag-copy-region (integerp beg) (integerp end) |
| 688 | (goto-char (posn-point posn))) | 688 | ;; Don't set this-command to `kill-region', so a following |
| 689 | ;; If mark is highlighted, no need to bounce the cursor. | 689 | ;; C-w won't double the text in the kill ring. Ignore |
| 690 | ;; On X, we highlight while dragging, thus once again no need to bounce. | 690 | ;; `last-command' so we don't append to a preceding kill. |
| 691 | (let (this-command last-command deactivate-mark) | ||
| 692 | (copy-region-as-kill beg end))) | ||
| 693 | (if (numberp beg) (goto-char beg)) | ||
| 694 | ;; On a text terminal, bounce the cursor. | ||
| 691 | (or transient-mark-mode | 695 | (or transient-mark-mode |
| 692 | (memq (framep (selected-frame)) '(x pc w32 ns)) | 696 | (window-system) |
| 693 | (sit-for 1)) | 697 | (sit-for 1)) |
| 694 | (push-mark) | 698 | (push-mark) |
| 699 | ;; If `select-active-regions' is non-nil, `set-mark' sets the | ||
| 700 | ;; primary selection to the buffer's region, overriding the role | ||
| 701 | ;; of `copy-region-as-kill'; that's why we did the copy first. | ||
| 695 | (set-mark (point)) | 702 | (set-mark (point)) |
| 696 | (if (numberp (posn-point end)) | 703 | (if (numberp end) (goto-char end)) |
| 697 | (goto-char (posn-point end))) | ||
| 698 | ;; Don't set this-command to kill-region, so that a following | ||
| 699 | ;; C-w will not double the text in the kill ring. | ||
| 700 | ;; Ignore last-command so we don't append to a preceding kill. | ||
| 701 | (when mouse-drag-copy-region | ||
| 702 | (let (this-command last-command deactivate-mark) | ||
| 703 | (copy-region-as-kill (mark) (point)))) | ||
| 704 | (mouse-set-region-1))) | 704 | (mouse-set-region-1))) |
| 705 | 705 | ||
| 706 | (defun mouse-set-region-1 () | 706 | (defun mouse-set-region-1 () |
| @@ -1046,15 +1046,19 @@ should only be used by mouse-drag-region." | |||
| 1046 | (overlay-start mouse-drag-overlay)) | 1046 | (overlay-start mouse-drag-overlay)) |
| 1047 | region-termination)) | 1047 | region-termination)) |
| 1048 | last-command this-command) | 1048 | last-command this-command) |
| 1049 | ;; We copy the region before setting the mark so | ||
| 1050 | ;; that `select-active-regions' can override | ||
| 1051 | ;; `copy-region-as-kill'. | ||
| 1052 | (and mouse-drag-copy-region | ||
| 1053 | do-mouse-drag-region-post-process | ||
| 1054 | (let (deactivate-mark) | ||
| 1055 | (copy-region-as-kill region-commencement | ||
| 1056 | region-termination))) | ||
| 1049 | (push-mark region-commencement t t) | 1057 | (push-mark region-commencement t t) |
| 1050 | (goto-char region-termination) | 1058 | (goto-char region-termination) |
| 1051 | (if (not do-mouse-drag-region-post-process) | 1059 | (if (not do-mouse-drag-region-post-process) |
| 1052 | ;; Skip all post-event handling, return immediately. | 1060 | ;; Skip all post-event handling, return immediately. |
| 1053 | (delete-overlay mouse-drag-overlay) | 1061 | (delete-overlay mouse-drag-overlay) |
| 1054 | ;; Don't let copy-region-as-kill set deactivate-mark. | ||
| 1055 | (when mouse-drag-copy-region | ||
| 1056 | (let (deactivate-mark) | ||
| 1057 | (copy-region-as-kill (point) (mark t)))) | ||
| 1058 | (let ((buffer (current-buffer))) | 1062 | (let ((buffer (current-buffer))) |
| 1059 | (mouse-show-mark) | 1063 | (mouse-show-mark) |
| 1060 | ;; mouse-show-mark can call read-event, | 1064 | ;; mouse-show-mark can call read-event, |
| @@ -1697,9 +1701,7 @@ is to prevent accidents." | |||
| 1697 | (with-current-buffer (overlay-buffer mouse-secondary-overlay) | 1701 | (with-current-buffer (overlay-buffer mouse-secondary-overlay) |
| 1698 | (kill-region (overlay-start mouse-secondary-overlay) | 1702 | (kill-region (overlay-start mouse-secondary-overlay) |
| 1699 | (overlay-end mouse-secondary-overlay)))) | 1703 | (overlay-end mouse-secondary-overlay)))) |
| 1700 | (delete-overlay mouse-secondary-overlay) | 1704 | (delete-overlay mouse-secondary-overlay)) |
| 1701 | ;;; (x-set-selection 'SECONDARY nil) | ||
| 1702 | ) | ||
| 1703 | 1705 | ||
| 1704 | (defun mouse-secondary-save-then-kill (click) | 1706 | (defun mouse-secondary-save-then-kill (click) |
| 1705 | "Save text to point in kill ring; the second time, kill the text. | 1707 | "Save text to point in kill ring; the second time, kill the text. |
diff --git a/lisp/select.el b/lisp/select.el index cc15bed7580..a65f2908b24 100644 --- a/lisp/select.el +++ b/lisp/select.el | |||
| @@ -122,15 +122,16 @@ equivalent to `PRIMARY'. (It can also be a string, which stands | |||
| 122 | for the symbol with that name, but this usage is obsolete.) | 122 | for the symbol with that name, but this usage is obsolete.) |
| 123 | 123 | ||
| 124 | DATA is a selection value. It should be one of the following: | 124 | DATA is a selection value. It should be one of the following: |
| 125 | - a vector of non-vector selection values | 125 | - A vector of non-vector selection values. |
| 126 | - a string | 126 | - A string. |
| 127 | - an integer | 127 | - An integer. |
| 128 | - a cons cell of two markers pointing to the same buffer | 128 | - A cons cell of two markers pointing to the same buffer |
| 129 | - an overlay | 129 | (the data consists of the text between the markers). |
| 130 | In the latter two cases, the selection is considered to be the | 130 | - An overlay (the data consists of the text within the overlay). |
| 131 | text between the markers at whatever time the selection is | 131 | - A buffer (the data consists of the text in the region). |
| 132 | examined. Thus, editing done in the buffer after you specify the | 132 | For the last three cases, the actual selection data is computed |
| 133 | selection can alter the effective value of the selection. | 133 | only when the selection is requested. Thus, it includes any |
| 134 | changes made to the buffer after `x-set-selection' is called. | ||
| 134 | 135 | ||
| 135 | The return value is DATA. | 136 | The return value is DATA. |
| 136 | 137 | ||
| @@ -158,7 +159,8 @@ prefix argument, it uses the text of the region as the selection value ." | |||
| 158 | data) | 159 | data) |
| 159 | 160 | ||
| 160 | (defun x-valid-simple-selection-p (data) | 161 | (defun x-valid-simple-selection-p (data) |
| 161 | (or (and (consp data) | 162 | (or (bufferp data) |
| 163 | (and (consp data) | ||
| 162 | (markerp (car data)) | 164 | (markerp (car data)) |
| 163 | (markerp (cdr data)) | 165 | (markerp (cdr data)) |
| 164 | (marker-buffer (car data)) | 166 | (marker-buffer (car data)) |
| @@ -210,7 +212,11 @@ Cut buffers are considered obsolete; you should use selections instead." | |||
| 210 | "Return bounds of X selection value VALUE. | 212 | "Return bounds of X selection value VALUE. |
| 211 | The return value is a list (BEG END BUF) if VALUE is a cons of | 213 | The return value is a list (BEG END BUF) if VALUE is a cons of |
| 212 | two markers or an overlay. Otherwise, it is nil." | 214 | two markers or an overlay. Otherwise, it is nil." |
| 213 | (cond ((and (consp value) | 215 | (cond ((bufferp value) |
| 216 | (with-current-buffer value | ||
| 217 | (when (mark t) | ||
| 218 | (list (mark t) (point) value)))) | ||
| 219 | ((and (consp value) | ||
| 214 | (markerp (car value)) | 220 | (markerp (car value)) |
| 215 | (markerp (cdr value))) | 221 | (markerp (cdr value))) |
| 216 | (when (and (marker-buffer (car value)) | 222 | (when (and (marker-buffer (car value)) |
diff --git a/lisp/simple.el b/lisp/simple.el index f087189d44d..68966cf95a7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3472,16 +3472,31 @@ a mistake; see the documentation of `set-mark'." | |||
| 3472 | (marker-position (mark-marker)) | 3472 | (marker-position (mark-marker)) |
| 3473 | (signal 'mark-inactive nil))) | 3473 | (signal 'mark-inactive nil))) |
| 3474 | 3474 | ||
| 3475 | (defcustom select-active-regions nil | ||
| 3476 | "If non-nil, an active region automatically becomes the window selection." | ||
| 3477 | :type 'boolean | ||
| 3478 | :group 'killing | ||
| 3479 | :version "23.1") | ||
| 3480 | |||
| 3475 | ;; Many places set mark-active directly, and several of them failed to also | 3481 | ;; Many places set mark-active directly, and several of them failed to also |
| 3476 | ;; run deactivate-mark-hook. This shorthand should simplify. | 3482 | ;; run deactivate-mark-hook. This shorthand should simplify. |
| 3477 | (defsubst deactivate-mark () | 3483 | (defsubst deactivate-mark (&optional force) |
| 3478 | "Deactivate the mark by setting `mark-active' to nil. | 3484 | "Deactivate the mark by setting `mark-active' to nil. |
| 3479 | \(That makes a difference only in Transient Mark mode.) | 3485 | Unless FORCE is non-nil, this function does nothing if Transient |
| 3480 | Also runs the hook `deactivate-mark-hook'." | 3486 | Mark mode is disabled. |
| 3481 | (when transient-mark-mode | 3487 | This function also runs `deactivate-mark-hook'." |
| 3482 | (if (or (eq transient-mark-mode 'lambda) | 3488 | (when (or transient-mark-mode force) |
| 3483 | (and (eq (car-safe transient-mark-mode) 'only) | 3489 | ;; Copy the latest region into the primary selection, if desired. |
| 3484 | (null (cdr transient-mark-mode)))) | 3490 | (and select-active-regions |
| 3491 | mark-active | ||
| 3492 | (x-set-selection 'PRIMARY (buffer-substring-no-properties | ||
| 3493 | (region-beginning) (region-end)))) | ||
| 3494 | (if (and (null force) | ||
| 3495 | (or (eq transient-mark-mode 'lambda) | ||
| 3496 | (and (eq (car-safe transient-mark-mode) 'only) | ||
| 3497 | (null (cdr transient-mark-mode))))) | ||
| 3498 | ;; When deactivating a temporary region, don't change | ||
| 3499 | ;; `mark-active' or run `deactivate-mark-hook'. | ||
| 3485 | (setq transient-mark-mode nil) | 3500 | (setq transient-mark-mode nil) |
| 3486 | (if (eq (car-safe transient-mark-mode) 'only) | 3501 | (if (eq (car-safe transient-mark-mode) 'only) |
| 3487 | (setq transient-mark-mode (cdr transient-mark-mode))) | 3502 | (setq transient-mark-mode (cdr transient-mark-mode))) |
| @@ -3493,13 +3508,9 @@ Also runs the hook `deactivate-mark-hook'." | |||
| 3493 | (when (mark t) | 3508 | (when (mark t) |
| 3494 | (setq mark-active t) | 3509 | (setq mark-active t) |
| 3495 | (unless transient-mark-mode | 3510 | (unless transient-mark-mode |
| 3496 | (setq transient-mark-mode 'lambda)))) | 3511 | (setq transient-mark-mode 'lambda)) |
| 3497 | 3512 | (when select-active-regions | |
| 3498 | (defcustom select-active-regions nil | 3513 | (x-set-selection 'PRIMARY (current-buffer))))) |
| 3499 | "If non-nil, an active region automatically becomes the window selection." | ||
| 3500 | :type 'boolean | ||
| 3501 | :group 'killing | ||
| 3502 | :version "23.1") | ||
| 3503 | 3514 | ||
| 3504 | (defun set-mark (pos) | 3515 | (defun set-mark (pos) |
| 3505 | "Set this buffer's mark to POS. Don't use this function! | 3516 | "Set this buffer's mark to POS. Don't use this function! |
| @@ -3522,15 +3533,13 @@ store it in a Lisp variable. Example: | |||
| 3522 | (progn | 3533 | (progn |
| 3523 | (setq mark-active t) | 3534 | (setq mark-active t) |
| 3524 | (run-hooks 'activate-mark-hook) | 3535 | (run-hooks 'activate-mark-hook) |
| 3525 | (and select-active-regions | 3536 | (when select-active-regions |
| 3526 | (x-set-selection | 3537 | (x-set-selection 'PRIMARY (current-buffer))) |
| 3527 | nil (buffer-substring (region-beginning) (region-end)))) | ||
| 3528 | (set-marker (mark-marker) pos (current-buffer))) | 3538 | (set-marker (mark-marker) pos (current-buffer))) |
| 3529 | ;; Normally we never clear mark-active except in Transient Mark mode. | 3539 | ;; Normally we never clear mark-active except in Transient Mark mode. |
| 3530 | ;; But when we actually clear out the mark value too, | 3540 | ;; But when we actually clear out the mark value too, we must |
| 3531 | ;; we must clear mark-active in any mode. | 3541 | ;; clear mark-active in any mode. |
| 3532 | (setq mark-active nil) | 3542 | (deactivate-mark t) |
| 3533 | (run-hooks 'deactivate-mark-hook) | ||
| 3534 | (set-marker (mark-marker) nil))) | 3543 | (set-marker (mark-marker) nil))) |
| 3535 | 3544 | ||
| 3536 | (defcustom use-empty-active-region nil | 3545 | (defcustom use-empty-active-region nil |