all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* fit-frame every time i open a file
@ 2007-10-15 13:07 alxx
  2007-10-15 15:45 ` Drew Adams
  0 siblings, 1 reply; 14+ messages in thread
From: alxx @ 2007-10-15 13:07 UTC (permalink / raw)
  To: Help-gnu-emacs


Hello,

I'm been using emacs (well, Aquamacs for the past year) but I'm still on a
beginner's level. I've went through some of the available tutorials and I'm
also a computer programmer, so I should at least pretend to understand emacs
better :)

Here's my question. I've been getting tired of manually calling fit-frame
everytime I open a file with long lines (I have a wide-screen iMac so soft
wrapping doesn't make much sense), and I would like to know if there's any
easy way to tell emacs to call fit-frame everytime it opens a file.

I tried to hook fit-frame to some of the hooks (specifically,
after-make-frame) but it didn't seem to do much (at least in Aquamacs).
Since I've noticed that Aquamacs sets the mark after each file opening, I
tried to hook fit-frame to activate-mark-hook and that did the trick, except
-- you guessed it -- my window is all over the screen everytime I select
anything.

Does anyone know what the correct hook would be to make fit-frame run each
time I open a file? Or what's the correct way to do this?

Thank you!
-- 
View this message in context: http://www.nabble.com/fit-frame-every-time-i-open-a-file-tf4627339.html#a13212438
Sent from the Emacs - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 13:07 fit-frame every time i open a file alxx
@ 2007-10-15 15:45 ` Drew Adams
  2007-10-15 16:13   ` alxx
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2007-10-15 15:45 UTC (permalink / raw)
  To: alxx, Help-gnu-emacs

> I've been getting tired of manually calling fit-frame
> everytime I open a file with long lines (I have a wide-screen iMac so soft
> wrapping doesn't make much sense), and I would like to know if there's any
> easy way to tell emacs to call fit-frame everytime it opens a file.
>
> I tried to hook fit-frame to some of the hooks (specifically,
> after-make-frame) but it didn't seem to do much (at least in Aquamacs).
> Since I've noticed that Aquamacs sets the mark after each file opening, I
> tried to hook fit-frame to activate-mark-hook and that did the
> trick, except -- you guessed it -- my window is all over the screen
> everytime I select anything.
>
> Does anyone know what the correct hook would be to make fit-frame run each
> time I open a file? Or what's the correct way to do this?

Yes, see
http://www.emacswiki.org/cgi-bin/wiki/Shrink-Wrapping_Frames#AutoFitFrames.

You need libraries `fit-frame.el' and `autofit-frame.el' (which might be
included in Aquamacs), and you'll want to do this:

  (add-hook 'after-make-frame-functions 'fit-frame)

If you don't have the libraries, they are here:

http://www.emacswiki.org/cgi-bin/emacs/fit-frame.el

http://www.emacswiki.org/cgi-bin/emacs/autofit-frame.el

However, you say that you have already tried `after-make-frame-hook'. Try
again, with the above versions of the files. And perhaps someone who uses
Aquamacs can speak to the Aquamacs problems you encountered.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 15:45 ` Drew Adams
@ 2007-10-15 16:13   ` alxx
  2007-10-15 17:02     ` Drew Adams
  2007-10-15 17:44     ` Peter Dyballa
  0 siblings, 2 replies; 14+ messages in thread
From: alxx @ 2007-10-15 16:13 UTC (permalink / raw)
  To: Help-gnu-emacs


Thanks, but been there, done that. I admit I didn't try again with the new
libraries, because I'm not sure where they should be replaced :"> (yes, I
could try to find the files on disk).

However, aren't I correct in assuming that the libraries (albeit not
necessarily the latest versions) are already in Aquamacs, since I can call
fit-frame manually and it works? Moreover, I can successfully associate it
to some other hooks and that works too. The only thing that doesn't work is
hooking fit-frame to after-make-frame-functions in particular. This yields
no visible results.


Drew Adams wrote:
> 
> Yes, see
> http://www.emacswiki.org/cgi-bin/wiki/Shrink-Wrapping_Frames#AutoFitFrames.
> 
> [...]
> 
> However, you say that you have already tried `after-make-frame-hook'. Try
> again, with the above versions of the files. And perhaps someone who uses
> Aquamacs can speak to the Aquamacs problems you encountered.
> 

