help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding major mode key bindings


From: Tim Johnson
Subject: Re: Overriding major mode key bindings
Date: Mon, 5 Sep 2016 13:37:33 -0800
User-agent: Mutt/1.7.0 (2016-08-17)

* Yuri Khan <address@hidden> [160905 09:07]:
> On Mon, Sep 5, 2016 at 7:02 AM, Tim Johnson <address@hidden> wrote:
> 
> > I have keybindings established using 'global-set-key.
> > Some are being clobbered by a major mode (python and elpy).
> >
> > I've tried the following with a mode-hook function:
> > 1) unsetting those key sequences
> > or
> > 2) defining those key sequences as 'nil
> > 3) remapping the mode functions to a keymap of my own device:
> > i.e. a C-c n prefix.
> >
> > After some research, it looks like what I really should do is
> > to create my own minor mode and and bind the keys the I want to
> > "protect" to that minor mode.
> 
> If the bindings you are defining make sense as a toggleable
> self-contained set, a minor mode is the way to go.
> 
> However, if they are just a random collection of bindings you find
> more convenient than what the major modes offer, you also have an
> option of 4) removing the conflicting bindings from the offending
> major modes’ maps:
<...> 
Good point:

I'm evaluating whether to use the minor mode approach. Because the
current mapping in a 'dolist operating on a (sequence . function)
alist, (hence eliminating redundant calls) it is easy enough to
switch over. 

however, since I also have a hook function for python-mode, a quick
fix is something like

(defun tj-python-mode-keys ()
  "Additional key bindings and rebindings for python-mode
  functions."
  ;; the following overrides of all of Jurgen's bindings
  ;; that conflict with mine.
  (define-key elpy-mode-map (kbd "C-c s") nil)
  (define-key elpy-mode-map (kbd "<C-return>") nil)
  (define-key elpy-mode-map (kbd "<S-return>") nil)
  (define-key elpy-mode-map (kbd "<C-S-return>") nil)
  (define-key elpy-mode-map (kbd "C-c C-b") nil)
  ; ...
  )
;; This code is after elpy is loaded and precedes my global
;; bindings.   

:) so many choices ...

thanks very much
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]