【问题标题】:How to split windows horizontally in emacs when executing current buffer?执行当前缓冲区时如何在emacs中水平拆分窗口?
【发布时间】:2012-12-16 13:56:46
【问题描述】:

我正在使用 Emacs 在 python 中编码。我已经修改了“.emacs”以满足我的需要。但是,我不知道在执行当前缓冲区时如何更改窗口的默认垂直拆分行为。

我知道:

(setq split-height-threshold nil) 
(setq split-width-threshold 0) 

一般都有效。但是当我第一次使用C-c C-c执行缓冲区时它不起作用

尽管在我的 ~/.emacs 中有上述代码,但在 C-c C-c 上会发生以下情况:

希望我的问题很清楚,如果您对此有任何想法,请告诉我。

【问题讨论】:

  • 有趣的是,当我的 emacs 框架比它高时,Emacs 默认会并排打开窗口...
  • 我现在正在做C-x 3,但我确信一定有办法让它在 Emacs 中默认为 Python-IDE
  • @lukstafi ...这不是我观察到的。

标签: emacs split elisp


【解决方案1】:

我使用以下内容。它解决了您的问题(我希望如此),并从一开始就阻止 Emacs 拆分窗口。

;;; ------------------------------------------------------------------
;;; display-buffer

;; The default behaviour of `display-buffer' is to always create a new
;; window. As I normally use a large display sporting a number of
;; side-by-side windows, this is a bit obnoxious.
;;
;; The code below will make Emacs reuse existing windows, with the
;; exception that if have a single window open in a large display, it
;; will be split horisontally.

(setq pop-up-windows nil)

(defun my-display-buffer-function (buf not-this-window)
  (if (and (not pop-up-frames)
           (one-window-p)
           (or not-this-window
               (not (eq (window-buffer (selected-window)) buf)))
           (> (frame-width) 162))
      (split-window-horizontally))
  ;; Note: Some modules sets `pop-up-windows' to t before calling
  ;; `display-buffer' -- Why, oh, why!
  (let ((display-buffer-function nil)
        (pop-up-windows nil))
    (display-buffer buf not-this-window)))

(setq display-buffer-function 'my-display-buffer-function)

【讨论】:

  • 我试过了,没用。我认为这可能是因为我使用一些 dot-el 文件打开了其他一些设置。
  • 你的框架宽度小于162吗?因为那是上面 sn-p 中的硬编码值。
  • 无论窗口大小如何,它都不会水平分割。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多