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.
Related
I have an UI element that has a Text and an Image as its children. It has a HorizontalLayoutGroup component that enables Control Child Size and Child Force Expand.
I want the Image has a fixed size, and Text has strechable size controlled by the HorizontalLayoutGroup. So when the Image is set to inactive, the Text fills the whole space and when the Image is active, the Text shrinks a little bit in order to give space to the Image. Right now this part works good.
My second goal is to align them to both ends: the Text in the left and the Image on the right with space in between. But changing Child Alignment can't achieve this.
I tried the following solution:
Add LayoutElement both to Image and Text. On Text, enable Flexible Width and set a a value, on Image, enable Min Width and set to a value. Manually adjust the two values until it seems right.
This solution seems to work, but I don't know why. Is anyone familiar with this?What's the recommended way to do it? Thanks!
I worked it out. On the LayoutElement, treat Preferred Width or Preferred Height as Max Width or Max Height. Enable them, set the value the same with min value. One the other objects that you want to stretch, enable Flexible values. Then all worked as we want.
The text in my WKInterfaceLabel is way too long and causes the text to be cut off with dots at the end. I know for UILabel for iOS you can easily resolve this issue by enabling clip mode. I don't believe there is any way for me to resolve this for watchkit. This is going to force me to use an Image if I can't prevent the text from being cut off. Any tips or suggestions is appreciated.
You have a couple options depending on how you want the view to respond. In your interface story board select your label and open the attributes inspector.
Your first option is to change the font to a smaller size. This is more for a static label that you want to style and leave set.
Your second option is to adjust the min scale value, changing this will automatically shrink the text to fit the window up to the value provided. For example if your font size is 12pt and you set the scale to .5, the font will shrink up to 6pt before appending the ellipsis (...).
Your third option is to set the number of lines to 0 (or a higher number). This will move the text down onto the next line.
Set the number of lines to 0 and ensure the label and any containing groups are set to fit content.
if you want your font size adjust according to label size follow this method
in WKInterfaceTable attribute inspector set min scale to 0
like in screen shoot
Result before Min scale = 0
Result after Min scale = 0
Note: your no of lines also set to 1
I am facing a strange problem. After I change the KDE window rules for emacs according to http://www.emacswiki.org/emacs/KdeMaximized, that is, I created a special window setting:
the size of echoarea (the area shared with minibuffer) is doubled by default whenever the font size is larger than 115 (1/10 pt):
,
while normally it should be like this:
Moreover, this only occurs when emacsclient is maximized and without menubar (it is fine when fullscreened or not maximized or with menubar). Maybe it is just a problem with KDE? But I couldn't find other way to fully maximize KDE without creating special window settings.
Surely a workaround is to set font size to be at most 115, but that looks too small on my 13.3 ultrabook and I usually set it to 125.
So I am just wondering if there is a way to resize the EchoArea (or change the font size of EchoArea.) by emacs settings? I tried adjusting the font size of the minibuffer, but it does not work since only the minibuffer font is changed while the Echoarea is not affected.
I am using emacs 24.3.
Thanks!
Explanation
Emacs cannot fully use arbitrary screen sizes because it (for the most part) displays a grid of characters.
As a simple example, consider characters that are each 10 by 10 pixels, and screen real estate of 1024 by 768. You'll have four pixels of width and eight pixels of height that cannot be used by Emacs.
The article you linked to is about forcing Emacs into a particular screen size. From the page:
Once you try to maximize the window, emacs resizes itself to a slightly smaller portion of the screen. This is because emacs rejects the geometry given to it by KWin, because it’s not an integral multiple of the width/height of one character.
When you tell KDE to force a particular size, the Emacs frame ("window" in non-Emacs terminology) will be the size you want, but the windows inside it ("splits" in non-Emacs terminology) may not fit properly. This usually leads to "wasted space" at the bottom of the screen like you are seeing.
As you noticed, changing your font size can give different results. If your character width is 8 pixels, for instance, you won't have any wasted horizontal space since 1024 divides by 8 evenly (128 times).
Similarly, going fullscreen and enabling the menubar both alter the amount of vertical space that Emacs has available for its windows.
Workaround
One workaround might be to adjust the size of your KDE taskbar. I believe it can be adjusted with single pixel granularity. If you adjust it smaller by a few pixels one at a time you should find a small adjustment that will make Emacs use its space more efficiently.
A you suggested, you might try to alter the font size of the minibuffer:
(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup)
(defun my-minibuffer-setup ()
(set (make-local-variable 'face-remapping-alist)
'((default :height 0.9))))
(via Altering the font size for the Emacs minibuffer separately from default emacs?)
This will make the font size just a bit smaller. Try playing with the height and see if it can resolve the issue...
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.
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.