I would like to bind TAB
to my company-mode back-end only for the duration of a command's execution. I am trying to achieve this by using dynamic scoping as follows (the irrelevant part of the function is not shown):
(defun my-function()
(interactive)
(let ((company-mode-map (copy-sequence company-mode-map)))
(define-key company-mode-map (kbd "TAB") 'my-company-backend)
MORE-CODE-HERE))
The new binding does not work (though it did work when I performed it outside of my-function
). Why does this use of dynamic scoping not produce the result that I expected and how do I fix it?