unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Remapping the Tab Key?
@ 2005-11-20  8:37 William Reardon
  2005-11-20  9:19 ` Harald Hanche-Olsen
  0 siblings, 1 reply; 8+ messages in thread
From: William Reardon @ 2005-11-20  8:37 UTC (permalink / raw)


I'm trying to remap the tab key to call a custom elisp function, but
can't quite get it work.  Here's what I have:

(global-set-key [tab] 'indent-or-complete)

I'm pretty sure the problem isn't in the function, as I can
successfully remap it to ^t via

(global-set-key "\C-t" 'indent-or-complete)

and it works as expected.

I've hunted around a bit, tried the various tricks suggested in the
FAQ, but no luck.  Any suggestions?

I'm running GNU Emacs 21.2.1 on Mac OS X 10.3.9.

TIA!
-Bill

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

* Re: Remapping the Tab Key?
  2005-11-20  8:37 Remapping the Tab Key? William Reardon
@ 2005-11-20  9:19 ` Harald Hanche-Olsen
  2005-11-21  8:25   ` William Reardon
  0 siblings, 1 reply; 8+ messages in thread
From: Harald Hanche-Olsen @ 2005-11-20  9:19 UTC (permalink / raw)


+ "William Reardon" <william.reardon@gmail.com>:

| I'm trying to remap the tab key to call a custom elisp function, but
| can't quite get it work.  Here's what I have:
|
| (global-set-key [tab] 'indent-or-complete)

Changing the tab key in the global keymap is unlikely to work, as many
major modes will bind this key in their local keymaps.  Check out the
story on global vs local keymaps in the info file.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow

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

* Re: Remapping the Tab Key?
  2005-11-20  9:19 ` Harald Hanche-Olsen
@ 2005-11-21  8:25   ` William Reardon
  2005-11-21 17:45     ` John Russell
  0 siblings, 1 reply; 8+ messages in thread
From: William Reardon @ 2005-11-21  8:25 UTC (permalink / raw)


Ah, good to know.  Thanks Harald.

I actually only want to do this in cperl, but simplified it to
eliminate any problems w/ the mode hook (and make it easier to post
:-).  Unfortunately, still no luck when trying the following:

(add-hook 'cperl-mode-common-hook
          (function (lambda ()
                      (local-set-key [tab] (quote indent-or-complete))
                      )))

-Bill

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

* Re: Remapping the Tab Key?
  2005-11-21  8:25   ` William Reardon
@ 2005-11-21 17:45     ` John Russell
  2005-11-21 20:03       ` William Reardon
  0 siblings, 1 reply; 8+ messages in thread
From: John Russell @ 2005-11-21 17:45 UTC (permalink / raw)


"William Reardon" <william.reardon@gmail.com> writes:

> Ah, good to know.  Thanks Harald.
>
> I actually only want to do this in cperl, but simplified it to
> eliminate any problems w/ the mode hook (and make it easier to post
> :-).  Unfortunately, still no luck when trying the following:
>
> (add-hook 'cperl-mode-common-hook
>           (function (lambda ()
>                       (local-set-key [tab] (quote indent-or-complete))
>                       )))
>

This worked for me:

(define-key outline-mode-map [(tab)] 'my-function)

John

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

* Re: Remapping the Tab Key?
  2005-11-21 17:45     ` John Russell
@ 2005-11-21 20:03       ` William Reardon
  2005-11-21 21:23         ` John Russell
                           ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: William Reardon @ 2005-11-21 20:03 UTC (permalink / raw)


No luck with that approach either, as I get the following error:

Symbol's value as variable is void: cperl-mode-map

I did, however, finally stumble on something that does:

(add-hook 'cperl-mode-hook
          (function (lambda ()
                      (local-set-key [009] (quote indent-or-complete))
                      )))

Changing from 'cperl-mode-common-hook' to 'cperl-mode-hook' and using
the decimal value of the tab key.  I can think of a few reasons for the
former, but I don't understand the latter.  It *only* works with the
decimal value.  Neither of the following would do the trick:

(local-set-key [tab] (quote indent-or-complete))
(local-set-key [(tab)] (quote indent-or-complete))

Any insights as to why?

-Bill

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

* Re: Remapping the Tab Key?
  2005-11-21 20:03       ` William Reardon
@ 2005-11-21 21:23         ` John Russell
  2005-11-21 22:43         ` Harald Hanche-Olsen
  2005-11-22 18:14         ` rgb
  2 siblings, 0 replies; 8+ messages in thread
From: John Russell @ 2005-11-21 21:23 UTC (permalink / raw)


"William Reardon" <william.reardon@gmail.com> writes:

> No luck with that approach either, as I get the following error:
>
> Symbol's value as variable is void: cperl-mode-map
>

Had cPerl been autoloaded yet?  If not its possible that its keymap 
wasn't created yet.  

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

* Re: Remapping the Tab Key?
  2005-11-21 20:03       ` William Reardon
  2005-11-21 21:23         ` John Russell
@ 2005-11-21 22:43         ` Harald Hanche-Olsen
  2005-11-22 18:14         ` rgb
  2 siblings, 0 replies; 8+ messages in thread
From: Harald Hanche-Olsen @ 2005-11-21 22:43 UTC (permalink / raw)


+ "William Reardon" <william.reardon@gmail.com>:

| Changing from 'cperl-mode-common-hook' to 'cperl-mode-hook' and using
| the decimal value of the tab key.  I can think of a few reasons for the
| former, but I don't understand the latter.  It *only* works with the
| decimal value.

Well, instead of using 9 you could use ?\t as in
(local-set-key [?\t] ...)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow

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

* Re: Remapping the Tab Key?
  2005-11-21 20:03       ` William Reardon
  2005-11-21 21:23         ` John Russell
  2005-11-21 22:43         ` Harald Hanche-Olsen
@ 2005-11-22 18:14         ` rgb
  2 siblings, 0 replies; 8+ messages in thread
From: rgb @ 2005-11-22 18:14 UTC (permalink / raw)


> (add-hook 'cperl-mode-hook
>           (function (lambda ()
>                       (local-set-key [009] (quote indent-or-complete))
>                       )))
>
>  It *only* works with the
> decimal value.  Neither of the following would do the trick:
>
> (local-set-key [tab] (quote indent-or-complete))
> (local-set-key [(tab)] (quote indent-or-complete))
>
> Any insights as to why?

There are 2 questions.

1. Why doesn't it work

M-: (local-set-key [TAB] 'indent-relative)  RET
(error "To bind the key TAB, use \"\\t\", not [TAB]")

So it appears that the answer to WHY is, it's not supposed to.

2. WHY? doesn't it work.

I have no idea.

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

end of thread, other threads:[~2005-11-22 18:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-20  8:37 Remapping the Tab Key? William Reardon
2005-11-20  9:19 ` Harald Hanche-Olsen
2005-11-21  8:25   ` William Reardon
2005-11-21 17:45     ` John Russell
2005-11-21 20:03       ` William Reardon
2005-11-21 21:23         ` John Russell
2005-11-21 22:43         ` Harald Hanche-Olsen
2005-11-22 18:14         ` rgb

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