"Ian Crowther" <[EMAIL PROTECTED]> 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. _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs