From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Overriding emacs key bindings Date: Mon, 16 May 2016 20:59:47 +0200 Message-ID: <86a8jpg76k.fsf@student.uu.se> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1463425239 11021 80.91.229.3 (16 May 2016 19:00:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 May 2016 19:00:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 16 21:00:25 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b2Nkf-0000GD-3V for geh-help-gnu-emacs@m.gmane.org; Mon, 16 May 2016 21:00:25 +0200 Original-Received: from localhost ([::1]:46810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2NkZ-0006MG-Km for geh-help-gnu-emacs@m.gmane.org; Mon, 16 May 2016 15:00:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2NkO-0006Fd-Re for help-gnu-emacs@gnu.org; Mon, 16 May 2016 15:00:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2NkI-0006Bs-Pq for help-gnu-emacs@gnu.org; Mon, 16 May 2016 15:00:07 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:43250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2NkI-0006Bg-IX for help-gnu-emacs@gnu.org; Mon, 16 May 2016 15:00:02 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b2NkG-0008S1-V8 for help-gnu-emacs@gnu.org; Mon, 16 May 2016 21:00:01 +0200 Original-Received: from c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se ([85.230.225.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 May 2016 21:00:00 +0200 Original-Received: from embe8573 by c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 May 2016 21:00:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 69 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-9ce1e655.08-680-7570702.cust.bredbandsbolaget.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:DICvFGshAnWQa3B3Yb8wAnX0Uxc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:109997 Archived-At: xiongtk 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 "") > 'toggle-input-method) or (global-set-key (kbd > "") 'toggle-input-method) Instead of (kbd ""), 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.) > 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 -- underground experts united .... http://user.it.uu.se/~embe8573 Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic - so far: 30 Blogomatic articles -