all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: Preventing modes overriding global keys
Date: Mon, 13 Jun 2005 00:17:36 +0200	[thread overview]
Message-ID: <87r7f7w77j.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.4448.1118610019.25862.help-gnu-emacs@gnu.org

"Ian Crowther" <i_crowther@hotmail.com> writes:

> I'm trying to make emacs bind end-of-line to the tab key in all
> modes. Doing:
>
> 	(global-set-key (kbd "TAB") 'end-of-line)
>
> doesn't have any effect. "C-h k <TAB>" shows:
> 	TAB runs the command lisp-indent-line
>
> I assume my parameters to global-set-key are correct, as local-set-key
> works.
> It looks like the lisp mode is defining the tab key. If I evaluate
> "(lisp-mode)" then
> my binding made with local-set-key is disabled.
>
> Is there a way to override the mode settings for the tab key? Or a way
> to prevent
> modes overriding certain keys in the first place?
>
> Thanks for any help. I'm really stuck on this one.

Modes and keys management in emacs is not declarative, it's
procedural, and state is spread between global and buffer local
variables.

Have a look at global-set-key, it only modifies the
(current-global-map),  not all the keymaps, and not the keymaps
installed in each buffer by the various modes.

Perhaps you want something like:
        
(defun set-key-everywhere (key command)
  (global-set-key key command)
  (dolist (buffer (buffer-list))
    (set-buffer buffer)
    (let ((map (current-local-map)))
      (when map
        (define-key map key command)))))

(set-key-everywhere (kbd "TAB") 'end-of-line)

But of course you'll have to re-execute this last s-expr everytime a
mode redefines a local map.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.

       reply	other threads:[~2005-06-12 22:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4448.1118610019.25862.help-gnu-emacs@gnu.org>
2005-06-12 22:17 ` Pascal Bourguignon [this message]
2005-06-12 20:39 Preventing modes overriding global keys Ian Crowther
2005-06-14 18:07 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r7f7w77j.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.