help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Overriding emacs key bindings


From: xiongtk
Subject: Re: Overriding emacs key bindings
Date: Mon, 16 May 2016 23:14:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

Emanuel Berg <embe8573@student.uu.se> writes:

> xiongtk <xiongtk@gmail.com> writes:
>
>> Since this file is read only and it's not
>> inside .emacs.d, I do not want to change it
>> directly if other solutions are possible.
>
> Good call! Because then you'll loose it for
> example when you upgrade Emacs, and each edit
> would require a sudo detour...
>
>> I've tried with writing the following line in
>> my personal customization file:
>>
>>     (define-key global-map (kbd "<f8>")
>> 'toggle-input-method) or (global-set-key (kbd
>> "<f8>") 'toggle-input-method)
>
> Instead of (kbd "<f8>"), you can do [f8].
>
> (But: I don't recommend using the function keys
> as they are remote (i.e., require arm movement
> as opposed to just finger ditto, which in turn
> implies a reset to typing position) - also they
> are confusing (too alike) and thus difficult to
> remember. And they don't work in a VT Emacs
> instance! - not without special efforts [1]
> at least.)
>
I kind of run out of keys on my keyboard. Since this function is rarely
used(I use English for 99% of the time), I think the function keys is fine.
>> Apparently my method does not override the
>> original key binding. Any suggestions?
>
> By "override", do you mean the new keystroke
> won't work, or the old keystroke remains?
>
> If the old keystroke remains, that is normal.
> You can unset it like this:
>
>     (global-unset-key "\C-hh")
>
> If the new keystroke doesn't work, sometimes it
> is the case that a *local* keymap has that key
> assigned. Changing the global keymap doesn't
> change the local map, of course, and the local
> map has priority, as far as locally goes!
>
> Here is some code to automatize setting
> a global key, and then disabling the same key
> for the desired local modes - if you want the
> global key to be in effect there, as well.
> Use the functions in the order they appear.
>
> (defvar super-global-keys '())
>
> (defun super-global-set-key (key function)
>   "Make a super global KEY that invokes FUNCTION."
>   (global-set-key key function)
>   (add-to-list 'super-global-keys key) )
>
> (defun disable-super-global-keys (&optional map)
>   "Disable MAP super global keystrokes, so they can be assigned."
>   (dolist (k super-global-keys)
>     (define-key (or map (current-local-map)) k nil) ))
>
> [1] http://user.it.uu.se/~embe8573/tty-emacs-keys.txt
I believe (global-unset-key ) is what I'm searching for. Thank you!




reply via email to

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