From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: j@mremus.net Newsgroups: gmane.emacs.bugs Subject: bug#44973: Add a macOS global hotkey function Date: Mon, 30 Nov 2020 13:01:52 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000076afde05b559520b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40139"; mail-complaints-to="usenet@ciao.gmane.io" To: 44973@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 30 22:27:32 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 1kjqho-000AGv-AC for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Nov 2020 22:27:32 +0100 Original-Received: from localhost ([::1]:41496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjqhn-00019T-5Q for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Nov 2020 16:27:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjqhL-00017f-Vm for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 16:27:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45361) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kjqhL-0000Du-6N for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 16:27:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kjqhL-0003U6-37 for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 16:27:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: j@mremus.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Nov 2020 21:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44973 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160677161113346 (code B ref -1); Mon, 30 Nov 2020 21:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Nov 2020 21:26:51 +0000 Original-Received: from localhost ([127.0.0.1]:56903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjqh8-0003TC-WC for submit@debbugs.gnu.org; Mon, 30 Nov 2020 16:26:51 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjqJE-0002ro-Vv for submit@debbugs.gnu.org; Mon, 30 Nov 2020 16:02:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjqJE-00012c-OB for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 16:02:08 -0500 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:46837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kjqJC-0005lr-Iw for bug-gnu-emacs@gnu.org; Mon, 30 Nov 2020 16:02:08 -0500 Original-Received: by mail-ot1-x331.google.com with SMTP id z23so9064665oti.13 for ; Mon, 30 Nov 2020 13:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mremus.net; s=google; h=mime-version:from:date:message-id:subject:to; bh=NJ4glx7VlGPq2c3EpNNC51mRRos1MDNDSbaTCRnUZYg=; b=XpyGDBOGOvqJcegRdqqpEt/eFyOLMzTtGZvPwy/9Gnhgof4MMNcxIZCnmC6INis9ka S5mL3ETksCpTB0AufDLY5Ea5kPYkr/VwD0zG9jWbFxWeUrdFORKVD61qjJD4SUv0bc/p 99d+MA29EQRBfPQRrmFV6SC4vhw2jTUaVKPQvrbZAGNBpjxH+BYuDg17Da3hhO8dk85/ jHD5FQWo54u0KkIJ9J/VqOS9/J4Akwyv727r3JGt++EY/1JsLGG0/1iLDQmJys+rS/aR Hip8Z+VfgbG80Ur6ga/fC84v8RNKQ62T8usAjPWTSCAly47BcvGl6KriHxhC+moDeM04 JU6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NJ4glx7VlGPq2c3EpNNC51mRRos1MDNDSbaTCRnUZYg=; b=iPsAlUFsJQSpNX59HlgbKkt8Xd1tEnnyNkzQMi8Jp45WcuCwjWnXFic/E8Ki+wzEqX /pWpgeqKB3DribU/cGBTs2Hqg627M8imxKgclAXhwgoVeb52RXzG+Lbuci9mTGAPPaLi Z1udaEiz5DLeXJzntJ6A3pZVNVf00p98iUxuGqXGllDL+eCFUchDxmhGeulZO5KbRape nBzI47iL6Pb62+lrhH7WG03fL3dQ6FW0GO9h3O0ySu4udwkLvMYp7hYPSfdfG3NnJXiD Xlrx5zLiD2xchX1ZaqzGLCL1YeaONkY7X/ZAiV+f2toBbIbOpI3Snu6GzVljt1RfHVrV OvSg== X-Gm-Message-State: AOAM532peNORpMmNoMharlGc43AD6yqDjTB1bDv3c66T40u8A0OkfXzL yFLSKiqR1izXjM6Pawz3JkH5qHrM8IpKflSdxrWqIGZKi+bnbnDM X-Google-Smtp-Source: ABdhPJxOuL9ra6jUJF8Q/av2EtkYMjER6XT3eqbmXi3KHIIMffTFqQYhJ8JqZnXHeqfbyaIWopGBi4FjiFcYhUbga2c= X-Received: by 2002:a9d:346:: with SMTP id 64mr19076307otv.4.1606770123774; Mon, 30 Nov 2020 13:02:03 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=jbalk@mremus.net; helo=mail-ot1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 30 Nov 2020 16:26:49 -0500 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:194686 Archived-At: --00000000000076afde05b559520b Content-Type: text/plain; charset="UTF-8" MacOS makes it very difficult to assign global hotkeys to focus Emacs. For example, if I'm in another program, and I want to launch/focus Emacs with "Alt-SPC", it can't just be set in the system preferences; I'd need to use a 3rd-party program like skhd. Would it be possible to add a function or hook to Emacs which registers one or more global hotkeys (using addGlobalMonitorForEventsMatchingMask), and then when the hotkey is pressed, run an elisp function? For example, by creating a "ns-register-global hotkey" function, where the user could choose a keybinding (maybe "ALT-SPC"), and letting the user provide a hook function (maybe "org-capture-stuff") I intend this feature to be used for something like an Alfred replacement, as described here: https://www.mattduck.com/emacs-fuzzy-launcher.html . Even if it's rare for Emacs to implement an OS-specific feature, there is some precedent on Windows. If you look at w32-register-hot-keys, it's similar to, but different from my request. The implementation in nsterm.m should be simple, but it requires Obj-C and Emacs-specific development knowledge. Thanks! --00000000000076afde05b559520b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

MacOS makes it very difficult to assign global hotkeys to focus Emacs. Fo= r=C2=A0example, if I'm in another program, and I want to launch/focus E= macs with "Alt-SPC", it can't just be set in the system prefe= rences; I'd need to use a 3rd-party program like skhd.

Would it be possible to add a function or hook to Emacs which regi= sters one or more global hotkeys (using addGlobalMonitorForEventsMatchingMa= sk), and then when the hotkey is pressed, run an elisp function?
=
For example, by creating a "ns-register-global hotkey&q= uot; function, where the user could choose a keybinding (maybe "ALT-SP= C"), and letting the user provide a hook function (maybe "org-cap= ture-stuff")

I intend=C2=A0this feature to be= used for something like an Alfred replacement, as described here: https://www.mattduc= k.com/emacs-fuzzy-launcher.html .

Even if it&#= 39;s rare for Emacs to implement an OS-specific feature, there is some prec= edent on Windows. If you look at=C2=A0w32-= register-hot-keys, it's similar to, but different from my request.=C2= =A0

The implementation in nsterm.m should be simple, but it requires Obj-C and= Emacs-specific development knowledge.

Thanks!
--00000000000076afde05b559520b--