From: owner@emacsbugs.donarmstrong.com (Emacs bug Tracking System)
To: Chong Yidong <cyd@stupidchicken.com>
Subject: bug#902: marked as done (select-active-regions only half-working)
Date: Wed, 15 Jul 2009 01:40:04 +0000 [thread overview]
Message-ID: <handler.902.D902.124762149325999.ackdone@emacsbugs.donarmstrong.com> (raw)
In-Reply-To: 48C21AD8.1060505@harpegolden.net
[-- Attachment #1: Type: text/plain, Size: 867 bytes --]
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.)
--
902: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=902
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems
[-- Attachment #2: Type: message/rfc822, Size: 6331 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 1026 bytes --]
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.
[-- Attachment #2.1.2: select-active-regions-by-idle-timer.diff --]
[-- Type: text/x-patch, Size: 3131 bytes --]
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)))
[-- Attachment #2.1.3: ChangeLog.select-active-regions-by-idle-timer --]
[-- Type: text/plain, Size: 127 bytes --]
2008-09-06 David De La Harpe Golden <david@harpegolden.net>
* simple.el: idle-timer implementation of select-active-regions
[-- Attachment #3: Type: message/rfc822, Size: 1595 bytes --]
From: Chong Yidong <cyd@stupidchicken.com>
To: David De La Harpe Golden <david@harpegolden.net>
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>
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.
prev parent reply other threads:[~2009-07-15 1:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <878wiqivfr.fsf@stupidchicken.com>
2008-09-06 5:53 ` bug#902: select-active-regions only half-working David De La Harpe Golden
[not found] ` <handler.902.B.122068042025981.ack@emacsbugs.donarmstrong.com>
2008-09-06 19:35 ` bug#902: Acknowledgement (select-active-regions only half-working) David De La Harpe Golden
2008-09-06 19:50 ` bug#902: select-active-regions only half-working Stefan Monnier
2008-09-06 20:22 ` David De La Harpe Golden
2008-09-07 3:53 ` Stefan Monnier
2008-09-07 20:27 ` David De La Harpe Golden
2008-09-07 21:20 ` Stefan Monnier
2008-09-09 0:42 ` David De La Harpe Golden
2008-09-09 14:50 ` Stefan Monnier
2008-09-09 19:20 ` David De La Harpe Golden
2008-09-10 16:37 ` Stefan Monnier
2008-09-10 21:45 ` David De La Harpe Golden
2008-09-11 2:01 ` Stefan Monnier
2008-09-11 2:40 ` David De La Harpe Golden
2009-01-25 23:44 ` David De La Harpe Golden
2009-07-15 1:40 ` Emacs bug Tracking System [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=handler.902.D902.124762149325999.ackdone@emacsbugs.donarmstrong.com \
--to=owner@emacsbugs.donarmstrong.com \
--cc=cyd@stupidchicken.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).