在命令行中指定emacs中的窗口布局 [英] specify window layout in emacs on commandline

查看:238
本文介绍了在命令行中指定emacs中的窗口布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



更具体地说,我调用emacs file1 file2 file3 file4,这样我就可以在命令行中指定Emacs的窗口布局。例如,像看到

  + --------- + + ------ -  + 
| file1 | | buff |
| | |列表|
+ --------- +而不是我现在看到的
|的默认值+ -------- + | | |
| 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()
从上到下列出窗口,从左到右
(ordered-window-list-aux
(car(window-tree))))

(require'cl)

defun fill-windows()
使窗口列表显示最近的缓冲区
(mapcar *
(lambda(win buf)
(set-window-buffer win buf))
(nreverse(ordered-window-list))
(buffer-list)))

(delete-other-windows)

;;您的窗口配置
(水平分割窗口)
(垂直分割窗口)

;;使窗口列表显示最近的缓冲区
(fill-windows)

然后

  emacs blah foo bar --load layout.el 

您唯一需要做的就是使用以下功能组合来自定义布局:

 (split-window-horizo​​ntal)
(split-window-vertical)
(other-windows 1)


I would like to be able to specify the window layout of the Emacs when starting it from commandline.

More specifically, I invoke "emacs file1 file2 file3 file4" and would, for example, like see

+---------+                             +--------+
|  file1  |                             |  buff  |
|         |                             |  list  |
+---------+    instead of the default   +--------+  that I see currently
|         |                             |        |
|  file3  |                             |  file4 |
+---------+                             +--------+

My emacs is GNU Emacs 24.0.91.1, and I do not use emacsclient.

Note, I do not want to make the change permanent. That is why I ask for command-line solution.

解决方案

Put the following in 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)

Then

emacs blah foo bar --load layout.el

The only thing you have to do is customizing the layout the way you want using a combination of the following functions:

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

这篇关于在命令行中指定emacs中的窗口布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