From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David De La Harpe Golden Newsgroups: gmane.emacs.bugs Subject: bug#902: Acknowledgement (select-active-regions only half-working) Date: Sat, 06 Sep 2008 20:35:29 +0100 Message-ID: <48C2DB81.2080007@harpegolden.net> References: <48C21AD8.1060505@harpegolden.net> Reply-To: David De La Harpe Golden , 902@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080507030205070504020707" X-Trace: ger.gmane.org 1220730481 20226 80.91.229.12 (6 Sep 2008 19:48:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Sep 2008 19:48:01 +0000 (UTC) To: 902@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 06 21:48:56 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kc3m9-0003MI-Sm for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Sep 2008 21:48:54 +0200 Original-Received: from localhost ([127.0.0.1]:34469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kc3lA-0006TM-8z for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Sep 2008 15:47:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kc3ku-0006Do-Gr for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 15:47:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kc3ks-0006Az-NB for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 15:47:35 -0400 Original-Received: from [199.232.76.173] (port=36278 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kc3ks-0006Al-B1 for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 15:47:34 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:48324) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kc3kr-0006vh-Rh for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 15:47:34 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m86JlWtr023797; Sat, 6 Sep 2008 12:47:32 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m86Jj547022439; Sat, 6 Sep 2008 12:45:05 -0700 X-Loop: don@donarmstrong.com Resent-From: David De La Harpe Golden Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 06 Sep 2008 19:45:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 902 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: patch Original-Received: via spool by 902-submit@emacsbugs.donarmstrong.com id=B902.122072973720106 (code B ref 902); Sat, 06 Sep 2008 19:45:05 +0000 Original-Received: (at 902) by emacsbugs.donarmstrong.com; 6 Sep 2008 19:35:37 +0000 Original-Received: from harpegolden.net (harpegolden.net [65.99.215.13]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m86JZXnc020100 for <902@emacsbugs.donarmstrong.com>; Sat, 6 Sep 2008 12:35:34 -0700 Original-Received: from golden1.harpegolden.net (86-43-162-117.b-ras2.prp.dublin.eircom.net [86.43.162.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "David De La Harpe Golden", Issuer "David De La Harpe Golden Personal CA rev 3" (verified OK)) by harpegolden.net (Postfix) with ESMTP id 7B86081DE for <902@emacsbugs.donarmstrong.com>; Sat, 6 Sep 2008 20:35:32 +0100 (IST) User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) In-Reply-To: X-Enigmail-Version: 0.95.0 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Sat, 06 Sep 2008 15:47:35 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:20245 Archived-At: This is a multi-part message in MIME format. --------------080507030205070504020707 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Uh. Hashing is probably silly/pointless in this case (wrote that far too early in the morning...). Revised patch attached, just saves last region and uses string-equal. --------------080507030205070504020707 Content-Type: text/x-patch; name="select-active-regions-by-idle-timer_rev2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="select-active-regions-by-idle-timer_rev2.diff" Index: lisp/simple.el =================================================================== RCS file: /sources/emacs/emacs/lisp/simple.el,v retrieving revision 1.945 diff -U 8 -r1.945 simple.el --- lisp/simple.el 15 Aug 2008 00:30:44 -0000 1.945 +++ lisp/simple.el 6 Sep 2008 19:33:00 -0000 @@ -3439,18 +3439,45 @@ (defun activate-mark () "Activate the mark." (when (mark t) (setq mark-active t) (unless transient-mark-mode (setq transient-mark-mode 'lambda)))) +(defvar select-active-regions-timer nil) + +(defvar select-active-regions-last-region nil) + +(defun select-active-regions-maybe-set-selection () + "Implements `select-active-regions', called from idle timer +`select-active-regions-timer'" + (and select-active-regions + (region-active-p) + (> (region-end) (region-beginning)) + (if (or (not select-active-regions-last-region) + (x-selection-owner-p nil)) + (let ((latest-region + (buffer-substring (region-beginning) (region-end)))) + (unless (string-equal latest-region + select-active-regions-last-region) + (x-set-selection + nil latest-region) + (setq select-active-regions-last-region + latest-region))) + (setq select-active-regions-last-region nil)))) + (defcustom select-active-regions nil - "If non-nil, an active region automatically becomes the window selection." + "If non-nil, an active region automatically becomes the window selection. + +In conjunction with this, you might want to: +rebind mouse-2 to `mouse-yank-primary', set `x-select-enable-primary' to nil, +set `x-select-enable-clipboard' to non-nil, set `mouse-drag-copy-region' +to nil, and turn on `transient-mark-mode'." :type 'boolean :group 'killing :version "23.1") (defun set-mark (pos) "Set this buffer's mark to POS. Don't use this function! That is to say, don't use this function unless you want the user to see that the mark has moved, and you want the previous @@ -3466,19 +3493,26 @@ store it in a Lisp variable. Example: (let ((beg (point))) (forward-line 1) (delete-region beg (point)))." (if pos (progn (setq mark-active t) (run-hooks 'activate-mark-hook) - (and select-active-regions - (x-set-selection - nil (buffer-substring (region-beginning) (region-end)))) + (if select-active-regions + (progn + (unless select-active-regions-timer + (setq select-active-regions-timer + (run-with-idle-timer + 0.1 t 'select-active-regions-maybe-set-selection))) + (select-active-regions-maybe-set-selection)) + (when select-active-regions-timer + (cancel-timer select-active-regions-timer) + (setq select-active-regions-timer nil))) (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) (set-marker (mark-marker) nil))) --------------080507030205070504020707--