unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Making C-t act like C-x sometimes
@ 2010-07-22 10:37 Deniz Dogan
  2010-07-22 10:54 ` Teemu Likonen
  0 siblings, 1 reply; 3+ messages in thread
From: Deniz Dogan @ 2010-07-22 10:37 UTC (permalink / raw)
  To: help-gnu-emacs

Hi

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.

Any ideas?

Thanks,
Deniz Dogan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Making C-t act like C-x sometimes
  2010-07-22 10:37 Making C-t act like C-x sometimes Deniz Dogan
@ 2010-07-22 10:54 ` Teemu Likonen
  2010-07-22 12:57   ` Deniz Dogan
  0 siblings, 1 reply; 3+ messages in thread
From: Teemu Likonen @ 2010-07-22 10:54 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: help-gnu-emacs

* 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!")))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Making C-t act like C-x sometimes
  2010-07-22 10:54 ` Teemu Likonen
@ 2010-07-22 12:57   ` Deniz Dogan
  0 siblings, 0 replies; 3+ messages in thread
From: Deniz Dogan @ 2010-07-22 12:57 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: help-gnu-emacs

2010/7/22 Teemu Likonen <tlikonen@iki.fi>:
> * 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!")))
>

Derr, of course.

Thanks!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-22 12:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-22 10:37 Making C-t act like C-x sometimes Deniz Dogan
2010-07-22 10:54 ` Teemu Likonen
2010-07-22 12:57   ` Deniz Dogan

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).