It will be necessary to decide ahead of time what windows/buffers will be A, B and C. The alist argument for the left window-width
can be adjusted to taste -- it is presently hard-coded to 70. This example uses an internal function window--display-buffer
, which requires some general understanding of certain functions inside window.el
. The selected-window
is letter B
, but this can be changed (with a little coding) if so desired.
(defun example-fn ()
"To try this example, type: M-x example-fn"
(interactive)
(let ((a (dired-noselect "~"))
(b (find-file-noselect "~/foo.txt"))
(c (get-buffer-create "*scratch*")))
(delete-other-windows)
(switch-to-buffer b)
;; See the doc-strings for `split-window' and `window--display-buffer'.
(window--display-buffer
a (split-window (selected-window) nil 'left)
'window '((window-width . 70)) display-buffer-mark-dedicated)
(window--display-buffer
c (split-window (selected-window) nil 'below)
'window nil display-buffer-mark-dedicated)))
And, if a keyboard shortcut is desired, it can be set with:
(global-set-key (kbd "<f5>") 'example-fn)
To incorporate this new example into lawlist-bookmark
, the entire let
section of example-fn
can be added or just use the name of the function itself.
(defun lawlist-bookmark (choice)
"Choices for directories and files. http://stackoverflow.com/a/19284395/2112489"
(interactive "c[3]-way | [D]ired | [v]ocab.org | [g]td.org | [d]iary.org | [n]otes.org")
(cond
((eq choice ?3)
(example-fn))
((eq choice ?D)
(dired "/very/long/and/boring/path/which/make/me/use/tab/for/..."))
((eq choice ?v)
(find-file "/Users/HOME/.0.data/vocab.org")
(message "Opened: %s" (buffer-name)))
((eq choice ?g)
(find-file "/Users/HOME/.0.data/gtd.org")
(message "Opened: %s" (buffer-name)))
((eq choice ?d)
(find-file "/Users/HOME/.0.data/diary.org")
(message "Opened: %s" (buffer-name)))
((eq choice ?n)
(find-file "/Users/HOME/.0.data/notes.org")
(message "Opened: %s" (buffer-name)))
(t (message "Quit"))))
Pursuant to the request of the original poster in a comment underneath the initial answer, the following is an example of how to select window letter A
:
(defun example-fn-two ()
"To try this example, type: M-x example-fn"
(interactive)
(let ((window-a nil)
(window-b (selected-window))
(window-c nil)
(buffer-a (dired-noselect "~"))
(buffer-b (find-file-noselect "~/foo.txt"))
(buffer-c (get-buffer-create "*scratch*")))
(delete-other-windows)
(set-window-buffer window-b buffer-b)
(setq window-a
(window--display-buffer
buffer-a (split-window window-b nil 'left)
'window '((window-width . 70)) display-buffer-mark-dedicated))
(setq window-c
(window--display-buffer
buffer-c (split-window window-b nil 'below)
'window nil display-buffer-mark-dedicated))
(select-window window-a)))