我希望能够在从命令行启动 Emacs 时指定 Emacs 的窗口布局。
更具体地说,我调用“emacs file1 file2 file3 file4”,例如,就像看到
+---------+ +--------+
| file1 | | buff |
| | | list |
+---------+ instead of the default +--------+ that I see currently
| | | |
| file3 | | file4 |
+---------+ +--------+
我的 emacs 是 GNU Emacs 24.0.91.1,并且我不使用 emacsclient。
请注意,我不想使更改永久化。这就是为什么我要求命令行解决方案。
最佳答案
将以下内容放入layout.el
(setq inhibit-startup-screen t)
(defun ordered-window-list-aux (tree)
(if (windowp tree)
(list tree)
(append (ordered-window-list-aux (nth 2 tree))
(ordered-window-list-aux (nth 3 tree)))))
(defun ordered-window-list ()
"Lists windows from top to bottom, left to right."
(ordered-window-list-aux
(car (window-tree))))
(require 'cl)
(defun fill-windows ()
"Make window list display recent buffer."
(mapcar*
(lambda (win buf)
(set-window-buffer win buf))
(nreverse (ordered-window-list))
(buffer-list)))
(delete-other-windows)
;; your window configuration
(split-window-horizontally)
(split-window-vertically)
;; Make window list display recent buffer
(fill-windows)
然后
emacs blah foo bar --load layout.el
您唯一需要做的就是使用以下功能的组合来按照您想要的方式自定义布局:
(split-window-horizontally)
(split-window-vertically)
(other-windows 1)
关于emacs - 在命令行上指定 emacs 中的窗口布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10097321/