-- 
View this message in context: http://www.nabble.com/fit-frame-every-time-i-open-a-file-tf4627339.html#a13216190
Sent from the Emacs - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 16:13   ` alxx
@ 2007-10-15 17:02     ` Drew Adams
  2007-10-15 17:44     ` Peter Dyballa
  1 sibling, 0 replies; 14+ messages in thread
From: Drew Adams @ 2007-10-15 17:02 UTC (permalink / raw)
  To: alxx, Help-gnu-emacs

> Thanks, but been there, done that. I admit I didn't try again with the new
> libraries, because I'm not sure where they should be replaced :"> (yes, I
> could try to find the files on disk).

You need not replace anything, just to try a library - just load it. If it
happens to help, then you can worry about how to replace what you have.

> However, aren't I correct in assuming that the libraries (albeit not
> necessarily the latest versions) are already in Aquamacs, since I can call
> fit-frame manually and it works?

I have no idea what is in Aquamacs. I don't use Aquamacs, I don't have
access to an Apple machine, and I wasn't involved in adding my code to
Aquamacs.

If I had to guess, I'd guess that Aquamacs does something different with
these libraries and `after-make-frame-functions'. But that's just a guess
from ignorance.

> Moreover, I can successfully associate it to some other hooks and
> that works too. The only thing that doesn't work is
> hooking fit-frame to after-make-frame-functions in particular.
> This yields no visible results.

I'm afraid I can't help you then. It works fine on other platforms. Perhaps
Aquamacs does something special in this regard. Perhaps someone who is
familiar with Aquamacs has a suggestion.

Perhaps it has to do with the order of the functions in
`after-make-frame-functions'. You might try changing the order or testing
without any other functions in that hook, besides `fit-frame'.

Perhaps it has to do with how Aquamacs and Apple create frames, and how that
process interacts with `after-make-frame-functions'. Dunno.

Did you say that it doesn't work only on files with long lines? Perhaps
`fit-frame' is in fact being called, but it doesn't do what you expect.
`fit-frame' does not fill or change your text in any way. The new frame
width is based on the longest line in your buffer, so if you have long
lines, then you'll have a wide frame. You can, however, control the maximum
width in various ways (variables) - see the Commentary in fit-frame.el.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
  2007-10-15 16:13   ` alxx
  2007-10-15 17:02     ` Drew Adams
@ 2007-10-15 17:44     ` Peter Dyballa
  2007-10-15 18:15       ` Drew Adams
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Dyballa @ 2007-10-15 17:44 UTC (permalink / raw)
  To: alxx; +Cc: Help-gnu-emacs


Am 15.10.2007 um 18:13 schrieb alxx:

> I'm not sure where they should be replaced

Look at load-path. It will have among the first few elements  
directories that belong to your home directory. Put the files there,  
so they're found before those inside the Mac OS X application bundle.

--
Greetings

   Pete

A child of five could understand this!  Fetch me a child of five.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 17:44     ` Peter Dyballa
@ 2007-10-15 18:15       ` Drew Adams
  2007-10-15 18:23         ` Alex Deva
  0 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2007-10-15 18:15 UTC (permalink / raw)
  To: Peter Dyballa, alxx; +Cc: Help-gnu-emacs

> > I'm not sure where they should be replaced
>
> Look at load-path. It will have among the first few elements
> directories that belong to your home directory. Put the files there,
> so they're found before those inside the Mac OS X application bundle.

First, just try loading each of them using `M-x load-file'. If they don't
help, there is no sense in using them.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
  2007-10-15 18:15       ` Drew Adams
