2

I have the following for ridding of the toolbar on startup in graphical mode in my init configuration:

(if window-system
    (tool-bar-mode -1)
)

the issue:

it works fine (albeit slow...see this post) when starting emacs but does not work with the emacs --daemon , starting emacsclient c starts a graphical client with toolbar ( I want without). Does emacs graphical client require a seperate code to the if window-system?

I run:

emacs 25.3 on Linux manjaro 17.1.5 Hakolla

3

The most simple solution to your actual problem -- avoiding the tool bar -- is to customize tool-bar-mode to nil. Alternatively you can also put (setq tool-bar-mode nil) into your init file.

The problem with window-system in emacs daemon is that the virtual frame of the emacs daemon is not connected to any display. Since the init file runs in the daemon window-system is nil.

Furthermore, you shouldn't use windows-system as bool variable. Use display-graphic-p instead. See the last section of the windows-systems doc.

The server creates display frames for clients on demand (with option --create-frame).

Therefore, after-make-frame-functions is the right place to hook in if you want to tweak your graphical frames generated by an emacs daemon. In the following I give you an example:

(defun my-frame-tweaks (&optional frame)
  "My personal frame tweaks."
  (unless frame
    (setq frame (selected-frame)))
  (when frame
    (with-selected-frame frame
      (when (display-graphic-p)
    (tool-bar-mode -1)))))

;; For the case that the init file runs after the frame has been created.
;; Call of emacs without --daemon option.
(my-frame-tweaks) 
;; For the case that the init file runs before the frame is created.
;; Call of emacs with --daemon option.
(add-hook 'after-make-frame-functions #'my-frame-tweaks t)
  • and thanks for the explenation. I will read the windows-systems doc now. @Tobias – manandearth Mar 11 '18 at 14:32
  • @manandearth Have you tried just to customize the variable tool-bar-mode to nil? That should work for global modes like tool-bar-mode. (I never tried in connection with the emacs daemon.) That would be the simplest solution and if you checked it positively I would add it in front of my answer. – Tobias Mar 11 '18 at 14:40
  • It's also possible to just make a check with featurep. – DoMiNeLa10 Mar 11 '18 at 14:44
  • @Tobias It doesn't work with tool-bar-mode set to nil. not for the emacsclient – manandearth Mar 11 '18 at 14:44
  • @manandearth I've just tried it and it works for me. So I added it in front of my answer. – Tobias Mar 11 '18 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.