From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Stop modes from hijacking several global keys Date: Wed, 05 Nov 2014 08:12:08 +0100 Message-ID: <87sihy3yuv.fsf@thinkpad-t440p.tsdh.org> References: <87wq7a3zb0.fsf@thinkpad-t440p.tsdh.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415171566 15017 80.91.229.3 (5 Nov 2014 07:12:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 07:12:46 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 05 08:12:40 2014 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 1Xlulk-0006l9-Bq for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 08:12:40 +0100 Original-Received: from localhost ([::1]:44717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xlulj-0006K8-MW for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 02:12:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlulQ-0006FX-N6 for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 02:12:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlulL-0001Hu-1d for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 02:12:20 -0500 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:55416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlulK-0001Gv-Hu for help-gnu-emacs@gnu.org; Wed, 05 Nov 2014 02:12:14 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id EB19420882 for ; Wed, 5 Nov 2014 02:12:13 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 05 Nov 2014 02:12:13 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:from:to:subject:references :date:in-reply-to:message-id:mime-version:content-type; s= smtpout; bh=t6xfCmcXya8j+354DFqg6NF+kos=; b=u0i2zMoff7+X9zmssP6m VYEZzjF2w/mXowKr2VyVt6t4LhnhXy1tiRMFVXIbSnpo6jrgli8dOTTNFg7c+Njy 96AAWGjs3fXLSM0M08Cz6PlBojhFoluAwfhlM4iHNGOyR7u09VzUOaT83tStiwDW ZLJDO8/Q+tMLUT262d1i0xk= X-Sasl-enc: hw1/bBh0StCyfUOglsbt08VD/uMuIX3nLWVoq2X+Ki3D 1415171533 Original-Received: from thinkpad-t440p.tsdh.org (unknown [2.162.240.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 32A0D680160 for ; Wed, 5 Nov 2014 02:12:13 -0500 (EST) Mail-Followup-To: help-gnu-emacs In-Reply-To: <87wq7a3zb0.fsf@thinkpad-t440p.tsdh.org> (Tassilo Horn's message of "Wed, 05 Nov 2014 08:02:27 +0100") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.26 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100757 Archived-At: Tassilo Horn writes: > Ideally, that magic would stop the mode from hijacking M- > keys, and whatever it wants to bind to M- would automagically > be bound to ` M-' instead. > > I think at least for major-modes I can use > `after-change-major-mode-hook' in combination with a function checking > (key-binding (kbd "M-")) and doing `local-set-key' if needed. Oh, that was easier than I expected: --8<---------------cut here---------------start------------->8--- (defun th/select-nth-window-ensure-keys () "Ensures that M- is bound to `th/select-nth-window'. Binds whatever else is bound to M- to M-." (dotimes (i 9) (let* ((key (kbd (format "M-%s" (1+ i)))) (cmd (key-binding key))) (unless (equal cmd #'th/select-nth-window) (local-set-key key 'th/select-nth-window) (local-set-key (kbd (format " M-%s" (1+ i))) cmd))))) (add-hook 'after-change-major-mode-hook #'th/select-nth-window-ensure-keys) --8<---------------cut here---------------end--------------->8--- > But is there a similar hook that runs after a minor mode has been > activated? This one is still open although I think I haven't encountered a minor-mode that tried to redefine M- yet, so it's less important to me. Bye, Tassilo