0

I am wondering if and how it is possible to do the following things in Emacs:

  1. Load a certain file whenever Emacs is opened. In particular, it is a .ORG file located in user's home directory.

  2. Create a certain arrangement of windows within that Emacs frame. The frame is open as a GUI, if that matters. For example, it could be two vertical windows with one of them in-turn split into three smaller windows.

Drew
  • 29,895
  • 7
  • 74
  • 104
MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
  • 1
    For point 2, do `desktop-save` and `desktop-read` do what you want? (See also [this question](https://stackoverflow.com/q/392314/113848)) – legoscia Apr 03 '19 at 09:04
  • 1
    Here is a link to an example of how to achieve something very similar to what you are looking for: https://emacs.stackexchange.com/questions/26967/open-several-files-in-a-specifc-layout-with-a-shortcut – lawlist Apr 04 '19 at 02:26

1 Answers1

2

This is a somewhat inelegant solution, but you could just have your init file run the exact same commands that you would use to manually achieve your setup (use C-h f to help look up any keyboard shortcuts whose command names you don't know).

To open a file, you can use the command find-file (the command run by C-x f). You can use split-window-right and split-window-below (C-x 2 and C-x 3, respectively) to split your window. (It should be noted that there is a more general split-window command, but I'm avoiding it here since I am just replicating what Emacs would do if we set everything up manually.) The command other-window (C-x o) changes windows within a frame - note that this function requires an input argument (the number of windows to go over) when not used interactively.

You could obtain a setup similar to what you were asking about (org file on left, 3 horizontal splits on right, all separate empty buffers) with the following:

(find-file "ABSOLUTE-PATH-TO-FILE.org")
(split-window-right)
(other-window 1)
(split-window-below)
(switch-to-buffer "Fresh-Buffer-1")
(other-window 1)
(split-window-below)
(switch-to-buffer "Fresh-Buffer-2")
(other-window 1)
(switch-to-buffer "Fresh-Buffer-3")
(balance-windows)
(other-window 1)

You may also want to use the functions set-frame-height and/or set-frame-width to give yourself an appropriately sized frame (example usage (set-frame-width (selected-frame) 120)). Additionally, I'd recommend putting this at the end of your init file so that the modes of the buffers you are creating can't interfere with any of your other init functions.

D. Gillis
  • 670
  • 5
  • 8