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

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

Re: Keybinding excluding specific modes


From: wilnerthomas
Subject: Re: Keybinding excluding specific modes
Date: Mon, 29 Aug 2022 23:24:40 +0200 (CEST)

Aug 29, 2022, 20:37 by uzibalqa@proton.me:

>
> Whilst I can set a keybinding according to mode (e.g. emacs-lisp-mode-map)
>
>  (define-key emacs-lisp-mode-map (kbd "H-e") #'eval-last-sexp)
>
> how can I use the same key combination for eval-last-sexp when not in lisp 
> type modes?
>
One thing I could do is this

     (global-set-key (kbd "H-e") #'eval-expression)
     
     (define-key lisp-mode-map (kbd "H-e") #'eval-last-sexp)
     
     (define-key emacs-lisp-mode-map (kbd "H-e") #'eval-last-sexp)

Because local key maps override the global ones.  I define one key in the 
global map and then override  the key sequence with a key binding in 
lisp-mode-map and emacs-lisp-mode-map.

Would this be all?




reply via email to

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