After following instructions from https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration on starting emacs 27.1 as daemon in windows 10 where path\to\emacs is "c:\emacs-27.1\bin\runemacs.exe --daemon , see here:
You can also open Explorer, type in shell:startup in the address bar, and press enter. In this startup >folder, create a shortcut by right clicking and selecting new->shortcut. When asked for location, put >the following: "X:\path\to\emacs\bin\runemacs.exe" --daemon where you have substituted the proper path >to runemacs.exe. This shortcut will run at startup. You can double click on the shortcut to start the >Emacs server if it is not already running.
Emacs daemon loads initialization file in c:/emacs-27.1/.config/emacs/init.el and properly so far defines ever function, only there are key-bindings initialized in the init and listed under describe-personal-keybindings that don't work when emacsclientw.exe starts.
They are bindings that were initially reserved for windows and decoded then recoded in the init. This guy, for example, doesn't play nicely (nothing happens after C-m) in a client connected to a daemon, but works just fine when emacs is started with a frame.
(define-key input-decode-map [?\C-m] [C-m])
; translate it as synonymous with <apps> key
(define-key key-translation-map (kbd "<apps>") (kbd "<C-m>"))
;create a prefix command
(define-prefix-command 'super-keymap)
;set C-m as the prefix-command (note s- is also enabled now, so all C-m can be run with s-)
(global-set-key (kbd "<C-m>") super-keymap)
The same bug occurs after rebinding these guys C-[
and C-]
;rebind C-] keys
;rebind abort-recursive-edit, ESC will work on windows
(global-unset-key (kbd "C-]"))
(define-key input-decode-map (kbd "C-[") [control-bracketleft])
(bind-key [control-bracketleft] 'sp-backward-sexp)
(global-unset-key (kbd "C-]"))
(define-key input-decode-map (kbd "C-]") [control-bracketright])
(bind-key [control-bracketright] 'sp-forward-sexp)
The daemon doesn't of course open up a frame when it launches, hence likely it's in terminal mode. Maybe those keys on windows are not accessible from the same commands in terminal mode? Or is something else going on here?
Any takers?
Solution for me was to run the client with arguments.
pathTo/emacsclientw.exe -n -c -a "" -e "(rebind-keys)"