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

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

Re: disabling key bindings


From: Phillip Lord
Subject: Re: disabling key bindings
Date: 28 Nov 2003 12:47:07 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93

>>>>> "Jesper" == Jesper Harder <address@hidden> writes:

  Jesper> Phillip Lord <address@hidden> writes:


  >> I a new major mode, how do I disable all keybindings, except for
  >> those that I specify. In particular I would want all the normally
  >> self-insert keys to do nothing at all (except where I have bound
  >> the explicitly).

  Jesper> Sounds a bit like Erik Naggums's "poor man's vi-mode":

  Jesper> ,---- | (use-global-map (make-sparse-keymap))
  Jesper> | 
  Jesper> | like vi, it will beep at everything you do, and you can't quit.
  Jesper> | have fun!
  Jesper> `----


Well I tried this, but it doesn't seem to work. 

I think that the problem is that there are more than just the major
mode keymap active.

So I am defining my major mode like so....

 (define-derived-mode pabbrev-select-mode fundamental-mode
      "Pabbrev Select"
      "Major mode for selecting `pabbrev-mode' expansions.
The number keys selects the various possible expansions. 
\\[pabbrev-suggestions-delete]
removes the previously added expansion, \\[pabbrev-suggestions-mimimum] selects 
the mimimum
matching substring, while \\[pabbrev-suggestions-delete-window] just deletes 
the window
\\{pabbrev-select-mode-map}") 
    (setq pabbrev-select-mode-map (make-sparse-keymap))
    (define-key pabbrev-select-mode-map "\t" 
'pabbrev-suggestions-select-default)
    (define-key pabbrev-select-mode-map [delete] 'pabbrev-suggestions-delete)
    (define-key pabbrev-select-mode-map [backspace] 'pabbrev-suggestions-delete)
    (define-key pabbrev-select-mode-map "\C-m" 'pabbrev-suggestions-mimimum)
    (define-key pabbrev-select-mode-map " "
    'pabbrev-suggestions-delete-window)

But in a buffer with this mode I can still type "A" and I get an "A"
in the buffer. 

I guess I could do....

   (loop for i from 33 to 126 do
      (define-key pabbrev-select-mode-map (char-to-string i) 'pabbrev-noop))


(defun pabbrev-noop()
  (interactive))


which seems to work. But it seems a little messy...

Cheers

Phil


reply via email to

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