bug-gnu-emacs
[Top][All Lists]
Advanced

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

Difficulties with Emacs resizing the frame after turning off the tool-ba


From: worley
Subject: Difficulties with Emacs resizing the frame after turning off the tool-bar (workaround and possible fix)
Date: Sun, 26 Jan 2003 14:47:29 -0500 (EST)

Emacs version: 21.2

Observed problem:

I dislike the tool-bar, so in my .emacs file I have placed the call

    (tool-bar-mode -1)

to suppress it.  However, after I start Emacs and place the frame
using my window manager, Emacs resizes the frame to be approximately 3
lines less high than I specified using the window manager.

Investigation:

Putting a call to sit-for in my .emacs file shows that the resizing of
the frame happens not when tool-bar-mode is called, but later,
probably after Emacs has finished processing .emacs.

It appears that the culprit is the code at lines 297 et seq. in
frame.el:

          (when (and tool-bar-originally-present
                     (or (null tool-bar-lines)
                         (null (cdr tool-bar-lines))
                         (eq 0 (cdr tool-bar-lines))))
            (let* ((char-height (frame-char-height frame-initial-frame))

The job of this code appears to be to resolve a problem that has been
reported by others, namely that if Emacs is started with a specified
frame geometry (e.g., "emacs --geometry 80x24 &") and if .emacs
suppresses the tool-bar, then the frame is initialized with too many
lines.  Removing the tool-bar enlarges the text window portion of the
frame; this code then shrinks the frame to eliminate the extra lines.

However, it seems to me that the semantics of the situation are more
complicated than have been allowed for:  If Emacs was started with a
specified size in *lines*, then the above code does the right thing,
preserving the number of lines in the text window when the tool-bar is
removed.  But if Emacs was started with a specified size in *pixels*
(e.g., "the full screen height"), then the above code should not be
executed -- the space reclaimed by suppressing the tool-bar should be
made available as extra lines in the text window.

To get this effect, the code in frame.el should do a further test to
determine whether to resize the frame:  Resize only if the size of the
frame was specified in lines.  It looks like this test can be done by
"(assq 'user-size initial-frame-alist)", since information about how
the size of the frame was specified is put into initial-frame-alist.
So the above code should be modified to:

          (when (and tool-bar-originally-present
                     (assq 'user-size initial-frame-alist)   ;; add this
                     (or (null tool-bar-lines)
                         (null (cdr tool-bar-lines))
                         (eq 0 (cdr tool-bar-lines))))
            (let* ((char-height (frame-char-height frame-initial-frame))

Workaround:

Looking at this code suggests that resizing of the frame can be
suppressed by setting tool-bar-originally-present to nil.  So one can
work around the problem by using the following code in .emacs:

    (tool-bar-mode -1)

    ;; Unless we've specified a number of lines, prevent the startup code from 
    ;; shrinking the frame because we got rid of the tool-bar.
    (if (not (assq 'user-size initial-frame-alist))
        (setq tool-bar-originally-present nil))

With this workaround, starting Emacs both with and without --geometry
seems to do the right thing.

Dale




reply via email to

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