2

我希望能够在从命令行启动 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。

请注意,我不想使更改永久化。这就是为什么我要求命令行解决方案。

4

1 回答 1

2

将以下内容放入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)
于 2012-04-11T08:52:50.457 回答