@ 2007-10-15 18:23         ` Alex Deva
  2007-10-15 18:41           ` Drew Adams
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Deva @ 2007-10-15 18:23 UTC (permalink / raw)
  To: Drew Adams; +Cc: Peter Dyballa, Help-gnu-emacs

Sorry Drew, but as I said, I'm more of a beginner.

I saved the two libraries you recommended, and then loaded both  
manually with load-file. So... what now? I can't call add-hook from  
inside emacs (or I don't know how). What am I supposed to do from  
this point on? How do I test the hook?

On Oct 15, 2007, at 9:15 PM, Drew Adams wrote:

>>> I'm not sure where they should be replaced
>>
>> Look at load-path. It will have among the first few elements
>> directories that belong to your home directory. Put the files there,
>> so they're found before those inside the Mac OS X application bundle.
>
> First, just try loading each of them using `M-x load-file'. If they  
> don't
> help, there is no sense in using them.
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 18:23         ` Alex Deva
@ 2007-10-15 18:41           ` Drew Adams
  2007-10-15 20:12             ` Alex Deva
       [not found]             ` <mailman.2101.1192479183.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Drew Adams @ 2007-10-15 18:41 UTC (permalink / raw)
  To: Alex Deva; +Cc: Peter Dyballa, Help-gnu-emacs

> Sorry Drew, but as I said, I'm more of a beginner.

No apology needed. My fault for not noticing that.

> I saved the two libraries you recommended, and then loaded both
> manually with load-file. So... what now? I can't call add-hook from
> inside emacs (or I don't know how). What am I supposed to do from
> this point on? How do I test the hook?

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)

If that doesn't fix the problem, then take a look at the value of
`after-make-frame-functions'. If it contains more than just `fit-frame', try
setting it to nil (empty) and then adding `fit-frame' back again:

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

The result should then be this:

C-h v after-make-frame-functions ==> (fit-frame)

Note: If there were additional functions, besides `fit-frame', in
`after-make-frame-functions', then there might be a good reason for them to
be there. ;-)

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.

But see my previous reply about long lines. It sounds like this might just
be unrealistic expectations on your part. `fit-frame' makes the frame as
wide as its longest line, but it respects maximum limits that you can set.
See the `fit-frame' doc string.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
  2007-10-15 18:41           ` Drew Adams
@ 2007-10-15 20:12             ` Alex Deva
  2007-10-15 20:54               ` Drew Adams
  2007-10-16  8:44               ` Peter Dyballa
       [not found]             ` <mailman.2101.1192479183.18990.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 14+ messages in thread
From: Alex Deva @ 2007-10-15 20:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 3645 bytes --]


On Oct 15, 2007, at 9:41 PM, Drew Adams wrote:

>> Sorry Drew, but as I said, I'm more of a beginner.
>
> No apology needed. My fault for not noticing that.

I actually take pride in that :)

>
>> I saved the two libraries you recommended, and then loaded both
>> manually with load-file. So... what now? I can't call add-hook from
>> inside emacs (or I don't know how). What am I supposed to do from
>> this point on? How do I test the hook?
>
> 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) 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.

> If that doesn't fix the problem, then take a look at the value of
> `after-make-frame-functions'. If it contains more than just `fit- 
> frame', try
> setting it to nil (empty) and then adding `fit-frame' back again:
>

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. :(

> M-: (setq after-make-frame-functions nil)
> M-: (add-hook 'after-make-frame-functions 'fit-frame)
>
> The result should then be this:
>
> C-h v 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.


> 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...

>
> But see my previous reply about long lines. It sounds like this  
> might just
> be unrealistic expectations on your part. `fit-frame' makes the  
> frame as
> wide as its longest line, but it respects maximum limits that you  
> can set.
> See the `fit-frame' doc string.

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).

Given this new information, is there anything else I could try? 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,

   Alex




[-- Attachment #1.2: Type: text/html, Size: 8688 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-15 20:12             ` Alex Deva
@ 2007-10-15 20:54               ` Drew Adams
  2007-10-16  7:15                 ` Alex Deva
  2007-10-16  8:44               ` Peter Dyballa
  1 sibling, 1 reply; 14+ messages in thread
From: Drew Adams @ 2007-10-15 20:54 UTC (permalink / raw)
  To: Alex Deva; +Cc: Help-gnu-emacs

> > 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
  2007-10-15 20:54               ` Drew Adams
