unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Function for deleting a key binding in a sparse keymap
Date: Wed, 07 Dec 2005 11:13:05 +0100	[thread overview]
Message-ID: <4396B5B1.10501@student.lu.se> (raw)
In-Reply-To: <87pso97k0r.fsf-monnier+emacs@gnu.org>

Stefan Monnier wrote:

>>I set the "help keys" to nil so that the help is still available during
>>resizing. Those are the keys I want to remove afterwards. The default value
>>in the sparse keymap bw-keymap is:
>>    
>>
>
>  
>
>>       (define-key bw-keymap [t]  'bw-exit-resize-mode)
>>    
>>
>
>I see.  Coming from a functional programming background, I'd use anoter
>approach based on the idea of reusing the original value rather than using
>side-effects to try and coerce it back to the same shape it had originally:
>
>       (defvar bw-keymap
>           (let ((map (make-sparse-keymap)))
>             (define-key map [t]  'bw-exit-resize-mode)
>             map))
>
>then when adding help-event-list bindings:
>
>       (setq bw-keymap (let ((map (make-sparse-keymap)))
>                         (set-keymap-parent map bw-keymap)
>                         map))
>       ;; dolist is more efficient than mapc.
>       (dolist (key help-event-list)
>         (define-key bw-keymap (vector key) nil))
>
>and when you want to remove those keys, just do
>
>       (setq bw-keymap (keymap-parent bw-keymap))
>
>Of course, you can use variants of it, e.g. introduce a "bw-basic-map"
>variable to keep the original map, rather than rely on (keymap-parent
>bw-keymap) holding that original map.
>  
>
I wrote to early. For some reason this does not work. It seems like the 
help keys just runs the default function (ie 'bw-exit-resize-mode). Here 
is the output from (describe-variable 'bw-keymap (get-buffer-create 
"*Help*")):

bw-keymap is a variable defined in `c:/emacs-lisp/test/bwcvs.el'.
Its value is shown below.

Documentation:
Keymap used by `bw-window-resize-mode'.

Value:
(keymap
 (f1)
 (help)
 keymap
 (right . bw-mode-resize-right)
 (left . bw-mode-resize-left)
 (down . bw-mode-resize-down)
 (up . bw-mode-resize-up)
 (102 . bw-shrink-windows-horizontally)
 (46 . bw-balance-siblings)
 (43 . bw-balance)
 (t . bw-exit-resize-mode)
 (menu-bar keymap
           (bw "&Resize" keymap
               (balance "Balance Windows" . bw-balance)
               (siblings "Balance Window Siblings" . bw-balance-siblings)
               (shrink "Shrink to Buffers" . bw-shrink-windows-horizontally)
               "second"))
 "Window Resizing")

[back]

  parent reply	other threads:[~2005-12-07 10:13 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-04 23:58 Function for deleting a key binding in a sparse keymap Lennart Borgman
2005-12-05 16:38 ` Richard M. Stallman
2005-12-05 16:55   ` Lennart Borgman
2005-12-06 16:42     ` Richard M. Stallman
2005-12-06 17:04       ` Lennart Borgman
2005-12-06 21:26         ` Stefan Monnier
2005-12-06 22:18           ` Lennart Borgman
2005-12-06 22:28             ` Stefan Monnier
2005-12-06 23:01               ` Lennart Borgman
2005-12-07  1:56                 ` Stefan Monnier
2005-12-07  9:56                   ` Lennart Borgman
2005-12-07 10:13                   ` Lennart Borgman [this message]
2005-12-07 14:33                     ` Lennart Borgman
2005-12-08  9:10                       ` Kim F. Storm
2005-12-07 17:06         ` Richard M. Stallman
2005-12-07 17:12           ` Lennart Borgman
2005-12-05 19:42 ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2005-12-08  9:32 LENNART BORGMAN
2005-12-08 14:24 ` Kim F. Storm
2005-12-08 15:03   ` Lennart Borgman
2005-12-08 16:53 ` Stefan Monnier
2005-12-08 18:36   ` Lennart Borgman
2005-12-08 18:56     ` Stefan Monnier
2005-12-08 23:59       ` Lennart Borgman
2005-12-09 11:24         ` Kim F. Storm
2005-12-09 15:03         ` Richard M. Stallman
2005-12-09 20:12           ` Lennart Borgman
2005-12-10  4:13             ` Richard M. Stallman
2005-12-10 23:45               ` Lennart Borgman
2005-12-11  1:12                 ` Stefan Monnier
2005-12-11  2:16                   ` Lennart Borgman
2005-12-11  8:14                     ` Stefan Monnier
2005-12-11 16:49                     ` Richard M. Stallman
2005-12-11 16:49                 ` Richard M. Stallman
2005-12-12  1:41                   ` Lennart Borgman
2005-12-12 15:52                     ` Stefan Monnier
2005-12-12 17:02                       ` Lennart Borgman
2005-12-13 15:52                         ` Stefan Monnier
2005-12-12 16:18                     ` Richard M. Stallman
2005-12-12 19:09                       ` Lennart Borgman
2005-12-13 17:50                         ` Richard M. Stallman
2005-12-14  0:50                           ` Lennart Borgman
2005-12-14 20:02                             ` Richard M. Stallman
2005-12-10 23:40             ` Kim F. Storm
2005-12-11  0:29               ` Lennart Borgman
2005-12-11  0:54                 ` Lennart Borgman
2005-12-11 16:49                   ` Richard M. Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4396B5B1.10501@student.lu.se \
    --to=lennart.borgman.073@student.lu.se \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).