<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">David,</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">I've traded some email with Drew Adams about my problems with fit-frame in Aquamacs.  The thread is appended.  At this point, I think it's best to ask you for some help.</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><span class="Apple-style-span" style="font-size: medium;"><br></span></span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">On October 21, 2009 4:32:49 PM MDT <</span></font><a href="mailto:siemsen@ucar.edu"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">siemsen@ucar.edu</span></font></a><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">> <</span></font><a href="mailto:siemsen@ucar.edu"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">siemsen@ucar.edu</span></font></a><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">> wrote:</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font><blockquote type="cite"><blockquote type="cite"><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">I'm using Aquamacs "2.0preview2".<br><br>When I open a file, I'd like the frame to automatically resize to fit the text, as much as possible.  I found fit-frame on the web, which seems exactly what I want.  I discovered that it's distributed with Aquamacs.  When I did M-x fit-frame, it resized the frame.  Very cool!<br><br>Trouble is, it makes the frame wider than needed.  I think this is because I've customized Aquamacs to use a default font height of "120", while fit-frame uses the height attribute of the "default" face, which is 130.  In other words, in my customizations.el file I have<br><br>(custom-set-faces<br> '(autoface-default ((((type ns)) (:inherit default :height 120 :family "Monaco" :background "#02053c"))))<br><br>...but when I evaluate (face-attribute `default :height) I get 130.  I think fit-frame is using 130, hence my frames are resized too large.  Admittedly, I'm guessing a bit here.<br><br>To try to fix it, I put this in my Preferences.el:<br><br>(set-face-attribute `default nil :height 120)<br><br>It didn't work.  It doesn't set the value used by fit-frame.  Instead, it seems to set the height of the font of the current frame, not of the height of the default face.<br><br>Am I in the right ballpark?<br></span></font></div></blockquote></blockquote><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><div><br></div><br></span></font><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">On October 21, 2009 4:59:59 PM MDT, David Reitter wrote:</span></font></div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font><blockquote type="cite"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Yes you are.  Emacs calculates dimensions and coordinates based on the frame font because you're setting the "frame size".  You can change the fit-frame function to be smarter - it should be pretty easy.  Convert to pixels based on the default face, then convert back to frame chars.<br>But even so: the "width" of the default face is just an approximation, because the default face may well be a variable-width font.<br><br>If you do improve fit-frame, please post the new code.  (You can check if Drew Adams has an updated version.)<br></span></font></blockquote><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">I asked for Drew Adams for help.  Here's the relevant bits ( I've tried to put them into a sensible order):</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><br></div><div><p style="margin: 0.0px 0.0px 1.0px 92.0px; text-indent: -92.0px; font: 18.0px Helvetica"><font class="Apple-style-span" face="'Times New Roman'">On October 21, 2009 12:10:05 PM MDT, Pete Siemsen wrote:</font></p></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><blockquote type="cite"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Drew,<br><br>I'm a brand new user of fit-frame.  Very cool, and I'm definitely going to explore your other stuff.  I have this problem:  I use Aquamacs, and I set the font size with this call in my "customizations.el" startup file:<br><br>'(autoface-default ((((type ns)) (:inherit default :height 120 :family "Monaco" :background "#02053c"))))<br><br>Fit-frame works, but miscalculates the frame size because it thinks the font size is something other than the one I'm using.  How can I make fit-frame base its calculations on the "Monaco 12" that I use?<br><br>-- Pete</span></font></blockquote></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><br></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">On October 21, 2009 12:25:07 PM MDT, Drew Adams wrote:</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div></div><blockquote type="cite"><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">I never heard of `autoface-default'. I don't know much about Aquamacs - perhaps that's an Aquamaces thing? I searched for `autoface-default' throughout the vanilla Emacs libraries - no hits. Googling for it suggests that it's an Aquamacs thing. You should perhaps ask the Aquamacs folks about this.<br><br>What I would use is just the `default' face. You can customize that. The `font' attribute of face `default' corresponds to frame parameter `font'. And it corresponds to what is returned by functions `frame-char-height' and `frame-char-width', which is what fit-frame.el uses.<br><br>You can also use various commands to change the current font or font size.<br><br>HTH - Drew</span></font></div></blockquote><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><br></div><p style="margin: 0.0px 0.0px 1.0px 92.0px; text-indent: -92.0px; font: 18.0px Helvetica"><font class="Apple-style-span" face="'Times New Roman'">On October 22, 2009 3:38:35 PM MDT, Pete Siemsen wrote:</font></p><p style="margin: 0.0px 0.0px 1.0px 92.0px; text-indent: -92.0px; font: 18.0px Helvetica"><div><div><font class="Apple-style-span" face="'Times New Roman'"><br></font></div><div></div></div></p><div></div><blockquote type="cite"><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Yes, it's an Aquamacs thing.  It was added to allow per-mode fonts.  It works well.</span></font></div></blockquote><blockquote type="cite"><div></div></blockquote><br><blockquote type="cite"><div><span class="Apple-style-span" style="font-size: 18px; ">I tried doing this in my startup file:</span></div><div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">(set-face-attribute `default nil :height 120)</span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">...but it didn't affect fit-frame's behavior.  I confess to some confusion.  I can't do C-h v frame-char-width - Aquamacs doesn't know the variable.  Yet fit-frame works, sorta.</span></font></div></div></div></blockquote><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><br></div><div><p style="margin: 0.0px 0.0px 1.0px 82.0px; text-indent: -82.0px; font: 18.0px Helvetica"><font class="Apple-style-span" face="'Times New Roman'">On October 22, 2009 4:20:41 PM MDT, Drew Adams wrote:</font></p><p style="margin: 0.0px 0.0px 1.0px 82.0px; text-indent: -82.0px; font: 18.0px Helvetica"><font class="Apple-style-span" face="'Times New Roman'"><br></font></p></div><div dir="ltr"></div><blockquote type="cite"><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Use M-: (face-attribute 'default :height) to see if the setting actually took effect.</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Do also M-: (frame-char-height). It should show the same height that you just set. If it does, then fit-frame should work, because it uses that function.</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">If, for some reason, set-face-attribute didn't work, try instead `M-x customize-face default'. In the Customize buffer, change the Height value to the height you want (use Height in 1/10 pt from the Value Menu). Open a new Emacs session and see if that customization worked.</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">This works for me, on Windows (with normal Emacs 23.1.1, not with Aquamacs). If I use `set-face-attribute' as you did, then `frame-char-height' reflects that, and fit-frame works.</span></font></font></span></div></blockquote><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><br></div><div dir="ltr"><span class="943084721-22102009"><div dir="ltr"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><span class="Apple-style-span" style="font-size: medium;">On October 22, 2009 3:38:35 PM MDT, Pete Siemsen wrote:</span></span></font></div><div dir="ltr"><br></div></span></div><div dir="ltr"><blockquote type="cite"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">David Reitter, the author of Aquamacs, has suggested that I might "fix" fit-frame to make it work better.  I doubt that there's a problem in fit-frame.  I am sure that my Lisp skills are insufficient to "fix" it :-)</span></font></blockquote></div><div><div><div><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></div><div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">On October 22, 2009 4:20:41 PM MDT, Drew Adams wrote:</span></font></font></span></div><div dir="ltr"><font class="Apple-style-span" color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><br></span></font></font></div><div dir="ltr"></div><blockquote type="cite"><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">To fix it, we need to first find out what the problem is. David should be able to help you with that, as there seems to be some interaction with Aquamacs changes to Emacs. I cannot reproduce the problem (without Aquamacs).</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">I will help if I can from my end, but I'll need to know more about what's happening in your case, and why. Either you or David will need to debug this a bit, to see where the problem is.</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">The first thing to see is what the value of (frame-char-height) is. That is what fit-frame uses. If it is correct (same as what you set using set-face-attribute), then we can try to see why fit-frame didn't do the right thing. If it is not correct (different from the value you set), then I'd suggest that it's an Aquamacs problem. AFAIK, set-face-attribute for the `default' face should always be reflected in `frame-char-height' (and -width). The `default' face is just shorthand for a certain number of frame parameters (or vice versa).</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Let me know what you can find out. Sorry for your trouble.</span></font></font></span></div><div dir="ltr"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"><font color="#000080"></font></span></font></span><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;"> </span></font></div><div dir="ltr"><span class="943084721-22102009"><font color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px;">Thx - Drew</span></font></font></span></div></blockquote><div><br></div><div><br></div><div dir="ltr"><span class="943084721-22102009"><div dir="ltr"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; ">On October 22, 2009 3:38:35 PM MDT, Pete Siemsen wrote:</span></font></div><div dir="ltr"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; "><br></span></font></div><div dir="ltr"></div><blockquote type="cite"><div dir="ltr"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; ">Perhaps this is due to Aquamacs' incomplete implementation of your libraries.  Aquamacs comes with these:</span></font></div><div dir="ltr"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; "><br></span></font></div><div dir="ltr"><div><font class="Apple-style-span" face="Courier" size="4"><span class="Apple-style-span" style="font-size: 14px;">autofit-frame.el frame+.el        icomplete+.el    strings.el       upd2</span></font></div><div><font class="Apple-style-span" face="Courier" size="4"><span class="Apple-style-span" style="font-size: 14px;">files+.el        frame-cmds.el    misc-fns.el      thingatpt+.el</span></font></div><div><font class="Apple-style-span" face="Courier" size="4"><span class="Apple-style-span" style="font-size: 14px;">fit-frame.el     frame-fns.el     oneonone.el      upd</span></font></div></div></blockquote><div dir="ltr"><div><br></div></div></span></div><div dir="ltr"><font class="Apple-style-span" color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; ">On October 22, 2009 4:20:41 PM MDT, Drew Adams wrote:</span></font></font></div><div dir="ltr"><font class="Apple-style-span" color="#000080"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; "><br></span></font></font></div><div dir="ltr"><blockquote type="cite"><font class="Apple-style-span" color="#000080"><span class="943084721-22102009"><font class="Apple-style-span" size="5"><span class="Apple-style-span" style="font-size: 18px; ">No; for fit-frame.el to work, you do not need any other libraries at all.</span></font></span></font></blockquote><div dir="ltr"><br></div><div dir="ltr"><br></div>David, that's the thread.  When I use set-face-attribute to change the height of the default font, my frames resize, but to a size that is too small vertically and too wide horizontally.</div><div dir="ltr"><br></div><div dir="ltr">It seems like things almost work, but I don't understand the missing piece.  What I want is: when I open a "thin" file, containing, like, a column of numbers, I'd like the frame to appear sized just wide enough to contain the numbers.  Similarly, when I open a file that contains only 10 lines, I'd like the frame to be large enough vertically to show the 10 lines, and no more.  If a file is too big for its frame to fit horizontally or vertically on the screen, I'd like the initial frame to be some maximum number of lines or columns.  If I add content to such a buffer, scroll bars should appear, and I can then evaluate fit-frame again to make the frames use the right amount of real estate.  It seems that fit-frame can do all this.</div><div dir="ltr"><br></div><div dir="ltr">I realize fit-frame won't work well with proportional fonts, but I don't use proportional fonts.</div><div dir="ltr"><br></div><div dir="ltr">Thanks again for Aquamacs, it's fantastic!</div><div dir="ltr"><br></div><div dir="ltr">- Pete</div><div dir="ltr"><br></div></div></div></div></body></html>