@ 2007-10-16  7:15                 ` Alex Deva
  2007-10-16 14:18                   ` Drew Adams
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Deva @ 2007-10-16  7:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help-gnu-emacs


On Oct 15, 2007, at 11:54 PM, Drew Adams wrote:

> `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.
>

Thanks. I wouldn't have gotten very far without knowing the basic  
emacs keystroke conventions, and definitely not this far. :) I just  
didn't know that `pp-eval-expression' was bound to a particular  
keystroke.

>
> 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.

Another keystroke I didn't know. This is what I get in the *Help*  
buffer:

set-mode-style-after-make-frame is a Lisp function in `aquamacs- 
styles.el'.
(set-mode-style-after-make-frame frame)

Not documented.


So obviously Aquamacs-specific code.


>
> 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

I activated up the debugger, then opened a new file and the debugger  
didn't start, probably meaning that `fit-frame' never got called. I  
double-checked and `after-make-frame-functions' indeed had the value  
(fit-frame). I suppose this means that the problem is Aquamacs  
ignoring this call...?

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

You seem to be right there.


> 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.
>

Is there any way I can debug the hook itself, and maybe see why it  
doesn't call `fit-frame'?


> The things you need to determine for sure are these:
>
> 1. Whether `fit-frame' gets called as an after-make-frame function.

It doesn't seem to get called.

> 2. Exactly what changes if you have short or long lines.

That must've been my fault -- I expressed myself poorly (sorry, I'm  
not a native English speaker). When I call `fit-frame' manually, the  
frame is correctly resized to smaller if the lines are shorter than  
the current edge (within minimum limits), and bigger if the lines are  
soft-wrapped (also within maximum limits). I don't think that the  
problem is anywhere inside `fit-frame'.

>
> 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.
>

That makes perfect sense and thank you again for your help so far.  
However, let me ask again, perhaps I might debug the hook itself and  
see what it's calling and what it's not? Is there a way to do this?

Thanks,

   Alex

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
  2007-10-15 20:12             ` Alex Deva
  2007-10-15 20:54               ` Drew Adams
@ 2007-10-16  8:44               ` Peter Dyballa
  1 sibling, 0 replies; 14+ messages in thread
From: Peter Dyballa @ 2007-10-16  8:44 UTC (permalink / raw)
  To: Alex Deva; +Cc: emacs list


Am 15.10.2007 um 22:12 schrieb Alex Deva:

> Given this new information, is there anything else I could try? 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.

Because they're on the Mac OS X Emacs list:

	---------------------------- Info -----------------------------
	List Post: <mailto:macosx-emacs@email.esm.psu.edu>
	List Archives: <http://dir.gmane.org/gmane.emacs.macintosh.osx>


--
Greetings

   Pete

"We have to expect it, otherwise we would be surprised."

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: fit-frame every time i open a file
  2007-10-16  7:15                 ` Alex Deva
@ 2007-10-16 14:18                   ` Drew Adams
  0 siblings, 0 replies; 14+ messages in thread
From: Drew Adams @ 2007-10-16 14:18 UTC (permalink / raw)
  To: Alex Deva; +Cc: Help-gnu-emacs

