4.4. Working with Frames


By now you know that Emacs calls GUI windows "frames." In this section, we'll cover how to create frames, navigate between frames, and delete frames.

4.4.1 Creating a New Frame

To open a new frame, type C-x 5 2 (for make-frame). Emacs makes a new frame containing the current buffer and puts it on top of the current frame.

If your new frame completely overlaps your current frame, you may need to size the new frame to tell them apart. For a more convenient solution, add these lines to your .emacs file:

(setq initial-frame-alist '((top . 10) (left . 30)                             (width . 90) (height . 50))) (setq default-frame-alist '((width . 80) (height . 45)))

These lines set up sizes for the width and height of Emacs frames. The first frame is the size set in initial-frame-alist (in this example, 90 characters wide by 50 lines high with top and left defining an inset), and subsequent frames, specified by default-frame-alist, will be 80 characters wide and 45 lines high. Depending on your display, you can make these numbers smaller or larger.

Here we edit a bit of Henry James.

Type: C-x 5 2

Emacs opens a new frame titled james


Frame Names

Note the title of your new frame. The first frame in your session, your initial Emacs frame, displays Emacs@system name at the top (or Emacs's best guess at the system name). Any other frames you create display the buffer name at the top. In fact, once you have multiple frames, all frames display the buffer name as their title. If you delete all frames but one, the title once again reverts to Emacs@system name.


Let's say we want to open a frame on our dickens buffer.

Type: C-x 5 f dickens Enter

Emacs opens a new frame on dickens.


If you type C-x b to move to another buffer, the name at the top of the frame changes to the new buffer's name (and on Linux, it shows the path as well). To move to a buffer and put it in a new frame, type C-x 5 b. You might have guessed that one.

4.4.2 Moving Between Frames

You can move between frames in several ways. You can use the mouse to select a frame or press C-x 5 o to go to another frame. To see a list of current frames, select Frames from the Buffers menu. (If you have only one frame, the Frames option does not appear on this menu.)

4.4.3 Deleting and Minimizing Frames

To get rid of a frame, press C-x 5 0. Emacs deletes the frame you are in. Deleting a frame, like deleting a window, affects only the display. The underlying buffer is still active, and you can move to it by typing C-x b.

If you try to use C-x 5 0 to delete the only frame that is left, Emacs won't do it. To exit Emacs, type C-x C-c or close the frame as you would any other GUI window using the mouse.

To minimize a frame, either minimize it in the usual way or press C-z. Table 4-1 summarizes the frame commands.

Table 4-1. Frame commands

Keystrokes

Command name

Action

C-x 5 oBuffers

other-frame

Move to other frame.

C-x 5 0File

delete-frame

Delete current frame.

C-x 5 2File

make-frame

Create a new frame on the current buffer.

C-x 5 f

find-file-other-frame

Find file in a new frame.

C-x 5 r

find-file-read-only-other-frame

Finds a file in a new frame, but it is read-only.

C-x 5 b

switch-to-buffer-other-frame

Make frame and display other buffer in it.




Learning GNU Emacs
Learning GNU Emacs, Third Edition
ISBN: 0596006489
EAN: 2147483647
Year: 2003
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net