【问题标题】:Open emacs with a horizontal split使用水平拆分打开 emacs
【发布时间】:2013-10-04 16:16:11
【问题描述】:

使用两个文件$ emacs a.txt b.txt 打开 emacs 时,窗口会垂直拆分。

我需要进行水平拆分。是否有一个变量可以控制这种行为,或者是否有一个钩子可以让我在不改变其他行为的情况下覆盖一个行为?

我查看过 StackOverflow 上的相关问题,但它们的侧重点不同,而且它们的答案并不直接适用:

我想找到打开 emacs 时运行的特定代码,并将调用更改为 (split-window-vertically)。

以防万一,我使用的是 GNU Emacs 24.3.1。

【问题讨论】:

    标签: emacs elisp dot-emacs


    【解决方案1】:

    从命令行打开文件的具体代码在startup.el。该函数是command-line-1,它调用find-file-other-window(在两个不同的地方)。

    你应该可以在你的 .emacs 中做这样的事情,但我不确定细节:

    (defadvice find-file-other-window (before split (file &optional wildcards))
      (if <during command line processing>
          (split-window-horizontally)))
    (ad-activate 'find-file-other-window)
    

    【讨论】:

      【解决方案2】:
      emacs -Q a.txt -eval "(split-window-horizontally)" -eval "(find-file \"b.txt\")"
      

      也可以设置一些字体,例如 Liberation Mono-18:

      emacs -Q a.txt -eval "(split-window-horizontally)" -eval "(find-file \"b.txt\")" --font 'Liberation Mono-18'
      

      如果没有选项 -Q 也加载你的初始化文件。

      好吧,为了完整起见,当已经在一个文件中时:C-x 3

      【讨论】:

        【解决方案3】:

        可以选择transpose 垂直/水平分割。非常方便和有趣。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-03-24
          • 1970-01-01
          • 1970-01-01
          • 2015-09-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多