Certain emacs function splits the current frame, for example magit-status or compile (probably there are dozens). How emacs decides whether to do a vertical split or a horizontal one?
My experiments suggests that if the frame's width is larger then 162 chars then it dose a vertical split, and otherwise a horizontal one. Is it the right value? More important, where is this value stored, how can I change this threshold?
split-width-threshold:
Minimum width for splitting windows sensibly. Hide If this is an
integer, split-window-sensibly may split a window horizontally only
if it has at least this many columns. If this is nil,
split-window-sensibly is not allowed to split a window horizontally.
Standard value is 160 here, looks pretty close to what you've found.
Related
I would like to have a text box rescale with the level of magnification, such that one unit of text is always assigned one unit of horizontal axis-length. The text width should not change but rather the spacing between characters.
For instance, if the x-axis displayed [0:50], fifty characters should be displayed, one at each integer position. If the magnification was increased such that the display comprised only [0:10], only ten characters would be displayed, again placing one character at each integer position along the horizontal axis.
Finally, the text would ideally not display when the magnification level was below some threshold determined by the number of characters that can be legibly printed along a horizontal line spanning the extent of the axes.
I have tried using the text object, but it doesn't seem to have the relevant properties to allow such dynamic behavior. I have instead considered breaking the N-length string into N unit-length strings and placing each at a defined x-position, but I'm having trouble figuring out how to display only those relevant at the prevailing zoom level (there is some spill-over of characters beyond the bounds of the axis). In contrast, with this approach, all the characters appear as a jumble at zoom levels so low that the number of characters printed cannot be reasonably accommodated.
Thus, I inquire whether another solution besides printing a series of unit-length strings might be advised and, if not, how the twin problems of text spill-over and text overlap can be resolved at high and low zoom, respectively (the first might be done by somehow preventing printing of information outside the axes; the second seems to require some dynamic magnification-aware means of suppressing text output at or above a certain x-axis extent).
The way I understand how emacs displays stuff is that essentially everything is text. If you have something in the fringe or linum mode active, essentially your document is pushed a little inwards and something is written in the first few columns.
I'm writing a function for putting some stuff into the head-line and this works nicely, however, I would like the start of the text to be aligned with the start of the document.
Thus I am looking for a way to get the number of columns that sit between the frame border and the start of the actual document.
Let me illustrate using a poorly produced graphic:
I want to get the number of columns (or the number of pixels) that make up the distance marker by the ruler just below the line number 10000.
The function which returns this value shall be executed in the functions which create the head-line.
There is a function called window-inside-edges that you can use to determine the offset of the text area ("window body") from the total width and height of the window in columns and lines, respectively.
It returns a list four values; the order is left - top - right - bottom, so to get the value you are interested in for the current window, just do
(car (window-inside-edges))
More information on window coordinates can be found here; this page has information about window sizes, including a nice ASCII representation of window elements.
How to automatically set optimal frame width of Emacs?
When open a file with Emacs from command line, how to let it automatically set the frame size such that
width is 2 characters wider than the widest row or the computer screen width, which ever is smaller
height is 80 rows, or the computer screen height, which ever is smaller?
You can use a find-file-hook which sets your frame's size. You'll need things like display-width and display-height, and you'll need to loop through the whole file computing the width of each line (using forward-line to move to the next line, end-of-line to go the end of the line and current-column to find the width). And you'll probably need to fiddle with off-by-one details in order to account for things like the menu-bar, the fringes, ...
Me? I prefer to declare that files should not go over 80 columns so I don't need to adjust the frame width.
This is just what libraries fit-frame.el and autofit-frame.el are for. See also http://www.emacswiki.org/FrameSize.
I don't know if this can easily be done with Emacs (read below for my hack in case there's no easy way to do this) so...
How can I add one pixel of vertical-spacing between each line under Emacs?
I know that screen real estate is precious but I'm using a "custom" font (ProggyFont) and, under IntelliJ IDEA, I can modify the vertical spacing to something that I like.
Under Emacs, however, I find the text hard to read because the pixels from one line are too close from the pixel of another line, so I'd like to add one "one pixel" empty vertical line between every line. Can this be done simply?
If there's no "simple way", how do I take a "x by y" bitmap font and turn it into a "x by (y+1)" bitmap font? I don't mind using a font editor: been there, done that. But I don't know exactly everything that would be involved.
Check out the line-spacing variable, e.g.
(setq line-spacing 0.2)
From the docs:
Additional space to put between lines when displaying a buffer.
The space is measured in pixels, and put below lines on window systems.
If value is a floating point number, it specifies the spacing relative
to the default frame line height. A value of nil means add no extra space.
I have a few scripts that use the function pop-to-buffer a lot. It used to split the window horizontally, but now in Emacs 23 it splits the window vertically. I've dug through some of the elisp code but it's not jumping out at me - how can I change this behavior of Emacs 23 to split horizontally again?
It's listed in the NEWS for Emacs (C-h N):
*** display-buffer' tries to be smarter when splitting windows. The
new option
split-window-preferred-function' lets
you specify your own function to pop
up new windows. Its default value
split-window-sensibly' can split a
window either vertically or
horizontally, whichever seems more
suitable in the current configuration.
You can tune the behavior of
split-window-sensibly by customizing
split-height-threshold' and the new
option `split-width-threshold'. Both
options now take the value nil to
inhibit splitting in one direction.
Setting split-width-threshold to nil
inhibits horizontal splitting and gets
you the behavior of Emacs 22 in this
respect. In any case, display-buffer
may now split the largest window
vertically even when it is not as wide
as the containing frame.
I think what you want is:
(setq split-width-threshold nil)
(but I think you're using the vertical versus horizontal splitting the opposite of what Emacs terminology is (which is counterintuitive to me as well))