[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: fit-frame every time i open a file

From: Drew Adams
Subject: RE: fit-frame every time i open a file
Date: Mon, 15 Oct 2007 13:54:16 -0700

> > After you load the *.el files with `load-file', do this
> > (mentioned in the file Commentary):
> >
> > M-: (add-hook 'after-make-frame-functions 'fit-frame)

> I added the hook manually (I honestly didn't know about
> M-: because I'm not a LISP programmer, though it's on my list)

`M-:' means hold the Meta key (probably the Alt key) pressed while you hit
`:'. It is bound to command `pp-eval-expression', which lets you type a Lisp
expression to evaluate.

> and the effect was this: any file I opened came up in a
> frame exactly the same dimensions as the current frame
> (which, as it happens, had been fit-framed). The dimensions
> of the new frames are now irrespective of the frame best fit
> (i.e., if I manually call fit-frame, the frame resizes).

> However, if I resize the current window by dragging its corner
> (Aquamacs lets you do that), then the files I subsequently
> open still have the same dimensions that the current window
> originally had. In other words, width/height seem to have been
> frozen when I added the hook, somehow.

It sounds like either `fit-frame' was not called, it was called but didn't
do anything, or it did something that was undone afterward.

> Taking a look at the variable in question, I get this:
> (fit-frame set-mode-style-after-make-frame)
> A quick grep showed that the second call has nothing to
> do with either of your two libraries. I don't know how to
> look it up inside emacs to see where it comes from. :(

FYI - You can use `C-h f' to describe any function. The *Help* buffer
showing the description usually tells you what file it is defined in and
provides a link to its definition.

> > M-: (setq after-make-frame-functions nil)
> > M-: (add-hook 'after-make-frame-functions 'fit-frame)

> OK.

> Now again nothing happens when I open new files.
> They seem to open with the default width/height and are
> resized to best fit when I call fit-frame manually.

If `after-make-frame-functions' has value (fit-frame), then `fit-frame'
should be called. You can do this to see if it is called:

M-x debug-on-entry RET fit-frame RET

You can cancel such debugging this way: M-x cancel-debug-on-entry RET

If `fit-frame' is not being called, then you'll need to get some help from
an Aquamacs user. It sounds to me like it is not getting called, because
when you call it by hand it apparently works correctly. Make sure you
spelled everything correctly.

C-h v after-make-frame-functions should show this: (fit-frame)

If `fit-frame' is getting called (as shown by entering the debugger), then
you need to figure out why it doesn't fit the frame. Read the doc string of
`fit-frame' to understand it, including the conditions under which it does
nothing. It's possible that the values of the fit-frame user options (e.g.
`fit-frame-inhibit-fitting-flag') are preventing resizing.

Again, however, I doubt that it is getting called at all, since calling it
manually does resize the frame correctly.

> > The above procedure is just to try to see if `fit-frame'
> > does the right thing at least when there are no other
> > `after-make-frame-functions' present. If it does, then
> > there is likely interference among those functions.
> > In that case, you can try (starting with an empty list)
> > adding them all back, in different orders (e.g. try
> > `fit-frame' first or last), to see if that helps.
> > You get the idea.

> Thank you, I do, but since the test failed, I don't see
> the point in reversing the order of the only 2 functions
> that were hooked...

Do you see "If it does" and "In that case" in what I wrote? From what you
wrote, it does not: `after-make-frame-functions' = (fit-frame) does not
solve the problem. So the presence of `set-mode-style-after-make-frame' is
not the problem.

> I read everything you write carefully. I know (empirically)
> what fit-frame does and what it doesn't do, and we're not
> having a case of enforced line width limits (besides, those
> are accessible as configuration parameters within Aquamacs --
> one of the reasons I thought fit-frame would be better integrated).

Yes, and you said that it correctly resizes the frame when you call it
manually. I suspect it is not being called, but I can't say why. I also
don't know what you meant by it resizing OK with short lines, but not when
there are long lines. If it works with short lines, then it would seem to be
getting called as an after-make-frame function. Does it resize correctly
with long-lines if you call it manually? Something doesn't make sense to me
in your description.

> Given this new information, is there anything else I could try?

See above.

If `fit-frame' is called, you can also try stepping through it in the
debugger (`d') to see what it is doing. Why it might do something wrong when
called in a hook and when called manually is unclear. I doubt that that is
what's happening - I suspect that it is not called from the hook.

> The problem started off pretty simple, but now seems to be
> getting hairier... Aquamacs support is rather scarce, and I'm
> surprised to discover that nobody from their team is on this
> list also. Thank you for your support so far,

I think that there are Aquamacs people who read this list. They might not be
willing or able to help.

The things you need to determine for sure are these:

1. Whether `fit-frame' gets called as an after-make-frame function.
2. Exactly what changes if you have short or long lines.

If `fit-frame' is not called by the hook, then I cannot help you. If it is
called but it doesn't DTRT, then I can try to help.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]