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

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

Re: How not to share `local-set-key' with all other buffers in the same


From: Stefan Monnier
Subject: Re: How not to share `local-set-key' with all other buffers in the same major mode?
Date: Fri, 02 Apr 2021 08:55:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> I would like to use editing modes as temporary view modes where I
> would like to set a key like "q" or "i" temporarily, like this for
> example:
>
> (local-set-key "q" 'quit-window)
>
> And I use it in read only mode. The binding goes in the current
> buffer’s local map, which in most cases is shared with all other
> buffers in the same major mode.

To avoid it, you can use something like:

    (use-local-map
     (let ((map (make-sparse-keymap)))
       (set-keymap-parent map (current-local-map))
       map))

before doing your `local-set-key`.


        Stefan




reply via email to

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