AmazingMiki
AmazingMiki

Reputation: 254

emacs daemon ignores a setting (tool-bar-mode -1) which normal emacs does not

If I run emacs, the tool-bar does not appear and accepts my setting of: (tool-bar-mode -1)

without any problems.

If I run:

emacsclient -c -a ' '

(launch emacs client and launch emacs --daemon if no emacs daemon is running)

Then the tool-bar appears and I have to disable it manually via

M-x RET tool-bar-mode RET M-x RET tool-bar-mode RET

I do not know why I must do it twice after I do it once, it tells me that tool bar mode is enabled (but it already was enabled?) then a second time disables it successfully.

I don't really think that the setting is being ignored, I think that the expected loading order of my ~/.emacs.d/init.el is being disrupted because of something in the design of the daemon feature in emacs.

I do not know what that is exactly, and I'm not here to fix emacs itself. I just want to acknowledge this issue, and be able to handle it.

Any help would be much appreciated.

p.s. - I recently started using package.el, so I think it could have something to do with it. ask me for whatever you need to know to help me solve this.

Thank you.

EDIT: (have no mistake, although I fixed the problem, I still do not consider this resolved since I still have a question)

I solved the problem by taking the line with

(tool-bar-mode -1)

and moving it to be the last thing on my init.el

since that I actually do not want to sabotage my init.el majestic order and design, I moved that line around between where it was and where it started working, reducing the gap until I found the one problematic line:

from some reason, if:

(tool-bar-mode -1)

is provided before this line:

(setq default-frame-alist '((cursor-color . "white")))

AND

emacs is being launched in daemon mode

then:

that line would be ignored, in the way that tool-bar-mode is actually marked as disabled (since M-x RET too-bar-mode supposibly enables it for the first time) and at the same time tool-bar-mode is physically enabled.

if emacs is being launched normally then none of this would happen.

in that case, given all this info I've learned, I want to change my question into something a bit shorter:

WHY?

thank you :)

Upvotes: 0

Views: 1004

Answers (2)

Color
Color

Reputation: 985

  • create a new file cemacs with contents like bellow, you should change the emacsfolder variable
  • make this file executable, and put it to your $PATH
  • now you can use cemacs as your emacsclient alternative
#!/bin/bash
# NOTE: jetbrains external tools doesn't support `env bash` command

# TODO: you should change to your own folder
emacsfolder=/Applications/Emacs.app/Contents/MacOS

# execute emacs command to disable ui
$emacsfolder/bin/emacsclient -e '(progn (scroll-bar-mode -1) (tool-bar-mode -1))'

# start emacsclient
$emacsfolder/bin/emacsclient $args "$@"

Upvotes: 0

Tyler
Tyler

Reputation: 10032

(tool-bar-mode -1)

Turns off the toolbar for the current frame. For normal Emacs, that's the frame you're looking at. You then change the default frame parameters for new frames via

(setq default-frame-alist '((cursor-color . "white")))

At this point, if you open a new frame, the only non-default parameter is cursor-color.

Running in daemon mode, you don't have an active frame when you turn off the toolbar. The first visible frame uses default-frame-alist, which does not modify the toolbar setting.

You can set tool-bar-lines to 0 in default-frame-alist to turn off toolbars for all new windows.

Upvotes: 1

Related Questions