Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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))
like image 413
Willi Ballenthin Avatar asked Nov 28 '25 08:11

Willi Ballenthin


1 Answers

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.

like image 107
Tyler Avatar answered Nov 30 '25 22:11

Tyler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!