all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#21033: 25.0.50; `local-map' property inside `:eval' sexp in mode-line
@ 2015-07-10 21:01 Drew Adams
  2015-07-10 22:24 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2015-07-10 21:01 UTC (permalink / raw)
  To: 21033

This might not be a bug, but I cannot seem to figure it out.
If it is not, please let me know what I'm missing.

This code puts string "abcdefg" in the mode-line with text property
`local-map', which has a single key binding to command `foo' for
`mouse-2'.

(setq global-mode-string
      '(:eval (let* ((map  (make-sparse-keymap))
		     (str  "abcdefg"))
		(define-key map [mouse-2] 'foo)
		(add-text-properties 0 (1- (length str))
				      `(local-map ,map) str)
		str)))

(defun foo (ev)
  (interactive "e")
  (message "@@@@@@@@@@@@@"))

I've fiddled with umpteen variations, but I cannot seem to get the
`local-map' property (or the `keymap' property) to have any effect
within an `:eval' form.

It is perhaps the case that this is simply not supported?  I don't see
anything in the doc saying that.  I'm hoping that I'm just missing
something, and there is a simple way to accomplish this.


In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2015-07-03 on LEG570
Repository revision: 2b848fadd51e805b2f46da64c5958ea7f009048a
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --host=i686-pc-mingw32 --enable-checking=yes,glyphs'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#21033: 25.0.50; `local-map' property inside `:eval' sexp in mode-line
  2015-07-10 21:01 bug#21033: 25.0.50; `local-map' property inside `:eval' sexp in mode-line Drew Adams
@ 2015-07-10 22:24 ` Stefan Monnier
  2015-07-10 23:03   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2015-07-10 22:24 UTC (permalink / raw)
  To: Drew Adams; +Cc: 21033

> 		(define-key map [mouse-2] 'foo)
                                ^^^^^^^^^

events on the mode-line have a `mode-line' prefix.
IOW, you want to use [mode-line mouse-2].
This seems completely weird in this case, but it makes a lot of sense
when the binding comes from the buffer-local (or the global) keymap,
since it lets us define different bindings for clicks inside the window
and in the mode-line.


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#21033: 25.0.50; `local-map' property inside `:eval' sexp in mode-line
  2015-07-10 22:24 ` Stefan Monnier
@ 2015-07-10 23:03   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2015-07-10 23:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 21033

> > 		(define-key map [mouse-2] 'foo)
>                                 ^^^^^^^^^
> 
> events on the mode-line have a `mode-line' prefix.

Ay, caramba ! (aka Merde !)  Thank you!

I should have thought of that.  I'm glad I asked, because I'm
pretty sure that would not have occurred to me, though it
probably should have.

I'll close the bug.

> IOW, you want to use [mode-line mouse-2].
> This seems completely weird in this case, but it makes a lot of sense
> when the binding comes from the buffer-local (or the global) keymap,
> since it lets us define different bindings for clicks inside the window
> and in the mode-line.

Got it.  Thx.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-10 23:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-10 21:01 bug#21033: 25.0.50; `local-map' property inside `:eval' sexp in mode-line Drew Adams
2015-07-10 22:24 ` Stefan Monnier
2015-07-10 23:03   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.