I have defined some keymaps on org-mode src-blocks. If I click in the block with a mouse, I see the keymap is changed, e.g. the menu items change, and the new keybindings are active. However, if I use C-n or C-p to get into the block, the keymap is not changed. However, as soon as I edit the block, the keymap becomes active. The keymaps are added during font-lock via:

             beg end `(local-map ,some-key-map))))

inside a function that is added to org-font-lock-hook.

Is there something different about mouse motion and cursor motion that would cause this difference?

  • AFAIK, text property maps only depend on current point, not how it got there. How exactly are you testing that keybindings are active? Is this only an issue with org-src blocks? Do you have org-src-fontify-natively and/or org-src-tab-acts-natively set?
    – npostavs
    Commented Jun 12, 2017 at 17:44
  • I have both of those things set to t. The test is whether the emacs menu changes to show the mode menus in the src blocks. If I click in the src block they do, and if I use keyboard navigation they don't. I have added a cursor-sensor-function that calls (org-mouse-down-mouse nil), and this makes it work whether I click or navigate in. Commented Jun 12, 2017 at 18:20

1 Answer 1


What is probably happening is just that the menu is not re-computed.

You need to call force-mode-line-update after the cursor moves into (or out-of) the text bloc where you applied that local-map property. You could do that by using something like

(cursor-sensor-mode 1)
 beg end `(local-map ,some-key-map
           cursor-sensor-functions my-csf-menu-update))))

along with

(defun my-csf-menu-update (&rest _)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.