From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: owner@emacsbugs.donarmstrong.com (Emacs bug Tracking System) Newsgroups: gmane.emacs.bugs Subject: bug#902: marked as done (select-active-regions only half-working) Date: Wed, 15 Jul 2009 01:40:04 +0000 Message-ID: References: <878wiqivfr.fsf@stupidchicken.com> <48C21AD8.1060505@harpegolden.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----------=_1247622004-26855-0" X-Trace: ger.gmane.org 1247623071 10138 80.91.229.12 (15 Jul 2009 01:57:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jul 2009 01:57:51 +0000 (UTC) To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 15 03:57:44 2009 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 1MQtkd-0006Dl-Lh for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Jul 2009 03:57:44 +0200 Original-Received: from localhost ([127.0.0.1]:45954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQtkc-0006wU-Sx for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Jul 2009 21:57:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQtkW-0006vW-M7 for bug-gnu-emacs@gnu.org; Tue, 14 Jul 2009 21:57:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQtkR-0006vK-3L for bug-gnu-emacs@gnu.org; Tue, 14 Jul 2009 21:57:35 -0400 Original-Received: from [199.232.76.173] (port=49582 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQtkQ-0006vH-T1 for bug-gnu-emacs@gnu.org; Tue, 14 Jul 2009 21:57:30 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:58456) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MQtkQ-0005dG-5r for bug-gnu-emacs@gnu.org; Tue, 14 Jul 2009 21:57:30 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6F1vS4k029763; Tue, 14 Jul 2009 18:57:28 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n6F1e5Jw026883; Tue, 14 Jul 2009 18:40:05 -0700 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: closed 902 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: patch X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:29428 Archived-At: This is a multi-part message in MIME format... ------------=_1247622004-26855-0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Your message dated Tue, 14 Jul 2009 21:31:04 -0400 with message-id <878wiqivfr.fsf@stupidchicken.com> and subject line Re: select-active-regions only half-working has caused the Emacs bug report #902, regarding select-active-regions only half-working to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com immediately.) --=20 902: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=3D902 Emacs Bug Tracking System Contact owner@emacsbugs.donarmstrong.com with problems ------------=_1247622004-26855-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-6.8 required=4.0 tests=AWL,BAYES_00,FVGT_m_MULTI_ODD, HAS_PACKAGE,MIXEDBDN,MURPHY_DRUGS_REL8,SPF_HELO_PASS autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 6 Sep 2008 05:53:40 +0000 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 m865rbGu025975 for ; Fri, 5 Sep 2008 22:53:38 -0700 Received: from golden1.harpegolden.net (unknown [86.45.10.133]) (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 1A01F81DE for ; Sat, 6 Sep 2008 06:53:35 +0100 (IST) Message-ID: <48C21AD8.1060505@harpegolden.net> Date: Sat, 06 Sep 2008 06:53:28 +0100 From: David De La Harpe Golden User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: submit@emacsbugs.donarmstrong.com Subject: select-active-regions only half-working X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------060103000303040901090207" This is a multi-part message in MIME format. --------------060103000303040901090207 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Package: emacs Version: 23.0.60 Severity: normal Tags: patch The select-active-regions in-tree does not work in all cases - it works when the region is changed by moving the mark but not when it is changed by certain other means e.g. moving the point with the keyboard. (Workaround: C-x C-x C-x C-x ...). There were a couple of approaches tried a while back (see emacs-devel "Improved X Selections" thread). The idle timer seemed to work best in practice, despite (or because of) "coarse graining" i.e. a bunch of small region changes in a row don't reupdate the selection for each change, only kicks in when emacs has idled. Attached patch is a simple idle-timer based implementation. Concerns here may also apply to the activate-mark-hook (which states in its documentation that it is rerun when region changes). Having that work similarly with the same method would probably mean that active region timer would have to be enabled whenever the mark is active, not just when select-active-regions is on. --------------060103000303040901090207 Content-Type: text/x-patch; name="select-active-regions-by-idle-timer.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="select-active-regions-by-idle-timer.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 05:41:14 -0000 @@ -3439,18 +3439,46 @@ (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-hash 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-hash) + (x-selection-owner-p nil)) + (let ((region-hash + (md5 (current-buffer) (region-beginning) + (region-end) nil t))) + (unless (string-equal region-hash + select-active-regions-last-region-hash) + (x-set-selection + nil (buffer-substring (region-beginning) (region-end))) + (setq select-active-regions-last-region-hash + region-hash))) + (setq select-active-regions-last-region-hash 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 +3494,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))) --------------060103000303040901090207 Content-Type: text/plain; name="ChangeLog.select-active-regions-by-idle-timer" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ChangeLog.select-active-regions-by-idle-timer" 2008-09-06 David De La Harpe Golden * simple.el: idle-timer implementation of select-active-regions --------------060103000303040901090207-- ------------=_1247622004-26855-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 902-done) by emacsbugs.donarmstrong.com; 15 Jul 2009 01:31:33 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.4 required=4.0 tests=AWL,MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from pantheon-po30.its.yale.edu (pantheon-po30.its.yale.edu [130.132.50.4]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6F1VR7T025994 for <902-done@emacsbugs.donarmstrong.com>; Tue, 14 Jul 2009 18:31:28 -0700 Received: from furry (dhcp128036014244.central.yale.edu [128.36.14.244]) (authenticated bits=0) by pantheon-po30.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id n6F1V59U020189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 14 Jul 2009 21:31:05 -0400 Received: by furry (Postfix, from userid 1000) id 94D53C09B; Tue, 14 Jul 2009 21:31:04 -0400 (EDT) From: Chong Yidong To: David De La Harpe Golden Cc: 902-done@emacsbugs.donarmstrong.com Subject: Re: select-active-regions only half-working Date: Tue, 14 Jul 2009 21:31:04 -0400 Message-ID: <878wiqivfr.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) Hi David, I've checked a revamped version of your patch into the trunk. Thanks very much for figuring out the details for making this work. ------------=_1247622004-26855-0--