bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#74619: macOS: <ns-show-prefs> displayed as keybinding for \\[customi


From: Robert Pluim
Subject: bug#74619: macOS: <ns-show-prefs> displayed as keybinding for \\[customize] on emacs -nw
Date: Mon, 09 Dec 2024 17:14:52 +0100

>>>>> On Sun, 08 Dec 2024 08:09:15 +0200, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Yoichi Nakayama <yoichi.nakayama@gmail.com>
    >> * Emacs built with --without-ns doesn't load term/ns-win.el (in this
    >> case, the problem doesn't occur)
    >> * Emacs built with --with-ns does load term/ns-win.el even in -nw process
    >> 
    >> Therefore, putting make-non-key-event for non-key events ns-* in the
    >> toplevel of term/ns-win.el solve the problem, and I also think
    >> term/ns-win.el is better place as you said "NS specific code should
    >> definitely go to ns-win.el".

    Eli> Thanks, then I guess it's okay to move the code there.

Except if we do that, then in the --with-ns build, the ⌘-, binding
(and the toplevel emacs/Settings menu item) doesnʼt work anymore. Iʼd
rather not have the code be duplicated, so how about this (I suck at
naming, so we can change the defun name):

diff --git i/lisp/term/common-win.el w/lisp/term/common-win.el
index 181dcc8e6d9..68c3b2d56e3 100644
--- i/lisp/term/common-win.el
+++ w/lisp/term/common-win.el
@@ -45,6 +45,8 @@ x-alternatives-map
     map)
   "Keymap of possible alternative meanings for some keys.")
 
+(declare-function ns-setup-special-keys "term/ns-win" ())
+
 (defun x-setup-function-keys (frame)
   "Set up `function-key-map' on the graphical frame FRAME."
   ;; Don't do this twice on the same display, or it would break
@@ -56,22 +58,7 @@ x-setup-function-keys
         (set-keymap-parent map (keymap-parent local-function-key-map))
         (set-keymap-parent local-function-key-map map))
       (when (featurep 'ns)
-       (setq system-key-alist
-             (list
-              ;; These are special "keys" used to pass events from C to lisp.
-              (cons  1 (make-non-key-event 'ns-power-off))
-              (cons  2 (make-non-key-event 'ns-open-file))
-              (cons  3 (make-non-key-event 'ns-open-temp-file))
-              (cons  4 (make-non-key-event 'ns-drag-file))
-              (cons  5 (make-non-key-event 'ns-drag-color))
-              (cons  6 (make-non-key-event 'ns-drag-text))
-              (cons  8 (make-non-key-event 'ns-open-file-line))
-;;;           (cons  9 (make-non-key-event 'ns-insert-working-text))
-;;;           (cons 10 (make-non-key-event 'ns-delete-working-text))
-              (cons 11 (make-non-key-event 'ns-spi-service-call))
-              (cons 12 (make-non-key-event 'ns-new-frame))
-              (cons 13 (make-non-key-event 'ns-toggle-toolbar))
-              (cons 14 (make-non-key-event 'ns-show-prefs))))))
+        (ns-setup-special-keys)))
     (set-terminal-parameter frame 'x-setup-function-keys t)))
 
 (defvar x-invocation-args)
diff --git i/lisp/term/ns-win.el w/lisp/term/ns-win.el
index 2a29457133e..640b7fe6dc7 100644
--- i/lisp/term/ns-win.el
+++ w/lisp/term/ns-win.el
@@ -168,6 +168,27 @@ global-map
 (define-key global-map [S-mouse-1] 'mouse-save-then-kill)
 (global-unset-key [S-down-mouse-1])
 
+;; Moved here from common-win.el because they need to work in a -nw
+;; invocation of a (featurep 'ns) => true build.  Bug#74619.
+(defun ns-setup-special-keys ()
+  (setq system-key-alist
+        (list
+         ;; These are special "keys" used to pass events from C to lisp.
+         (cons  1 (make-non-key-event 'ns-power-off))
+         (cons  2 (make-non-key-event 'ns-open-file))
+         (cons  3 (make-non-key-event 'ns-open-temp-file))
+         (cons  4 (make-non-key-event 'ns-drag-file))
+         (cons  5 (make-non-key-event 'ns-drag-color))
+         (cons  6 (make-non-key-event 'ns-drag-text))
+         (cons  8 (make-non-key-event 'ns-open-file-line))
+;;;            (cons  9 (make-non-key-event 'ns-insert-working-text))
+;;;            (cons 10 (make-non-key-event 'ns-delete-working-text))
+         (cons 11 (make-non-key-event 'ns-spi-service-call))
+         (cons 12 (make-non-key-event 'ns-new-frame))
+         (cons 13 (make-non-key-event 'ns-toggle-toolbar))
+         (cons 14 (make-non-key-event 'ns-show-prefs)))))
+(ns-setup-special-keys)
+
 ;; Special Nextstep-generated events are converted to function keys.  Here
 ;; are the bindings for them.  Note, these keys are actually declared in
 ;; x-setup-function-keys in common-win.


Robert
-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]