When I open an R file in ESS-mode, I'd like emacs to setup my panes in a certain format.
To this end, I've added the following to my init.el.
(add-hook 'ess-mode-hook
(lambda()
(split-window-horizontally)
(other-window 1)
(vterm)
(R)
))
When I run emacs myfile.R, emacs opens and prompts me to specify a project directory, which I do. This results in the vertical split on the right, which gives me pretty much what I show above. Awesome! But there is one problem. While myfile.R is opened as a buffer, the left-hand pane actually shows the scratch buffer. Why is that and how do I avoid it?

lambdawith something like(delete-other-windows)[to return the layout to just one visible window] and then go from there? Eventually, there are more precise functions you may wish to use for specifying a window-layout, but the ones you've chose are what most beginners use and I've even seen some users with more experience still post answers using those same functions.(delete-other-windows), you may wish to consider following up that command with something like(set-window-buffer (selected-window) (find-file-noselect FILE 'nowarn))or replace(find-file-noselect FILE 'nowarn)withBUFFER-OR-NAME, which may be known or can be obtained if need be.myfile.R(as per my example). Is there a way to figure out what the passed filename is programmatically? Perhaps pulling it frombuffer-listorcommand-line-argssomehow... (First day using Elisp, so I'm still finding my feet.)/absolute/path/to/preferred/version/of/emacs -nw foo.txt, then(car (last command-line-args))returns"foo.txt".