From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#44533: 27.1; Mac special key modifiers not functioning as expected Date: Tue, 10 Nov 2020 13:11:44 +0000 Message-ID: <20201110131144.GC36769@breton.holly.idiocy.org> References: <20a05d56-c273-471a-a23c-b9c2f62a8c2c_IMAP_ADDED_MISSING@ORVILLE> <9A29D888-6780-46EC-90ED-36FB9D800480@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26939"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44533@debbugs.gnu.org, Andrii Kolomoiets To: YH Tan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 10 14:12:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcTRS-0006rG-MQ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 14:12:11 +0100 Original-Received: from localhost ([::1]:60324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcTRR-0003bB-PF for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 08:12:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcTRL-0003b3-Ki for bug-gnu-emacs@gnu.org; Tue, 10 Nov 2020 08:12:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcTRK-000470-LD for bug-gnu-emacs@gnu.org; Tue, 10 Nov 2020 08:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kcTRK-00065F-Fk for bug-gnu-emacs@gnu.org; Tue, 10 Nov 2020 08:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Nov 2020 13:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44533 X-GNU-PR-Package: emacs Original-Received: via spool by 44533-submit@debbugs.gnu.org id=B44533.160501391823373 (code B ref 44533); Tue, 10 Nov 2020 13:12:02 +0000 Original-Received: (at 44533) by debbugs.gnu.org; 10 Nov 2020 13:11:58 +0000 Original-Received: from localhost ([127.0.0.1]:36719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcTRF-00064v-N7 for submit@debbugs.gnu.org; Tue, 10 Nov 2020 08:11:58 -0500 Original-Received: from wilbur.contactoffice.com ([212.3.242.68]:32974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcTRD-00064e-TJ for 44533@debbugs.gnu.org; Tue, 10 Nov 2020 08:11:56 -0500 Original-Received: from smtpauth1.co-bxl (smtpauth1.co-bxl [10.2.0.15]) by wilbur.contactoffice.com (Postfix) with ESMTP id 636D01EDB; Tue, 10 Nov 2020 14:11:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1605013909; s=20200222-6h9o; d=idiocy.org; i=alan@idiocy.org; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To; l=4063; bh=4qJbZ4FW6S/oWhdj5YNMs9OyZnc5nsvMdVNEWOcPFWs=; b=k48ZqXLlljfk1I6Y37Ci7Wi/SxY+eZXi86JE9UjjJuA1sabInHUfozvlcmHfJpGq RZRCayyF4xxkeqSbkp+qfSWvcg7csz6UBXBh/axKhkz2lcQzyVTdRqWwqQJxC2PQRqj Jitvk1GNunk9CEXWlRyORHy1qNZgkUn7Zwcsg1KMDZg3/DooMvnaA2pXC+Pzmm+Ut5X fQ1GIWH83PCYrvIR1uAej4Pa/4BwVSgN7xdtPzmhbbCx12iacronmdF3v1TNj0YTW+3 g98ji/6Honu9mQyXH4im2p5ok9IQFC91br5h1XdJSW/c5Fxb+Zd36Oxo5CnrcDtTtZU t3IKC2dxzg== Original-Received: by smtp.mailfence.com with ESMTPA ; Tue, 10 Nov 2020 14:11:46 +0100 (CET) Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 0CAA22026602D2; Tue, 10 Nov 2020 13:11:44 +0000 (GMT) Mail-Followup-To: Alan Third , YH Tan , 44533@debbugs.gnu.org, Andrii Kolomoiets Content-Disposition: inline In-Reply-To: <9A29D888-6780-46EC-90ED-36FB9D800480@gmail.com> X-ContactOffice-Account: com:241649512 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193006 Archived-At: --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Nov 10, 2020 at 08:09:03PM +0800, YH Tan wrote: > > > > On Nov 10, 2020, at 19:11, Alan Third wrote: > > > > On Mon, Nov 09, 2020 at 11:23:13PM +0800, YH Tan wrote: > >> The functioning of certain special key modifiers doesn't seem to work as > >> expected in 27.1. > >> > >> For example, when I do: > >> > >> (setq mac-left-option-modifier 'nil) > > ^^^^ > >> > >> nothing happens to the left option key, which retains its meta function. > > > > You should be using mac-option-modifier, not mac-left-option-modifier. > > This would reset both option keys. I would like to retain meta on the right. mac-left-option-modifier has no special function on the NS port of Emacs. It may on the Mac port, but I don't think so. I recommend you review the documentation (C-h i m emacs i ns-alternate-modifier). > > This actually sounds suspiciously like you've remapped fn as option in > > the system preferences. The fn key has some strange behaviours when > > used with "control" keys like the arrows. > > > > Yes. I do have: > > (setq mac-function-modifier 'meta) > > which maps function to meta. You mean this can actually interfere > with the right-option meta key? I’ve been using the same setup for > previous versions of emacs without problem. We reworked the keyboard handling for Emacs 27 because there were a lot of strange behaviours. I've attached a patch, it's for the master branch but is easily adapted for Emacs 27. Assuming this works I'd like to apply it to Emacs 27, but I'm not 100% sure it won't break anything, so perhaps it's best to put it in master first and back-port to Emacs 27 when/if we're happy with it. -- Alan Third --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-Fix-error-with-fn-key-in-NS-port-bug-44533.patch" Content-Transfer-Encoding: 8bit >From 8c4ff510a580e2b66e6ed7e6e7f96fcf557429fc Mon Sep 17 00:00:00 2001 From: Alan Third Date: Tue, 10 Nov 2020 12:54:50 +0000 Subject: [PATCH] Fix error with fn key in NS port (bug#44533) * src/nsterm.m ([EmacsView keyDown:]): Move the correction for fn key handling to before the modifiers are calculated. --- src/nsterm.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 4fad521b74..a9280eb4af 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6531,6 +6531,14 @@ flag set (this is probably a bug in the OS). */ code = 0xFF08; /* backspace */ else code = fnKeysym; + + /* Function keys (such as the F-keys, arrow keys, etc.) set + modifiers as though the fn key has been pressed when it + hasn't. Also some combinations of fn and a function key + return a different key than was pressed (e.g. fn- + gives ). We need to unset the fn key flag in these + cases. */ + flags &= ~NS_FUNCTION_KEY_MASK; } /* The ⌘ and ⌥ modifiers can be either shift-like (for alternate @@ -6552,17 +6560,6 @@ In that case we use UCKeyTranslate (ns_get_shifted_character) Lisp_Object kind = fnKeysym ? QCfunction : QCordinary; emacs_event->modifiers = EV_MODIFIERS2 (flags, kind); - /* Function keys (such as the F-keys, arrow keys, etc.) set - modifiers as though the fn key has been pressed when it - hasn't. Also some combinations of fn and a function key - return a different key than was pressed (e.g. fn- gives - ). We need to unset the fn modifier in these cases. - FIXME: Can we avoid setting it in the first place? */ - if (fnKeysym && (flags & NS_FUNCTION_KEY_MASK)) - emacs_event->modifiers - ^= parse_solitary_modifier (mod_of_kind (ns_function_modifier, - QCfunction)); - if (NS_KEYLOG) fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n", code, fnKeysym, flags, emacs_event->modifiers); -- 2.26.1 --GvXjxJ+pjyke8COw--