[Bug]: Pretzel-Q in neomacs quits neomacs as with a crash
Bug summary
The key combo I'm expecting to be bound to fill-paragraph instead causes neomacs to quit immediately without warning about unsaved buffers, etc.
Steps to reproduce
Launch.
Pretzel-Q
Expected behavior
I'm expecting pretzel-Q to be M-q, ordinarily bound to fill-paragraph. Note that the menu on mac has the pretzel-Q grayed out, suggesting that it won't be recognized. Also note that pretzel-Q does not go through the usual warnings about unsaved buffers. Instead, unsaved work is lost as with a crash.
Neomacs --version output
emacs-version reports 31.1
[email protected]> /Applications/neomacs.app/Contents/MacOS/neomacs --version
Neomacs 0.0.20
Git commit: 47fa15cc69ae8f8da1ca3fac25e0beb700e8c118
Source date: 2026-10-24T15:13:18.000000000-04:00
Build: release for aarch64-apple-darwin with rustc 1.96.1
Standalone Rust binary for Neomacs (no C dependency)
Platform
Linux (X11)
Install source
Prebuilt release asset (downloaded from Releases)
Extra context
No response
Neomacs is unusable at this point. I start to use it... hit fill paragraph, and all my work is lost.
Unusable.
If you go with the above "fix", please make it configurable. I want my M-q to be M-q.
😭 Sorry for the unacceptable bug.
Investigating.
@neomacs-agent can neomacs-gui-tests can running on MacOS now?
Yes, the suite builds and can run on macOS, but only a subset is exercised there and the full gui target is not part of an automatic macOS gate.
Verified locally at current main (a529ae5c5a):
cargo nextest list --release -p neomacs-gui-tests --test gui→ compiles and links the full GUI test binary on macOS (release profile) and lists its tests.cargo nextest run --release -p neomacs-gui-tests --test gui -E 'test(harness_contract)'→ 16/16 passed.real_gui_smoke_generates_surface_readback_pngwithNEOMACS_GUI_TEST_BACKEND=macosand a prebuilt release binary → the app launched on the current desktop and produced a frame snapshot andgui_state(buffer text, window start/end), but the test failed at the PNG surface-readback artifact (PNG artifact was not generated). I did not do a freshcargo xtask fresh-build --release, so this is not a green run of the smoke test on currentmain; the manual macOS smoke workflow only requires the snapshot, not the PNG.- I did not run
macos_native_menusorinteraction_geometry. They requirescripts/build-macos-gui-driver.sh, a runningNeomacsGuiDriver.app, the ABC keyboard layout, Accessibility and Screen Recording grants, and a logged-in unlocked desktop. The driver socket is not set up here, and those tests fail explicitly (rather than skipping) when prerequisites are missing.
CI/platform status:
- The automatic
neomacs-gui-testsjob intest-suite.ymlis Linux x86_64 only (X11 + Wayland). - macOS runs are manual:
native-display-contract.yml(workflow_dispatch, macOS matrix entry, runs--test native_display) andtmp_mac_test.yml(manual fresh build plus startup snapshot smoke). The native-display contract has succeeded on macOS in recent manual runs, so the macOS path is real, just not a per-PR requirement. - In the suite,
GuiBackend::Macosmaps toRunnerKind::CurrentDesktopSession; snapshot/geometry tests work on the current desktop, while physical pointer/keyboard tests need the permissioned helper described above.
For #668 specifically, there is currently no s-q / Cmd-Q / quit-chord test in the GUI suite, so even a working macOS run today would not cover it. The macOS driver can send physical key events, so a Cmd-Q regression test is feasible, but it needs the helper permissions. I can investigate/reproduce #668 and add that test if you want.
Follow-up TODO: remaining GNU quit-path deviations (not covered by #677)
#677 fixed the reported data loss: the AppKit Quit item now feeds s-q, so it runs save-buffers-kill-emacs and prompts. Two GNU behaviours are still missing. Evidence is from GNU 31.1 at a360712c9d and from current main (b076e99fba).
1. applicationShouldTerminate: / ns-confirm-quit are inert
GNU:
src/nsterm.m:6628-6641—applicationShouldTerminate:returnsNSTerminateNowwhenns-confirm-quitis nil; otherwise it runs a native alert, "Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", and returnsNSTerminateNow/NSTerminateCancel.src/nsterm.m:11653-11655—ns-confirm-quitis aDEFVAR_LISPwhose default is nil.
Neomacs:
- The variable is seeded (
crates/neovm-eval/src/emacs_core/runtime/eval/ns_surface.rs:49) and documented, but nothing reads it. - There is no
NSApplicationDelegate:applicationShouldTerminatedoes not occur anywhere in the repo, and the only AppKit application use isNSApplication::sharedApplicationincrates/neomacs-display-runtime/src/render_thread/macos_quit_redirect.rs:131. - The pinned winit fork observes only
NSApplicationWillTerminateNotification(winit-appkit/src/event_loop.rs:402-412→app_state.rs:188-193), which fires after the terminate decision already exists.
Consequence: a system-initiated terminate (logout/restart, osascript -e 'quit app "Neomacs"', Activity Monitor) exits immediately, so (setq ns-confirm-quit t) has no effect. With the default nil GNU also exits immediately, so today the defaults agree; the opt-in confirmation is what is missing.
TODO:
- [ ] Give Neomacs an
NSApplicationDelegatethat answersapplicationShouldTerminate:on the AppKit main thread: readns-confirm-quitfrom the Lisp side, run GNU's alert (or its equivalent), returnNSTerminateNow/NSTerminateCancel. - [ ] Pick the installation point (
macos_quit_redirect::installalready runs fromhandle_resumed); the pinned winit fork sets no delegate itself, so the slot is free. - [ ] Manual macOS verification for logout, AppleScript quit, and a modified buffer.
2. Menu Quit routes through the s-q binding instead of an ns-power-off event
GNU:
- The app menu Quit action is
terminate:(src/nsterm.m:6095-6097), and-[EmacsApp terminate:]posts the non-keyKEY_NS_POWER_OFF(src/nsterm.m:6588-6604). lisp/term/ns-win.el:177registers it as a non-key event;:195binds[ns-power-off]tosave-buffers-kill-emacs;:141bindss-qseparately.
Neomacs after #677:
- The Quit item is retargeted to synthesize
super+q(macos_quit_redirect.rs:37-43, installed at:122-165).
Consequence: rebinding s-q also changes what menu Quit and ⌘Q do — e.g. (global-set-key (kbd "s-q") #'fill-paragraph) makes the Quit menu item fill a paragraph — whereas in GNU the two routes are independent. This is closer to the "make it configurable" request in this issue, but it is still a GNU deviation.
TODO:
- [ ] Route the retargeted menu action through an
ns-power-off-style non-key event (or the equivalent internal quit command) instead ofs-q, and keep both[?\s-q]and[ns-power-off]bound tosave-buffers-kill-emacsas GNU does. - [ ] Preserve the current deferral while the input queue is full (
PENDING_QUIT/about_to_waitretry). - [ ] Add a regression test for the chosen routing; the Lisp side is testable on Linux, the AppKit side needs a manual macOS run.
Verification constraint: the macOS AppKit path is not gated in automatic CI (GUI tests run on Linux; macOS native-display runs are manual). Existing Lisp pins are neo_preload_binds_command_q_like_gnu_on_darwin and the oracle super_q_binding_matches_gnu_per_platform.
Update: the remaining quit-path differences from the earlier follow-up are fixed on main as of 40a4a7bd0e. They now follow GNU Emacs 31.1:
- ⌘Q is an ordinary key. As in GNU's Cocoa build, the Command key is
superby default (ns-command-modifierissuper, fromsrc/nsterm.m), so ⌘Q arrives ass-q.s-qis bound tosave-buffers-kill-emacs(lisp/term/ns-win.el), so it prompts about unsaved buffers instead of quitting. You can rebind it like any other key. - To make ⌘Q mean
M-q(fill-paragraph), which is what you expected, do what you would in GNU Emacs and set(setq ns-command-modifier 'meta). ⌘ then acts as Meta. - The application menu's Quit item goes through the same confirmation path, so it can no longer drop unsaved work.
Tested on macOS (Apple Silicon): the quit-confirmation tests pass, and so do the key-binding tests, which compare against a GNU Emacs 31.1 build on the same Mac. We could not press a physical ⌘Q in CI, because macOS doesn't allow synthetic input there. It would help a lot if you could try ⌘Q with an unsaved buffer on a build from current main and tell us whether you get the save prompt. This will be in v0.0.21.
Fixed in v0.0.21 (e351332e02 / 0b3a088ccf and follow-ups):
- ⌘Q arrives as
s-qand runssave-buffers-kill-emacs. - The menu's Quit item goes through the same confirmation.
Unsaved work is no longer lost. If you want ⌘ to act as Meta (so ⌘Q is M-q), set (setq ns-command-modifier 'meta), the same as in GNU Emacs.
All nine non-physical quit paths are compared against GNU. We could not press a physical ⌘Q in CI, so please reopen if v0.0.21 still quits without the save prompt.