开发者

why does set-default-font affect find-file-other-window?

开发者_如何学运维

I recently added the line

(set-default-font "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1")

to my .emacs file. After that find-file-other-window always opens a new window instead of utilizing existing windows. Why would that happen!? How can I fix it?

I don't understand how all this font-config magic works, so if it's actually obvious I'm sorry.

Edit: I have a pretty large resolution, and my font size has decreased pretty significantly. Does find-file-other-window take into account available character space? Perhaps it's deciding there's sooo much room it can afford to just open windows willy nilly.


find-file-other-window ultimately calls display-buffer, which runs a complex algorithm to decide whether to reuse an existing window or make one and how. In particular, if display-buffer decides it needs to create or recycle a window, it tries calling split-window-preferred-function to split the biggest window. By default, split-window-preferred-function is split-window-sensibly, which is willing to split windows vertically if they are more than split-height-threshold lines high, or failing that horizontally if they are more than split-width-threshold columns wide.

It looks like you want

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

N.B. This answer applies to GNU Emacs 23. Earlier versions didn't have horizontal splitting. Later versions may do things differently.


A few ways to find this out (none straightforward):

  • If you guess that what's going on is called splitting a window: M-x apropos RET split RET shows a number of variables and functions, and you might figure out which ones are relevant. Or if you guess that there's an option (there often is), C-h v split- TAB shows promising leads.
  • The documentation for find-file-other-window references Displaying Buffers. (You have to go to the Elisp manual for this level of detail; within Emacs, C-h i m elisp RET brings up the Elisp manual, and i find-file-other-window RET leads you to the documentation for this function.) It's less clear that pop-to-buffer is the passage to read there; it references Choosing Window which contains the sought after information.
  • C-h f find-file-other-window RET shows the built-in documentation for the function. It links to display-buffer. The description of display-buffer doesn't describe its operation in detail, so from there you need to either consult the Elisp manual as above or explore the source of display-buffer by clicking on window.el.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