在命令行上的emacs中指定窗口布局

时间:2012-04-10 22:23:20

标签: 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。

注意,我不想永久改变。这就是我要求命令行解决方案的原因。

1 个答案:

答案 0 :(得分: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)