Mac – Emacs code for resizing frame


I've been writing some fortran code using emacs, and found that I needed emacs to recognise that the code I'm working on is fortran code (if for example your filename doesn't end in .f or .f90) so that the appropiate syntax highlighting is used. I found out that this can be done by including this comment at the beginning of the code:

! -*- mode: F90 -*-

I was wondering if there was something similar I could put at the beginning of the code which would cause the emacs frame to resize? It would be useful because I have a small input file which I open regularly for my simulations, and everytime I open it I need to resize its frame to something smaller so that it fits snugly without wasting screen space. I still want the default frame size for other source code I'm working on.

Best Answer

Use eval:

! -*- eval: (set-frame-size (selected-frame) 40 25) -*-

Or the more general form:

! Local Variables: 
! eval: (set-frame-size (selected-frame) 40 25) 
! end: 

Here is a description:

Emacs asks you, if the code should be executed. Executing foreign code is a security problem. You can customize the behavior:


See the documentation here:

Related Question