diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 15 | ||||
-rw-r--r-- | lisp/cus-start.el | 5 | ||||
-rw-r--r-- | lisp/mouse.el | 27 | ||||
-rw-r--r-- | lisp/simple.el | 51 |
4 files changed, 44 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9d0e55f3f65..af1be5e5b60 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2010-08-07 Chong Yidong <cyd@stupidchicken.com> + + * simple.el (select-active-regions): Move to keyboard.c. + (deactivate-mark): Used saved-region-selection. + (select-active-region): Function removed. + (activate-mark, set-mark, push-mark-command) + (handle-shift-selection): Don't call it. + (keyboard-quit): Avoid adding the region to the window selection. + + * mouse.el (mouse-drag-track): Remove hacks to deal with old + select-active-regions implementation. + (mouse-yank-at-click): Doc fix. + + * cus-start.el: Add custom declaration for select-active-regions. + 2010-08-07 Eli Zaretskii <eliz@gnu.org> * simple.el (delete-forward-char): Doc fix. diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 1e8898290fb..10214d39a0d 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -197,6 +197,11 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (help-char keyboard character) (help-event-list keyboard (repeat (sexp :format "%v"))) (menu-prompting menu boolean) + (select-active-regions killing + (choice (const :tag "lazy" lazy) + (const :tag "always" t) + (const :tag "off" nil)) + "24.1") (suggest-key-bindings keyboard (choice (const :tag "off" nil) (integer :tag "time" 2) (other :tag "on"))) diff --git a/lisp/mouse.el b/lisp/mouse.el index 27587677513..a0491b0e5fb 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -697,9 +697,6 @@ This should be bound to a mouse drag event." (window-system) (sit-for 1)) (push-mark) - ;; If `select-active-regions' is non-nil, `set-mark' sets the - ;; primary selection to the buffer's region, overriding the role - ;; of `copy-region-as-kill'; that's why we did the copy first. (set-mark (point)) (if (numberp end) (goto-char end)) (mouse-set-region-1))) @@ -905,10 +902,6 @@ DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by `mouse-drag-region'." (mouse-minibuffer-check start-event) (setq mouse-selection-click-count-buffer (current-buffer)) - ;; We must call deactivate-mark before repositioning point. - ;; Otherwise, for `select-active-regions' non-nil, we get the wrong - ;; selection if the user drags a region, clicks elsewhere to - ;; reposition point, then middle-clicks to paste the selection. (deactivate-mark) (let* ((original-window (selected-window)) ;; We've recorded what we needed from the current buffer and @@ -955,10 +948,7 @@ DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by (if (eq transient-mark-mode 'lambda) '(only) (cons 'only transient-mark-mode))) - (let ((range (mouse-start-end start-point start-point click-count)) - ;; Prevent `push-mark' from clobbering the primary selection - ;; if the user clicks without dragging. - (select-active-regions nil)) + (let ((range (mouse-start-end start-point start-point click-count))) (goto-char (nth 0 range)) (push-mark nil t t) (goto-char (nth 1 range))) @@ -1017,23 +1007,16 @@ DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by ;; If point has moved, finish the drag. (let* (last-command this-command) - ;; Copy the region so that `select-active-regions' can - ;; override `copy-region-as-kill'. (and mouse-drag-copy-region do-mouse-drag-region-post-process (let (deactivate-mark) - (copy-region-as-kill (mark) (point)))) - ;; For `select-active-regions' non-nil, ensure that - ;; further alterations of the region (e.g. via - ;; shift-selection) continue to update PRIMARY. - (select-active-region)) + (copy-region-as-kill (mark) (point))))) ;; If point hasn't moved, run the binding of the ;; terminating up-event. (if do-multi-click (goto-char start-point) - (let (select-active-regions) - (deactivate-mark))) + (deactivate-mark)) (when (and (functionp fun) (= start-hscroll (window-hscroll start-window)) ;; Don't run the up-event handler if the window @@ -1251,9 +1234,7 @@ Also move point to one end of the text thus inserted (normally the end), and set mark at the beginning. Prefix arguments are interpreted as with \\[yank]. If `mouse-yank-at-point' is non-nil, insert at point -regardless of where you click. -If `select-active-regions' is non-nil, the mark is deactivated -before inserting the text." +regardless of where you click." (interactive "e\nP") ;; Give temporary modes such as isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) diff --git a/lisp/simple.el b/lisp/simple.el index c0d981ce180..dd7f512e8ae 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3666,29 +3666,27 @@ a mistake; see the documentation of `set-mark'." (marker-position (mark-marker)) (signal 'mark-inactive nil))) -(defcustom select-active-regions t - "If non-nil, an active region automatically becomes the window selection." - :type 'boolean - :group 'killing - :version "24.1") - (declare-function x-selection-owner-p "xselect.c" (&optional selection)) -;; Many places set mark-active directly, and several of them failed to also -;; run deactivate-mark-hook. This shorthand should simplify. (defsubst deactivate-mark (&optional force) "Deactivate the mark by setting `mark-active' to nil. Unless FORCE is non-nil, this function does nothing if Transient Mark mode is disabled. This function also runs `deactivate-mark-hook'." (when (or transient-mark-mode force) - ;; Copy the latest region into the primary selection, if desired. - (and select-active-regions - mark-active - (display-selections-p) - (x-selection-owner-p 'PRIMARY) - (x-set-selection 'PRIMARY (buffer-substring-no-properties - (region-beginning) (region-end)))) + (when (and select-active-regions + (region-active-p) + (display-selections-p)) + ;; The var `saved-region-selection', if non-nil, is the text in + ;; the region prior to the last command modifying the buffer. + ;; Set the selection to that, or to the current region. + (cond (saved-region-selection + (x-set-selection 'PRIMARY saved-region-selection) + (setq saved-region-selection nil)) + ((/= (region-beginning) (region-end)) + (x-set-selection 'PRIMARY + (buffer-substring-no-properties + (point) (mark)))))) (if (and (null force) (or (eq transient-mark-mode 'lambda) (and (eq (car-safe transient-mark-mode) 'only) @@ -3706,14 +3704,7 @@ This function also runs `deactivate-mark-hook'." (when (mark t) (setq mark-active t) (unless transient-mark-mode - (setq transient-mark-mode 'lambda)) - (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)))) + (setq transient-mark-mode 'lambda)))) (defun set-mark (pos) "Set this buffer's mark to POS. Don't use this function! @@ -3736,7 +3727,6 @@ store it in a Lisp variable. Example: (progn (setq mark-active t) (run-hooks 'activate-mark-hook) - (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 @@ -3820,7 +3810,6 @@ Display `Mark set' unless the optional second arg NOMSG is non-nil." (push-mark nil nomsg t) (setq mark-active t) (run-hooks 'activate-mark-hook) - (select-active-region) (unless nomsg (message "Mark activated"))))) @@ -4008,11 +3997,8 @@ Otherwise, if the region has been activated temporarily, deactivate it, and restore the variable `transient-mark-mode' to its earlier value." (cond ((and shift-select-mode this-command-keys-shift-translated) - (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) + (unless (and mark-active + (eq (car-safe transient-mark-mode) 'only)) (setq transient-mark-mode (cons 'only (unless (eq transient-mark-mode 'lambda) @@ -5576,7 +5562,10 @@ it skips the contents of comments that end before point." During execution of Lisp code, this character causes a quit directly. At top-level, as an editor command, this simply beeps." (interactive) - (deactivate-mark) + ;; Avoid adding the region to the window selection. + (setq saved-region-selection nil) + (let (select-active-regions) + (deactivate-mark)) (if (fboundp 'kmacro-keyboard-quit) (kmacro-keyboard-quit)) (setq defining-kbd-macro nil) |