[Top][All Lists]

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

Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary

From: Oleh Krehel
Subject: Re: [elpa] master 785f837 6/8: hydra.el (defhydra): Use `clear-temporary-overlay-map'
Date: Fri, 30 Jan 2015 21:02:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Oleh Krehel <address@hidden> writes:

> Stefan Monnier <address@hidden> 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'?


reply via email to

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