Isearch does not use regular commands. (kbd "_") together with all the other printable characters, is tied to a special command in isearch-mode-map . This is not obvious, but in "isearch-mode" a lot of things happen when you press the key. The display is updated with new results, packaging is possible, etc. Etc.,
You will need to manipulate the raw keyboard events, to make it work.
(defun underscore () (interactive) (isearch-unread-key-sequence (list ?_))) (define-key isearch-mode-map (kbd "Mu") 'underscore)
Please note that this code is not reliable; for example, a numeric prefix does not work.
EDIT: After I held out in my brain for a while, it seemed to me that this was an exact precedent for broadcast layouts
(define-key key-translation-map (kbd "Mu") (kbd "_"))
Emacs does not grand?
source share