* 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.
This commit is contained in:
parent
cbd61418b3
commit
f9be2e3569
5 changed files with 100 additions and 57 deletions
|
@ -1,3 +1,30 @@
|
|||
2009-07-15 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2009-06-28 David De La Harpe Golden <david@harpegolden.net>
|
||||
|
||||
* 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.
|
||||
|
||||
2009-07-14 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* simple.el (mail-user-agent): Default to the upwardly-UI-compatible
|
||||
|
|
|
@ -1693,8 +1693,7 @@ If DIRECTION is `backward', search in the reverse direction."
|
|||
(format "Regexp search%s: "
|
||||
(if case-fold-search "" " case-sensitively")))
|
||||
nil 'Info-search-history)))
|
||||
(when transient-mark-mode
|
||||
(deactivate-mark))
|
||||
(deactivate-mark)
|
||||
(when (equal regexp "")
|
||||
(setq regexp (car Info-search-history)))
|
||||
(when regexp
|
||||
|
|
|
@ -681,26 +681,26 @@ This should be bound to a mouse click event type."
|
|||
This should be bound to a mouse drag event."
|
||||
(interactive "e")
|
||||
(mouse-minibuffer-check click)
|
||||
(let ((posn (event-start click))
|
||||
(end (event-end click)))
|
||||
(select-window (posn-window posn))
|
||||
(if (numberp (posn-point posn))
|
||||
(goto-char (posn-point posn)))
|
||||
;; If mark is highlighted, no need to bounce the cursor.
|
||||
;; On X, we highlight while dragging, thus once again no need to bounce.
|
||||
(select-window (posn-window (event-start click)))
|
||||
(let ((beg (posn-point (event-start click)))
|
||||
(end (posn-point (event-end click))))
|
||||
(and mouse-drag-copy-region (integerp beg) (integerp end)
|
||||
;; Don't set this-command to `kill-region', so a following
|
||||
;; C-w won't double the text in the kill ring. Ignore
|
||||
;; `last-command' so we don't append to a preceding kill.
|
||||
(let (this-command last-command deactivate-mark)
|
||||
(copy-region-as-kill beg end)))
|
||||
(if (numberp beg) (goto-char beg))
|
||||
;; On a text terminal, bounce the cursor.
|
||||
(or transient-mark-mode
|
||||
(memq (framep (selected-frame)) '(x pc w32 ns))
|
||||
(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 (posn-point end))
|
||||
(goto-char (posn-point end)))
|
||||
;; Don't set this-command to kill-region, so that a following
|
||||
;; C-w will not double the text in the kill ring.
|
||||
;; Ignore last-command so we don't append to a preceding kill.
|
||||
(when mouse-drag-copy-region
|
||||
(let (this-command last-command deactivate-mark)
|
||||
(copy-region-as-kill (mark) (point))))
|
||||
(if (numberp end) (goto-char end))
|
||||
(mouse-set-region-1)))
|
||||
|
||||
(defun mouse-set-region-1 ()
|
||||
|
@ -1046,15 +1046,19 @@ should only be used by mouse-drag-region."
|
|||
(overlay-start mouse-drag-overlay))
|
||||
region-termination))
|
||||
last-command this-command)
|
||||
;; We copy the region before setting the mark 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 region-commencement
|
||||
region-termination)))
|
||||
(push-mark region-commencement t t)
|
||||
(goto-char region-termination)
|
||||
(if (not do-mouse-drag-region-post-process)
|
||||
;; Skip all post-event handling, return immediately.
|
||||
(delete-overlay mouse-drag-overlay)
|
||||
;; Don't let copy-region-as-kill set deactivate-mark.
|
||||
(when mouse-drag-copy-region
|
||||
(let (deactivate-mark)
|
||||
(copy-region-as-kill (point) (mark t))))
|
||||
(let ((buffer (current-buffer)))
|
||||
(mouse-show-mark)
|
||||
;; mouse-show-mark can call read-event,
|
||||
|
@ -1697,9 +1701,7 @@ is to prevent accidents."
|
|||
(with-current-buffer (overlay-buffer mouse-secondary-overlay)
|
||||
(kill-region (overlay-start mouse-secondary-overlay)
|
||||
(overlay-end mouse-secondary-overlay))))
|
||||
(delete-overlay mouse-secondary-overlay)
|
||||
;;; (x-set-selection 'SECONDARY nil)
|
||||
)
|
||||
(delete-overlay mouse-secondary-overlay))
|
||||
|
||||
(defun mouse-secondary-save-then-kill (click)
|
||||
"Save text to point in kill ring; the second time, kill the text.
|
||||
|
|
|
@ -122,15 +122,16 @@ equivalent to `PRIMARY'. (It can also be a string, which stands
|
|||
for the symbol with that name, but this usage is obsolete.)
|
||||
|
||||
DATA is a selection value. It should be one of the following:
|
||||
- a vector of non-vector selection values
|
||||
- a string
|
||||
- an integer
|
||||
- a cons cell of two markers pointing to the same buffer
|
||||
- an overlay
|
||||
In the latter two cases, the selection is considered to be the
|
||||
text between the markers at whatever time the selection is
|
||||
examined. Thus, editing done in the buffer after you specify the
|
||||
selection can alter the effective value of the selection.
|
||||
- A vector of non-vector selection values.
|
||||
- A string.
|
||||
- An integer.
|
||||
- A cons cell of two markers pointing to the same buffer
|
||||
(the data consists of the text between the markers).
|
||||
- An overlay (the data consists of the text within the overlay).
|
||||
- A buffer (the data consists of the text in the region).
|
||||
For the last three cases, the actual selection data is computed
|
||||
only when the selection is requested. Thus, it includes any
|
||||
changes made to the buffer after `x-set-selection' is called.
|
||||
|
||||
The return value is DATA.
|
||||
|
||||
|
@ -158,7 +159,8 @@ prefix argument, it uses the text of the region as the selection value ."
|
|||
data)
|
||||
|
||||
(defun x-valid-simple-selection-p (data)
|
||||
(or (and (consp data)
|
||||
(or (bufferp data)
|
||||
(and (consp data)
|
||||
(markerp (car data))
|
||||
(markerp (cdr data))
|
||||
(marker-buffer (car data))
|
||||
|
@ -210,7 +212,11 @@ Cut buffers are considered obsolete; you should use selections instead."
|
|||
"Return bounds of X selection value VALUE.
|
||||
The return value is a list (BEG END BUF) if VALUE is a cons of
|
||||
two markers or an overlay. Otherwise, it is nil."
|
||||
(cond ((and (consp value)
|
||||
(cond ((bufferp value)
|
||||
(with-current-buffer value
|
||||
(when (mark t)
|
||||
(list (mark t) (point) value))))
|
||||
((and (consp value)
|
||||
(markerp (car value))
|
||||
(markerp (cdr value)))
|
||||
(when (and (marker-buffer (car value))
|
||||
|
|
|
@ -3472,16 +3472,31 @@ a mistake; see the documentation of `set-mark'."
|
|||
(marker-position (mark-marker))
|
||||
(signal 'mark-inactive nil)))
|
||||
|
||||
(defcustom select-active-regions nil
|
||||
"If non-nil, an active region automatically becomes the window selection."
|
||||
:type 'boolean
|
||||
:group 'killing
|
||||
:version "23.1")
|
||||
|
||||
;; Many places set mark-active directly, and several of them failed to also
|
||||
;; run deactivate-mark-hook. This shorthand should simplify.
|
||||
(defsubst deactivate-mark ()
|
||||
(defsubst deactivate-mark (&optional force)
|
||||
"Deactivate the mark by setting `mark-active' to nil.
|
||||
\(That makes a difference only in Transient Mark mode.)
|
||||
Also runs the hook `deactivate-mark-hook'."
|
||||
(when transient-mark-mode
|
||||
(if (or (eq transient-mark-mode 'lambda)
|
||||
(and (eq (car-safe transient-mark-mode) 'only)
|
||||
(null (cdr transient-mark-mode))))
|
||||
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
|
||||
(x-set-selection 'PRIMARY (buffer-substring-no-properties
|
||||
(region-beginning) (region-end))))
|
||||
(if (and (null force)
|
||||
(or (eq transient-mark-mode 'lambda)
|
||||
(and (eq (car-safe transient-mark-mode) 'only)
|
||||
(null (cdr transient-mark-mode)))))
|
||||
;; When deactivating a temporary region, don't change
|
||||
;; `mark-active' or run `deactivate-mark-hook'.
|
||||
(setq transient-mark-mode nil)
|
||||
(if (eq (car-safe transient-mark-mode) 'only)
|
||||
(setq transient-mark-mode (cdr transient-mark-mode)))
|
||||
|
@ -3493,13 +3508,9 @@ Also runs the hook `deactivate-mark-hook'."
|
|||
(when (mark t)
|
||||
(setq mark-active t)
|
||||
(unless transient-mark-mode
|
||||
(setq transient-mark-mode 'lambda))))
|
||||
|
||||
(defcustom select-active-regions nil
|
||||
"If non-nil, an active region automatically becomes the window selection."
|
||||
:type 'boolean
|
||||
:group 'killing
|
||||
:version "23.1")
|
||||
(setq transient-mark-mode 'lambda))
|
||||
(when select-active-regions
|
||||
(x-set-selection 'PRIMARY (current-buffer)))))
|
||||
|
||||
(defun set-mark (pos)
|
||||
"Set this buffer's mark to POS. Don't use this function!
|
||||
|
@ -3522,15 +3533,13 @@ store it in a Lisp variable. Example:
|
|||
(progn
|
||||
(setq mark-active t)
|
||||
(run-hooks 'activate-mark-hook)
|
||||
(and select-active-regions
|
||||
(x-set-selection
|
||||
nil (buffer-substring (region-beginning) (region-end))))
|
||||
(when select-active-regions
|
||||
(x-set-selection 'PRIMARY (current-buffer)))
|
||||
(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 clear mark-active in any mode.
|
||||
(setq mark-active nil)
|
||||
(run-hooks 'deactivate-mark-hook)
|
||||
;; But when we actually clear out the mark value too, we must
|
||||
;; clear mark-active in any mode.
|
||||
(deactivate-mark t)
|
||||
(set-marker (mark-marker) nil)))
|
||||
|
||||
(defcustom use-empty-active-region nil
|
||||
|
|
Loading…
Add table
Reference in a new issue