I haven't used emacs for a while, but I noticed recently that setting ns-appearance does not change frames to dark mode in emacsclient. I tried with a minimal init file
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
In emacsclient, transparent title bar works but dark mode doesn't work. Both setting works in non-daemon emacs, however.
I'm currently running macOS 10.15.6 with emacs-plus 27.1. emacs-plus is installed using homebrew with option
--with-no-frame-refocus
Hi @jaaasonSun ,
Could you please tell me how you start the server?
Hi @jaaasonSun ,
Could you please tell me how you start the server?
I usually start emacsclient and start emacs server (if necessary) with this script from this article
# Number of current visible frames,
# Emacs daemon always has a visible frame called F1
visible_frames() {
emacsclient -a "" -e '(length (visible-frame-list))'
}
change_focus() {
emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null
}
# try switching to the frame incase it is just minimized
# will start a server if not running
test "$(visible_frames)" -eq "1" && change_focus
if [[ $* == *-nw* ]]
then
emacsclient "$@" && change_focus
else
emacsclient -n -c "$@" && change_focus
fi
But I've also tried starting emacs server with
emacs --daemon
and start emacsclient with
emacsclient -c -n
and dark mode doesn't work in both cases.
I could not reproduce when running it differently:
Emacs.app.M-x server-mode.$ emacsclient testfile.txt.But in some sense it's cheating. So maybe it's really related to the daemon mode. I think I've seen some similar reports related to daemon mode. 馃 Don't remember where and when.
Will play around with it later.
P. S. I don't understand how your script starts the emacs daemon. AFAIK, emacsclient doesn't work unless the server is running already. Apologies for dummy questions, I am not using emacsclient so might be missing something obvious here.
emacsclient -a EDITOR tries to start emacsclient with a fallback editor, and will start emacs daemon if no server is running and no fallback is provided.
- Start Emacs.app.
M-x server-mode.$ emacsclient testfile.txt.
So I tried this but $ emacsclient testfile.txt defaults to opening the file in an existing frame (which afaik always exists because server-mode requires the Emacs.app running?), and since existing frame is started directly from Emacs.app, it is in dark mode (correctly).
With -c option emacsclient will start a new frame. In this case, I'm seeing the same behavior that the new frame is in light mode.
Thank you for explanations.
which afaik always exists because server-mode requires the Emacs.app running
yes, that's why I said that it's cheating :smile_cat:
With -c option emacsclient will start a new frame. In this case, I'm seeing the same behavior that the new frame is in light mode.
Can reproduce. Thanks :)
P. S. Can't provide any ETA :disappointed: but will keep it top in my priorities :)
Thank you so much for your help!
Update:
These are the options used to build emacs-plus@28 and emacs-head@28
brew install emacs-plus@28 --with-xwidgets --with-no-frame-refocus --with-modern-cg433n-icon
brew install emacs-head@28 --with-cocoa --with-imagemagick --with-xwidgets
Sorry that I don't know much about homebrew formulae and how emacs is built so I couldn't be of much help. But emacs-plus and emacs-head seem quite similar. Hope this information will be of help.
@jaaasonSun thank you very much for the update. I am glad that you found a workaround with emacs-head.
@daviderestivo did you add anything special? Maybe some patch? 馃
@daviderestivo did you add anything special? Maybe some patch? 馃
@d12frosted to be honest I don't I have any special patch ...
@daviderestivo that's what I thought 馃樃 then it's strange that it works in emacs-head and doesn't work here 馃樃 馃し
I'm closing this issue because the behavior is completely due to my error, although I still cannot account for the difference between emacs-head and emacs-plus.
Two keys were written to defaults:
$ defaults read org.gnu.Emacs
{
... # omitted
NSRequiresAquaSystemAppearance = true;
TransparentTitleBar = DARK;
}
to (presumably) force emacs to use system dark mode before it was properly supported. Simply removing the lines with
$ defaults delete org.gnu.Emacs NSRequiresAquaSystemAppearance
$ defaults delete org.gnu.Emacs TransparentTitleBar
Wow, that was interesting. Thanks for reporting back 馃挴