How can I set styling and positioning of a newly created emacsclient?
Asked Answered
G

2

3

I've recently switched to emacsclient for most text editing. I am trying to migrate some of my settings to the new (and slightly different) environment.

In particular, in my .emacs file I have a function that sets the window size, and prepares some themes. However code in the .emacs file is not executed on each invocation of emacsclient, so the settings do not apply to these windows. Based on the question here, I added a hook to 'server-visit-hook that called a function which executed my settings. However, the settings are not being applied when I restart the server and invoke emacsclient.

How can set the styling and positioning of new emacsclient windows? Relevant portions of my .emacs are included below:

(defun gui-mode()
  (set-face-attribute 'default nil :font "Monospace-8")
  (require 'theme-wombat)
  (set-frame-size-according-to-resolution))

(add-hook 'server-visit-hook 'gui-mode)

(when window-system
  (gui-mode))
Galla answered 30/11, 2010 at 16:1 Comment(0)
K
5

Start emacsclient with the -e option, and use that to tell it to load your configs:

emacsclient -c -e '(load "~/.emacsclient")'

where ~/.emacsclient contains your configuration code. You probably want to define an alias or menu option so that you don't actually type that in every time you call emacsclient.

Kooima answered 4/2, 2011 at 18:25 Comment(3)
Thanks for the response. Works the first time I call emacsclient, but subsequent calls to the client do not invoke the configuration code. Do you know of a hook invoked each time a frame is viewed?Galla
I'm not sure. How are you closing the client? Does it matter if you close by killing the window vs invoking server-edit, ie.: C-x #Kooima
I take my first comment back... I was looking for the wrong thing to determine if the load was working. Your suggestion works great as is!Galla
I
0
(add-to-list 'default-frame-alist '(fullscreen . fullboth)) 

in .emacs does the job.

Incredulity answered 13/12, 2013 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.