From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mihai Bazon Newsgroups: gmane.emacs.bugs Subject: bug#4081: Overlay keymap and timers Date: Sat, 8 Aug 2009 12:24:51 +0300 Message-ID: <3404e64848e91742a2a6e2e51ca8a285@bazon.net> Reply-To: Mihai Bazon , 4081@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1249740671 16150 80.91.229.12 (8 Aug 2009 14:11:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Aug 2009 14:11:11 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 08 16:11:04 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 1MZmdT-0003A3-DO for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Aug 2009 16:11:03 +0200 Original-Received: from localhost ([127.0.0.1]:39546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZmdS-0005QA-Oo for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Aug 2009 10:11:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MZipG-000826-3J for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 06:06:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MZipA-00080D-87 for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 06:06:56 -0400 Original-Received: from [199.232.76.173] (port=55534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZip9-000806-UU for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 06:06:52 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:48367) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MZip9-0005Ti-5y for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 06:06:51 -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 n78A6mh0011416; Sat, 8 Aug 2009 03:06:48 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n789t5wN009449; Sat, 8 Aug 2009 02:55:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Mihai Bazon Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 08 Aug 2009 09:55:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4081 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12497247658812 (code B ref -1); Sat, 08 Aug 2009 09:55:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 8 Aug 2009 09:46:05 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n789k2sN008808 for ; Sat, 8 Aug 2009 02:46:04 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MZiUz-0000y0-Gv for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 05:46:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MZiUy-0000xi-D8 for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 05:46:00 -0400 Original-Received: from [199.232.76.173] (port=50551 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZiUx-0000xa-Vl for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 05:46:00 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:5873) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MZiUx-00020X-6m for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 05:45:59 -0400 Original-Received: from ip-72-55-183-145.static.privatedns.com ([72.55.183.145] helo=v1.dynarch.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MZiUv-0007kN-Jl for bug-gnu-emacs@gnu.org; Sat, 08 Aug 2009 05:45:57 -0400 Original-Received: by v1.dynarch.com (Postfix, from userid 5001) id BFBF01D80002; Sat, 8 Aug 2009 12:24:53 +0300 (EEST) Original-Received: from v3.dynarch.com (ip-72-55-183-147.static.privatedns.com [72.55.183.147]) by v1.dynarch.com (Postfix) with SMTP id AEAEB1DCC5D for ; Sat, 8 Aug 2009 12:24:51 +0300 (EEST) Original-Received: (nullmailer pid 23120 invoked by uid 65534); Sat, 08 Aug 2009 09:24:51 -0000 Content-Disposition: inline X-Mailer: XUHEKI - Dynarch.com WebMail X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Sat, 08 Aug 2009 06:06:56 -0400 X-Mailman-Approved-At: Sat, 08 Aug 2009 10:10:57 -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:29990 Archived-At: Hi folks, I identified a possible bug, just wondering if there's a known workaround. Please CC me in any reply as I'm not subscribed to the list. Short description =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D When creating overlays in a function called by run-with-timer, their keymap becomes available only *after* some key has been pressed. Sample code =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq counter 0) (setq my-keymap (make-sparse-keymap)) (define-key my-keymap (kbd "M-n")=20 (lambda() (interactive) (message "Got it %s!" (setq counter (+ counter 1))))) =20=20=20=20 (defun my-highlight () (interactive) (save-excursion (beginning-of-buffer) (while (search-forward-regexp "\\" nil t) (let ((overlay (make-overlay (- (point) 7) (point)))) (overlay-put overlay 'face 'highlight) (overlay-put overlay 'evaporate t) ;; using 'local-map doesn't make any difference (overlay-put overlay 'keymap my-keymap) (overlay-put overlay 'my-property t))))) =20=20=20=20 (defun my-highlight-with-timer () (interactive) (run-with-timer 0.5 nil 'my-highlight)) =20=20=20=20 (defun my-highlight-clear () (interactive) (remove-overlays (point-min) (point-max) 'my-property t)) Eval this code, then type "overlay" in some buffer and move the caret somewhere in the middle of the word. * Case 1. M-x my-highlight. The word gets colored. If you press M-n, it will display "Got it 1!" in the minibuffer -- works as expected. Now clear it with M-x my-highlight-clear. * Case 2. M-x my-highlight-with-timer. After half a second, the word gets colored. If we immediately press M-n now, we get "M-n is=20 undefined". However, pressing M-n a second time works. Clear it again with my-highlight-clear. * Case 3. M-x my-highlight-with-timer, then press some key such as C-f (make sure the cursor doesn't leave the overlay). Then pressing M-n works as expected. My guess is that the keymap becomes active the moment a key is released (?) (or in some post-command-hook?) and the cursor is within the overlay. So if set without a timer, it gets a chance to be activated straight away, but with a timer there isn't any key release to trigger it so it becomes active only after some key has been pressed. Not sure if this is a bug, but it's sure annoying and I've no idea how to work around it. Any help is appreciated. Cheers, -Mihai=