help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set-temporary-overlay-map doesn't work for me


From: Andrey Tykhonov
Subject: Re: set-temporary-overlay-map doesn't work for me
Date: Thu, 28 Nov 2013 00:40:16 +0200
User-agent: mu4e 0.9.9; emacs 24.3.1

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]