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

标签 emacs

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

相关文章:

emacs - 如何在组织模式下组织信息,以便将表格作为输出?

emacs - 如何在 RET 上禁用电子缩进但仍保留其他电子字符(例如 ‘{’ )?

关闭缓冲区后显示的 Emacs 缓冲区

regex - 选择包含 "some"字的行

emacs - 在 Lisp 中,使用 require 时避免使用 "Cannot open load file"

emacs - 如何为新语言编写 emacs 模式?

emacs - 更改 Emacs 中的默认文件夹

emacs - 是否有一个多语言程序可以生成与 emacs 兼容的来电者信息?

emacs - 如何使迷你缓冲区窗口变大?它不够大,默认显示向上/向下箭头

emacs - 如何中止 Clojure Box (Emacs) 中的评估?