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))
Community
  • 1
  • 1
Willi Ballenthin
  • 6,444
  • 6
  • 38
  • 52

2 Answers2

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.

Tyler
  • 9,872
  • 2
  • 33
  • 57
  • 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? – Willi Ballenthin Feb 06 '11 at 05:38
  • 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 # – Tyler Feb 06 '11 at 16:43
  • 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! – Willi Ballenthin Feb 06 '11 at 22:45
0
(add-to-list 'default-frame-alist '(fullscreen . fullboth)) 

in .emacs does the job.

ppr
  • 685
  • 7
  • 24