all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
       [not found] ` <E1YHEHT-00086o-LX@vcs.savannah.gnu.org>
@ 2015-01-30 18:18   ` Stefan Monnier
  2015-01-30 18:20     ` Oleh Krehel
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-01-30 18:18 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

>     hydra.el (defhydra): Use `clear-temporary-overlay-map'
    
Hmm... when/where is this function defined?


        Stefan



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

* Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
  2015-01-30 18:18   ` [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map' Stefan Monnier
@ 2015-01-30 18:20     ` Oleh Krehel
  2015-01-30 20:02       ` Oleh Krehel
  2015-01-30 21:06       ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Oleh Krehel @ 2015-01-30 18:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>     hydra.el (defhydra): Use `clear-temporary-overlay-map'
>     
> Hmm... when/where is this function defined?

It's generated by legacy code in at least in Emacs 24.3.4.  Newest
Emacs doesn't have it. It's a hack, but I need the older Emacs
versions to work.  See the old code:

    (defun set-temporary-overlay-map (map &optional keep-pred)
      "Set MAP as a temporary keymap taking precedence over most other keymaps.
    Note that this does NOT take precedence over the \"overriding\" maps
    `overriding-terminal-local-map' and `overriding-local-map' (or the
    `keymap' text property).  Unlike those maps, if no match for a key is
    found in MAP, the normal key lookup sequence then continues.
    
    Normally, MAP is used only once.  If the optional argument
    KEEP-PRED is t, MAP stays active if a key from MAP is used.
    KEEP-PRED can also be a function of no arguments: if it returns
    non-nil then MAP stays active."
      (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
             (overlaysym (make-symbol "t"))
             (alist (list (cons overlaysym map)))
             (clearfun
              ;; FIXME: Use lexical-binding.
              `(lambda ()
                 (unless ,(cond ((null keep-pred) nil)
                                ((eq t keep-pred)
                                 `(eq this-command
                                      (lookup-key ',map
                                                  (this-command-keys-vector))))
                                (t `(funcall ',keep-pred)))
                   (set ',overlaysym nil)   ;Just in case.
                   (remove-hook 'pre-command-hook ',clearfunsym)
                   (setq emulation-mode-map-alists
                         (delq ',alist emulation-mode-map-alists))))))
        (set overlaysym overlaysym)
        (fset clearfunsym clearfun)
        (add-hook 'pre-command-hook clearfunsym)
        ;; FIXME: That's the keymaps with highest precedence, except for
        ;; the `keymap' text-property ;-(
        (push alist emulation-mode-map-alists)))

Oleh



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

* Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
  2015-01-30 18:20     ` Oleh Krehel
@ 2015-01-30 20:02       ` Oleh Krehel
  2015-01-30 21:06       ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Oleh Krehel @ 2015-01-30 20:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Oleh Krehel <ohwoeowho@gmail.com> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>>     hydra.el (defhydra): Use `clear-temporary-overlay-map'
>>     
>> Hmm... when/where is this function defined?
>
> It's generated by legacy code in at least in Emacs 24.3.4.  Newest
> Emacs doesn't have it. It's a hack, but I need the older Emacs
> versions to work.  See the old code:
>
>     (defun set-temporary-overlay-map (map &optional keep-pred)
>       "Set MAP as a temporary keymap taking precedence over most other keymaps.
>     Note that this does NOT take precedence over the \"overriding\" maps
>     `overriding-terminal-local-map' and `overriding-local-map' (or the
>     `keymap' text property).  Unlike those maps, if no match for a key is
>     found in MAP, the normal key lookup sequence then continues.
>     
>     Normally, MAP is used only once.  If the optional argument
>     KEEP-PRED is t, MAP stays active if a key from MAP is used.
>     KEEP-PRED can also be a function of no arguments: if it returns
>     non-nil then MAP stays active."
>       (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
>              (overlaysym (make-symbol "t"))
>              (alist (list (cons overlaysym map)))
>              (clearfun
>               ;; FIXME: Use lexical-binding.
>               `(lambda ()
>                  (unless ,(cond ((null keep-pred) nil)
>                                 ((eq t keep-pred)
>                                  `(eq this-command
>                                       (lookup-key ',map
>                                                   (this-command-keys-vector))))
>                                 (t `(funcall ',keep-pred)))
>                    (set ',overlaysym nil)   ;Just in case.
>                    (remove-hook 'pre-command-hook ',clearfunsym)
>                    (setq emulation-mode-map-alists
>                          (delq ',alist emulation-mode-map-alists))))))
>         (set overlaysym overlaysym)
>         (fset clearfunsym clearfun)
>         (add-hook 'pre-command-hook clearfunsym)
>         ;; FIXME: That's the keymaps with highest precedence, except for
>         ;; the `keymap' text-property ;-(
>         (push alist emulation-mode-map-alists)))

Oops, I see now that the change wasn't actually working. See the next
fixing commit. Is there a more straightforward way to programmatically
disable the effect of `set-temporary-overlay-map'?

Oleh



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

* Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
  2015-01-30 18:20     ` Oleh Krehel
  2015-01-30 20:02       ` Oleh Krehel
@ 2015-01-30 21:06       ` Stefan Monnier
  2015-01-30 21:40         ` Oleh Krehel
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-01-30 21:06 UTC (permalink / raw)
  To: Oleh Krehel; +Cc: emacs-devel

>>> hydra.el (defhydra): Use `clear-temporary-overlay-map'
>> Hmm... when/where is this function defined?
> It's generated by legacy code in at least in Emacs 24.3.4.

No, that's a misunderstanding:

>       (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))

This creates a symbol whose name is "clear-temporary-overlay-map" but
this symbol is different from the one you get with:

   'clear-temporary-overlay-map

So you can't call this function the way you do it.


        Stefan



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

* Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
  2015-01-30 21:06       ` Stefan Monnier
@ 2015-01-30 21:40         ` Oleh Krehel
  0 siblings, 0 replies; 5+ messages in thread
From: Oleh Krehel @ 2015-01-30 21:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Fri, Jan 30, 2015 at 10:06 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>>> hydra.el (defhydra): Use `clear-temporary-overlay-map'
>>> Hmm... when/where is this function defined?
>> It's generated by legacy code in at least in Emacs 24.3.4.
>
> No, that's a misunderstanding:
>
>>       (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
>
> This creates a symbol whose name is "clear-temporary-overlay-map" but
> this symbol is different from the one you get with:
>
>    'clear-temporary-overlay-map
>
> So you can't call this function the way you do it.

Yes, I got it. It had to be interned, but it wasn't.
See the newer commit, it does something different.

Oleh



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

end of thread, other threads:[~2015-01-30 21:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20150130161848.31066.83266@vcs.savannah.gnu.org>
     [not found] ` <E1YHEHT-00086o-LX@vcs.savannah.gnu.org>
2015-01-30 18:18   ` [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map' Stefan Monnier
2015-01-30 18:20     ` Oleh Krehel
2015-01-30 20:02       ` Oleh Krehel
2015-01-30 21:06       ` Stefan Monnier
2015-01-30 21:40         ` Oleh Krehel

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.