From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrey Tykhonov Newsgroups: gmane.emacs.help Subject: Re: set-temporary-overlay-map doesn't work for me Date: Thu, 28 Nov 2013 00:40:16 +0200 Message-ID: <87fvqhwjsf.fsf@gmail.com> References: <87y549y1g6.fsf@gmail.com>, <4ecc8b65-0f0f-49c4-a32e-a58d6efc8d38@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1385592414 1762 80.91.229.3 (27 Nov 2013 22:46:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Nov 2013 22:46:54 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Drew Adams" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 27 23:46:57 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vlnsm-00022w-Qg for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Nov 2013 23:46:56 +0100 Original-Received: from localhost ([::1]:38178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlnsm-0005IT-E6 for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Nov 2013 17:46:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlnsT-0005IG-FY for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 17:46:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlnsI-000791-TY for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 17:46:37 -0500 Original-Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]:57400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlnsI-00078c-Kc for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 17:46:26 -0500 Original-Received: by mail-la0-f42.google.com with SMTP id ec20so5677314lab.1 for ; Wed, 27 Nov 2013 14:46:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:user-agent:in-reply-to:date :message-id:mime-version:content-type; bh=qxB34NhrOpPewrrkQJzsriw9c9PIeADz79wNQyWxAa4=; b=zcrR8gNmqw3qhR1DYDr4o6ksYN0PfAcCjxIKoX3U3gIUw45zAhakOuKDCEzPeA9Dav 4waktdkk2BWRGxMouV/0478XGyGW9vxcmtAMNTSEPiIeQjWZetpdzwrKVbCAk38NSSro CaOF4IAk2sJWn+0OVUHcDnAnq/u1THJJgiQzT8lgKDMXbVJu7oHM/HEBmj7RJNgk21a/ 7xleHEeaIPo26jyyj15bp3mbrsi0oNQSbuYbRqR3+e59I9vf2Or0SY88dQfV0F7+QWns Mv/qV4xL2bYj+1G2tN6QClxLLFoFK4Cm/nDpIlyua9/+YMD8PN7bOFVOSwYWqUHM1wTc 0X5A== X-Received: by 10.112.150.103 with SMTP id uh7mr2757187lbb.34.1385592385496; Wed, 27 Nov 2013 14:46:25 -0800 (PST) Original-Received: from demi.gmail ([193.84.22.38]) by mx.google.com with ESMTPSA id xl4sm52112934lac.9.2013.11.27.14.46.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 27 Nov 2013 14:46:24 -0800 (PST) User-agent: mu4e 0.9.9; emacs 24.3.1 In-reply-to: <4ecc8b65-0f0f-49c4-a32e-a58d6efc8d38@default> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22a X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94686 Archived-At: Drew Adams writes: >> (defun my-temp () >> (interactive) >> (set-temporary-overlay-map >> (let ((map (make-sparse-keymap))) >> (define-key map [mouse-1] 'my-mouse-down) >> map))) >> >> (defun my-mouse-down () >> (interactive) >> (message "Word is: %s " (thing-at-point 'word))) >> >> I evaluate them, then M-x my-temp RET, then mouse click (left button) on >> "interactive" world and I'm expecting to see "Word is "interactive"" >> message in the minibuffer. But no messages appear! > > `my-temp' does not read your mouse click. It binds the keymap, and > then it exits. And then you click your mouse, with the binding no > longer in effect. I wonder: why (kbd "C-c C-c") binding (in case if place it instead of [mouse-1]) still in effect even after `my-temp` exits? I was expecting that [mouse-1] will be behaved in the same way. > One approach would be to read an event inside your `my-temp', and > ignore it if not a mouse click. To do something cleaner than that > we would need to see the overall context - what you really want to do. Well, I'll try read an event! Thank you a lot! Best regards, Andrey > > But if this is all there is, then it seems you want to invoke a > command (why a command?) that reads an event, and if that event is a > mouse click then invoke `my-mouse-down'. Or perhaps you want to > read events until you get a mouse click event... > > Anyway, that's the problem. Either describe what you really need > or work it out knowing what this problem is.