[Top][All Lists]

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

Re: substitute-key-definition vs. define-key MAP [remap ...]

From: Miles Bader
Subject: Re: substitute-key-definition vs. define-key MAP [remap ...]
Date: Fri, 23 Jul 2010 18:32:55 +0900

Stefan Monnier <address@hidden> writes:
> The `remap' thingy operates at the level of `key-binding'.  I.e. after
> the command loop reads a key-sequence, it looks it up in the keymaps to
> turn the key-sequence into a command, and then it looks this up in the
> `remap' sub-keymap(s) to see if it got remapped.

And it's _extremely_ handy for some uses... e.g., one of my favorite
tricks is little minor-modes that bind [remap self-insert-command]...


   ;;; caps-lock-mode, Miles Bader <address@hidden>

   (defvar caps-lock-mode-map
     (let ((map (make-sparse-keymap)))
       (define-key map [remap self-insert-command] 'self-insert-upcased)

   (define-minor-mode caps-lock-mode
     "When enabled, convert all self-inserting characters to uppercase."
     :lighter " CapsLock")

   (defun self-insert-upcased (arg)
     (interactive "p")
     (setq last-command-char (upcase last-command-char))
     (self-insert-command arg))


Politics, n. A strife of interests masquerading as a contest of
principles. The conduct of public affairs for private advantage.

reply via email to

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