Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在命令行上的emacs中指定窗口布局_Emacs - Fatal编程技术网

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

在命令行上的emacs中指定窗口布局,emacs,Emacs,我希望能够在从命令行启动Emacs时指定它的窗口布局 更具体地说,我调用“emacs file1 file2 file3 file4”,例如,如 +---------+ +--------+ | file1 | | buff | | | | list | +---------+ instead o

我希望能够在从命令行启动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,我不使用EmacClient


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

将以下内容放入
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)
然后

您需要做的唯一一件事是使用以下功能的组合按您想要的方式自定义布局:

(split-window-horizontally)
(split-window-vertically)
(other-windows 1)

谢谢你的帮助。然而,您提供的代码对我不起作用(我不理解如何修复它)。然而,你所做的让我想到了如何解决我的问题。我按照您的建议创建了“layout.el”,并添加了一行(addhook'emacs startup hook(lambda()(其他窗口1)(切换到buffer“bar”)),以达到我最初的问题想要的效果。要获得额外的修改,我可以按照您的建议使用(水平拆分窗口)(垂直拆分窗口)。如果我使用给定的代码,那么我将得到四个窗口。最底部是最大的,取下框架的下半部分,并包含“条”,上面有三个窗口。它们中最右边的占据了右边一半的空间并包含“foo”。左侧顶部分为“blah”和“*Scratch”,底部为“blah”,顶部为“*Scratch”。如果我注释掉“(垂直拆分窗口)”,我会得到三个带有“blah”、“foo”和“bar”的窗口。此外,如果我注释掉“(水平拆分窗口)”,我会在顶部看到“foo”,在底部看到“Buffer List”。似乎在启动时,emacs会根据窗口大小和打开的文件数量拆分窗口。启动屏幕也会干扰窗口配置。。。设置窗口配置之前的
(删除其他窗口)
似乎可以解决此问题。同时设置
(setq禁止启动屏幕t)
谢谢您的帮助!它确实很有帮助。实际上不需要
有序窗口-*
函数。请参见“漫游窗口树”
(split-window-horizontally)
(split-window-vertically)
(other-windows 1)