GNU bug report logs - #44973
Add a macOS global hotkey function

Previous Next

Package: emacs;

Reported by: j <at> mremus.net

Date: Mon, 30 Nov 2020 21:27:02 UTC

Severity: minor

Full log


Message #17 received at 44973 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: j <at> mremus.net
Cc: 44973 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#44973: Add a macOS global hotkey function
Date: Mon, 21 Dec 2020 08:12:04 +0000
On Sun, Dec 20, 2020 at 04:40:37PM -0800, j <at> mremus.net wrote:
> Hi Lars,
> 
> I'm pretty close to having a patch ready, but I'm stuck in one key spot. I
> don't know if anyone on the list could help?
> 
> After the user registers a hotkey, and when they press the hotkey, MacOS
> will run the code below. On the line "RUN_SOME_ELISP_FUNCTION", I would
> expect some elisp function to be run (e.g. 'emacs-version').
> 
> But no matter what I do, it always crashes the program. I think my first
> problem is not knowing how to call elisp (run_hooks, safe_call, etc?)
> correctly, but second, I suspect if this is crashing due to a threading
> issue.
> 
>     handler = [NSEvent
> addGlobalMonitorForEventsMatchingMask:(NSEventMaskKeyDown)
> handler:^(NSEvent *event){
>         if (event.modifierFlags & modifier)
>           if([event.charactersIgnoringModifiers characterAtIndex:0] ==
> vkey) {
>            RUN_SOME_ELISP_FUNCTION
>             [[NSApp mainWindow] makeKeyAndOrderFront:NSApp];
>           }
>         }
>       }];

I think you probably want to send an event to Emacs, that way a user
can bind it to anything they like. Look at, say, [EmacsApp openFile:]
for how do that.

One potential problem with your approach is that we don't accept code
using Objective C blocks as it's incompatible with GCC. Unless that
policy has changed?
-- 
Alan Third




This bug report was last modified 4 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.