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: Drew Adams
Subject: RE: set-temporary-overlay-map doesn't work for me
Date: Wed, 27 Nov 2013 14:00:52 -0800 (PST)

> (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.

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.

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]