I installed undo-tree-mode into my emacs. It does have a lot of nifty features, one of them being undo-tree-redo (bound to M-_). It so useful that I put the following code inside my ~/.emacs.d/init.el:

;; Always activate undo-tree-mode because of redo (M-_)
(add-hook 'find-file-hook #'undo-tree-mode)

After some time, I started learning LISP and installed slime-mode. However, now whenever I press M-_ while in lisp-mode the command slime-edit-uses is executed instead of undo-tree-redo. Even after adding the following (trying to follow the suggestions of this and this questions, and this and this links) to my init.el doesn't bring back undo-tree-redo to M-_:

;; Unbind slime's keybind's hijacking
(defun override-slime ()
  (define-key slime-repl-mode-map
    (read-kbd-macro paredit-backward-delete-key) nil)
  (define-key slime-repl-mode-map (kbd "M-_") nil)
  (define-key slime-mode-indirect-map (kbd "M-_") nil)
  (define-key undo-tree-map (kbd "M-_") 'undo-tree-redo))

(eval-after-load "slime-mode"
  '(define-key slime-mode-indirect-map (kbd "M-_") nil))

(add-hook 'slime-repl-mode-hook 'override-slime)

How can I bring undo-tree-redo back to M-_?

PS: I don't think any other code of my init.el may be influencing or doing something funny with the code above. In any case, here is my init.el.

PS2: C-h k M-_ returns:

M-_ runs the command slime-edit-uses (found in
slime-mode-indirect-map), which is an interactive compiled Lisp
function in ‘../elpa/slime-2.20/slime.el’.

It is bound to M-?, M-_.

However M-? is an inconvenient keybind for me. I'm using Emacs 25.2.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.