> This is what I get in the *Help* buffer:
>
> set-mode-style-after-make-frame is a Lisp function in `aquamacs-
> styles.el'. (set-mode-style-after-make-frame frame)
> Not documented.
>
> So obviously Aquamacs-specific code.

You can click `mouse-2' on `aquamacs-styles.el' to go to its definition.
Sometimes there are comments in the code that will help you understand what
it does. And sometimes the code itself is understandable, even for someone
new to Lisp. (And it's one way to learn a little Lisp, in passing...)

> > 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
>
> I activated up the debugger, then opened a new file and the debugger
> didn't start, probably meaning that `fit-frame' never got called.

That's what I suspected.

> I double-checked and `after-make-frame-functions' indeed had the value
> (fit-frame). I suppose this means that the problem is Aquamacs
> ignoring this call...?

I don't know, sorry. At least the problem is apparently not with
`fit-frame'. I think you'll need to contact an Aquamacs expert.

> Is there any way I can debug the hook itself, and maybe see why it
> doesn't call `fit-frame'?

Try debugging `make-frame'.

There might be other code to debug instead or in addition, but I don't have
the time now to search for it. If you `grep' the Lisp source files you might
find code that runs the hook, and then you can debug that.

You can also define a command that calls `find-file' (or whatever), and then
debug that. Sooner or later, you will get to the hook.

Good luck. Try also what Peter suggested: contacting an Aquamacs mailing
list.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: fit-frame every time i open a file
       [not found]             ` <mailman.2101.1192479183.18990.help-gnu-emacs@gnu.org>
@ 2007-10-21  7:57               ` David Reitter
  0 siblings, 0 replies; 14+ messages in thread
From: David Reitter @ 2007-10-21  7:57 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 15, 9:12 pm, Alex Deva <a...@indigenious.ro> wrote:

> Given this new information, is there anything else I could try? The
> problem started off pretty simple, but now seems to be getting
> hairier...

(I presume you run one-buffer-one-frame-mode, that is, "Display
Buffers in Separate Frames" is on in the Options menu.)

To fit a frame, the `fit-frame' function needs to see the buffer
contents.

When you type C-x C-f, a new frame is opened, and then you are allowed
to enter the name of the file to be loaded. This means that the `after-
make-frame-functions' are run _before_ the file is loaded. The  idea
of using `after-make-frame-functions' is thus a kludge: it assumes
that the frame is created after the file has been loaded. This is easy
to see if you actually watch watch's happening when you press C-x C-f.
As further hint: `fit-frame' works fine when you find files from the
"Recent Files" menu.

If you enter C-h k C-x C-f, you find that C-x C-f is bound to
`aquamacs-find-file' in Aquamacs. That's something we can leverage.
So, my solution is this (in addition to the code Drew suggested):

(defadvice aquamacs-find-file (after fit activate)
  (fit-frame))

if you add that to your ~/Library/Preferences/Aquamacs Emacs/
Preferences.el, `fit-frame' is called after each (interactive)
aquamacs-find-file operation.

Does that work for you?

Maybe we'll add an option for users to easily enable frame fitting in
such a situation - I think that'd be nice.

> Aquamacs support is rather scarce, and I'm surprised to
> discover that nobody from their team is on this list also.

Can you substantiate that? What else have you tried with respect to
support? Notice the support options on the website.

--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and
support the Aquamacs Project!

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-10-21  7:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-15 13:07 fit-frame every time i open a file alxx
2007-10-15 15:45 ` Drew Adams
2007-10-15 16:13   ` alxx
2007-10-15 17:02     ` Drew Adams
2007-10-15 17:44     ` Peter Dyballa
2007-10-15 18:15       ` Drew Adams
2007-10-15 18:23         ` Alex Deva
2007-10-15 18:41           ` Drew Adams
2007-10-15 20:12             ` Alex Deva
2007-10-15 20:54               ` Drew Adams
2007-10-16  7:15                 ` Alex Deva
2007-10-16 14:18                   ` Drew Adams
2007-10-16  8:44               ` Peter Dyballa
     [not found]             ` <mailman.2101.1192479183.18990.help-gnu-emacs@gnu.org>
2007-10-21  7:57               ` David Reitter

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.