[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to define minor-mode keybindings conditional on buffer's major-m
From: |
Stefan Monnier |
Subject: |
Re: How to define minor-mode keybindings conditional on buffer's major-mode? |
Date: |
Fri, 04 Oct 2013 10:27:48 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> How can this be achieved?"
You can define two keymaps (probably inheriting from a third one that
contains the shared stuff), and then in the minor-mode function, setup
minor-mode-overriding-map-alist to use the right one.
Or you can do truly evil things like
(define-key minor-mode-map
"<<key-binding1>>"
`(menu-item "" minor-mode-command
:filter ,(lambda (cmd) (if (eq major-mode 'xyz-mode) cmd))))
(define-key minor-mode-map
"<<key-binding2>>"
`(menu-item "" minor-mode-command
:filter ,(lambda (cmd) (if (not (eq major-mode 'xyz-mode)) cmd))))
-- Stefan