title: Override (globally override key binding in emacs) temporarily
body: <p>I use the method stated here : <a href="https://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs">globally-override-key-binding-in-emacs</a></p>
  
  <pre><code>(defvar my-keys-minor-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map (kbd "C-i") 'some-function)
      map)
    "my-keys-minor-mode keymap.")
  
  (define-minor-mode my-keys-minor-mode
    "A minor mode so that my key settings override annoying major modes."
    ;; Define-minor-mode will use `my-keys-minor-mode-map' for us.
    :init-value t
    :lighter " my-keys")
  
  (defun my-keys-keep-on-top (&amp;rest _)
    "Try to ensure that my keybindings always have priority."
    (unless (eq (caar minor-mode-map-alist) 'my-keys-minor-mode)
      (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
        (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
        (add-to-list 'minor-mode-map-alist mykeys))))
  (add-hook 'after-load-functions #'my-keys-keep-on-top)
  
  (my-keys-minor-mode 1)
  </code></pre>
  
  <p>How to I explicitly override this?
  The methods in the link is not working to me.</p>
  
  <p><strong>EDIT2 :</strong></p>
  
  <p>Issue is not only applied to read only mode. The <code>eval-after-load</code> is not a good method since it makes change to <code>my-minor-mode-keymap</code> in long term.</p>
  
  <p>I put another example here:</p>
  
  <p>I use program mode for most of the time. Suppose I want to have <code>C-q</code> bind to syntax-check in program mode. However, I jot notes in text mode sometime. It makes no sense to have syntax check in text mode. So I decide to have <code>C-q</code> bind to spell-check.</p>
  
  <p>Under normal circumstances, I would do this</p>
  
  <pre><code>(global-set-key (kbd "C-q") 'syntax-check)
  (define-key text-mode-map (kbd "C-q") 'spell-check)
  </code></pre>
  
  <p>How to have such effect if I define my-keys-minor-mode-map?
  Assume I put this in my keymap:</p>
  
  <pre><code>(define-key 'my-keys-minor-mode-map (kbd "C-q") 'syntax-check)
  </code></pre>
  
  <p><code>(define-key text-mode-map (kbd "C-q") 'spell-check)</code> doesn't work since my keymap always has precedence over other minor mode mapping.</p>
  
  <p>Neither</p>
  
  <pre><code>(eval-after-load "text-mode"
    (define-key my-keys-minor-mode-map (kbd "C-q") 'spell-check))
  </code></pre>
  
  <p>nor</p>
  
  <pre><code>(add-hook 'text-mode-map (lambda () 
    (define-key my-keys-minor-mode-map (kbd "C-q") 'spell-check)))
  </code></pre>
  
  <p>do a good job because they change the my-keys-minor-mode-map in long term. That means when I switch back from text mode to program mode, I lose syntax check function.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>For example, </p>
  
  <pre><code>(define-key my-keys-minor-mode-map (kbd "&lt;return&gt;") 'newline-and-indent)
  </code></pre>
  
  <p>this works 99% of time and is good to prevent any other minor modes or major modes to modify this.</p>
  
  <p>However, the key map has problem in read only mode. So I need to have "super priority" function to remap this key. I want something like</p>
  
  <pre><code>(defun super-priority-map()
    (define-key super-my-keys-minor-mode-map (kbd "&lt;return&gt;") 'something-else))
  (add-hook 'some-modes 'super-priority-map)
  </code></pre>
  
  <p>And more important, the super-priority-map should take off as long as that specified mode is left.</p>