2
votes

I start emacs with emacs --daemon when the computer starts up, and then open a new graphical frame with emacsclient -c -n.

According to https://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html:

If you omit a filename argument while supplying the ā€˜-c’ option, the new frame displays the scratch buffer by default. If initial-buffer-choice is a string, the new frame displays that file or directory instead.

I have (setq initial-buffer-choice "~/") in my ~/.emacs. However, when I open a new frame, it still starts *scratch*, rather than ~. I have a ~ buffer, but it's not the displayed initially.

Is there something else I need to do to prevent the *scratch* buffer (which I never use) from being created?

Even with a minimal ~/.emacs which only has (setq initial-buffer-choice "~/"), upon starting a new frame with emacsclient -c -n, it still opens up with *scratch*.

1
Odd -- when I open a client with these settings, I get the "~" buffer (although there's no initial-scratch-buffer variable). Can you start up the daemon, open a client, and then check what initial-buffer-choice evaluates to? - Dan
I saw initial-scratch-buffer on another stackoverflow answer. How do I check the value of a variable? - Dan Jones
You might be thinking of initial-scratch-message (which controls that line of text at the top of the scratch buffer), but that won't be related to this question. To check the value of initial-buffer-choice, hit M-: (or M-x eval-expression) and then enter initial-buffer-choice, which will tell you what that variable evaluates to. - Dan
Got it. I typed (eval initial-buffer-choice) into the *scratch* buffer (that showed up when launched with emacsclient -c), and evaluated it C-x C-e, and it said "~/" in the mini-buffer. - Dan Jones
Huh. If, with one graphical frame already open, you open another client the same way, do you still default to the scratch buffer? - Dan

1 Answers

4
votes

This behavior appears to be limited to versions before 24. In emacs 23, emacsclient -c (or emacsclient -t) always opens to *scratch*, even when initial-buffer-choice is set. This is fixed in emacs 24, so the solution is to upgrade.