emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog info.el mouse.el select.el...


From: Chong Yidong
Subject: [Emacs-diffs] emacs/lisp ChangeLog info.el mouse.el select.el...
Date: Wed, 15 Jul 2009 01:25:38 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      09/07/15 01:25:37

Modified files:
        lisp           : ChangeLog info.el mouse.el select.el simple.el 

Log message:
        * 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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.15807&r2=1.15808
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/info.el?cvsroot=emacs&r1=1.560&r2=1.561
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/mouse.el?cvsroot=emacs&r1=1.353&r2=1.354
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/select.el?cvsroot=emacs&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/simple.el?cvsroot=emacs&r1=1.991&r2=1.992

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.15807
retrieving revision 1.15808
diff -u -b -r1.15807 -r1.15808
--- ChangeLog   14 Jul 2009 19:57:58 -0000      1.15807
+++ ChangeLog   15 Jul 2009 01:25:32 -0000      1.15808
@@ -1,3 +1,30 @@
+2009-07-15  Chong Yidong  <address@hidden>
+
+       * 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  <address@hidden>
+
+       * 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  <address@hidden>
 
        * simple.el (mail-user-agent): Default to the upwardly-UI-compatible

Index: info.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/info.el,v
retrieving revision 1.560
retrieving revision 1.561
diff -u -b -r1.560 -r1.561
--- info.el     2 Jul 2009 22:47:33 -0000       1.560
+++ info.el     15 Jul 2009 01:25:36 -0000      1.561
@@ -1693,8 +1693,7 @@
                        (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

Index: mouse.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/mouse.el,v
retrieving revision 1.353
retrieving revision 1.354
diff -u -b -r1.353 -r1.354
--- mouse.el    31 Jan 2009 22:14:56 -0000      1.353
+++ mouse.el    15 Jul 2009 01:25:36 -0000      1.354
@@ -681,26 +681,26 @@
 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 @@
                              (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 @@
     (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.

Index: select.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/select.el,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- select.el   14 Jul 2009 16:58:29 -0000      1.49
+++ select.el   15 Jul 2009 01:25:36 -0000      1.50
@@ -122,15 +122,16 @@
 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 @@
   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 @@
   "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))

Index: simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.991
retrieving revision 1.992
diff -u -b -r1.991 -r1.992
--- simple.el   14 Jul 2009 19:58:03 -0000      1.991
+++ simple.el   15 Jul 2009 01:25:37 -0000      1.992
@@ -3472,16 +3472,31 @@
       (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)
+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))))
+                     (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 @@
   (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 @@
       (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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]