[Top][All Lists]

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

Re: Making C-t act like C-x sometimes

From: Teemu Likonen
Subject: Re: Making C-t act like C-x sometimes
Date: Thu, 22 Jul 2010 13:54:52 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux)

* 2010-07-22 12:37 (+0200), Deniz Dogan wrote:

> I'm struggling trying to make my C-t act like the C-x prefix in all
> cases but C-t C-n (C-x C-n is set-goal-column).
> (global-unset-key (kbd "C-t"))
> (global-set-key (kbd "C-t") ctl-x-map)
> (global-set-key (kbd "C-t C-n") nil)
> (global-set-key (kbd "C-x C-n") 'set-goal-column)
> This does not work. Both C-t C-n and C-x C-n are now bound to
> set-goal-column. It seems that I can only have C-t C-n AND C-x C-n,
> not only C-x C-n.

That's how it works. :-) In your examples both C-x and C-t are prefix
keys to the same keymap: ctl-x-map. To make them different keymaps you
need to copy the map:

    ;; Copy ctl-x-map
    (setq my-ctl-t-map (copy-keymap ctl-x-map))
    ;; Make global C-t the prefix for the new map
    (global-set-key (kbd "C-t") my-ctl-t-map)

Now keys in those two maps can be defined separately:

    (define-key my-ctl-t-map (kbd "C-n")
      #'(lambda () (interactive)
          (message "Pling!")))

    (define-key ctl-x-map (kbd "C-n")
      #'(lambda () (interactive)
          (message "Plong!")))

reply via email to

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