How do I provide a command-line option to emacsclient?
Asked Answered
S

3

9

I start emacsclient using:

emacsclient -a "" -c

This opens a frame connected to the emacs daemon, and starts the daemon if it's not already started. Great, this works fine.

However, I like opening my emacs frames maximized. With emacs, I would use -mm. However, that doesn't work with emacsclient. How do I make this work?

(It seems I could make something work by adding a shell file like so: emacsclient -a "myshell.sh" -c, where the shell file is: emacs -mm, but I haven't been able to make that work - the server doesn't stay up.)

Sapir answered 2/12, 2011 at 23:7 Comment(1)
I'm not sure if this is possible however those settings could be defined in your .emacs or in you .Xressources. See this question.Deeplaid
E
16

You can add the following line to .emacs, so that Emacs can be started with the window maximized. See http://www.gnu.org/software/emacs/manual/html_node/elisp/Size-Parameters.html#Size-Parameters for details.

(add-to-list 'default-frame-alist '(fullscreen . maximized))

Emacs client accepts -F option, where you can specify frame parameters, so the above example would be:

emacsclient -c -a "" -F "((fullscreen . maximized))"
Exophthalmos answered 19/9, 2012 at 5:17 Comment(1)
emacsclient -c -a "" -F "((fullscreen . maximized))" is really handy! Thank you!Keys
W
3

Let's say you want to run emacsclient fullscreen, which was my case.

man emacsclient shows emacsclient has -F option:

-F, --frame-parameters=ALIST
       set the parameters of a newly-created frame.

In Emacs Manual, which is an info file, section (emacs) emacsclient Options has more information. Specifically for this question (elisp) Size Parameters mentions fullscreen parameter. To run emacsclient fullscreen, you need to supply an alist, with one element being (fullscreen . fullboth) like that:

emacsclient -c -F "((fullscreen . fullboth))"
Whitford answered 19/10, 2012 at 8:6 Comment(0)
E
2

emacsclient provides the --eval (-e for short) command line option for executing arbitrary Emacs Lisp code, so you can visit a file and call suspend-frame from the command line like so:

emacsclient -a "" -c --eval "(progn (find-file \"/tmp/my-file\") (suspend-frame))"

You could put this in a script, e.g:

#!/bin/bash
emacsclient -a "" -c --eval "(progn (find-file \"$1\") (suspend-frame))"
Exsanguine answered 3/12, 2011 at 11:21 Comment(2)
OK, but that wasn't the question... The question was how to run command-line options like -mmSapir
Emacs is open source, it should be fairly straightforward to modify emacsclient.c to create your own version of emacsclient which accepts -mm.Exsanguine

© 2022 - 2024 — McMap. All rights reserved.