Day 3 - Understanding Files and Buffers

The windows and the buffer.

I will touch upon one new topic and what I learned today. While writing my Day 2 article I learnt intersting usage of windows and frames (well, the one where we do our editing and writing stuff. It would be good to understand how opening emacs creates the frame and window within.) We start emacs the same way we start our other application. (on Linux, by typing on the terminal window; on Windows and Mac, clicking on to the application icon.) When emacs starts up it usually display a special buffer name GNU Emacs. This contains information about emacs and links to common good stuff for begineers(in later days we will figure out how we can skip this)

It is good not to start multiple emacs session, instead just start once and do all the editing in the same sessions. In this way the emacs context accumlates valuable context, such as kill ring, registers, undo history, which helps a lot at advanced stages.

Buffer

The text we are going to edit in emacs is called as buffers and is used to hold the files text. So everytime we visit a file, run dired, send message with ‘C-x m’ or ask for help, a buffer is used for holding the text of the message.

Creating and selecting buffers

</tr> </tr> </tbody> </table> ### Listing Buffers
Command Keybinding Command Description
C-x b BUFFER switch-to-buffer select of create a buffer
    named BUFFER.
C-x 4 b BUFFER switch-to-buffer-other-window slect BUFFER in other
    window.
C-x 5 b BUFFER switch-to-buffer-other-frame select BUFFER in other
    frame.
C-x </td> previous-buffer select the previous buffer
C-x </td> next-buffer select the next buffer
C-u M-g M-g   read num N and move to line N
C-u M-g g   in the most recent buffer
    other than current
Command Keybinding Command Description
C-x C-b list-buffer List the exisitng buffers
Here is an example of a buffer list: CRM Buffer Size Mode File . \* .emacs 3294 Emacs-Lisp ~/.emacs % **Help** 101 Help search.c 86055 C ~/cvs/emacs/src/search.c % src 20959 Dired by name ~/cvs/emacs/src/ - **mail** 42 Mail % HELLO 1607 Fundamental ~/cvs/emacs/etc/HELLO % NEWS 481184 Outline ~/cvs/emacs/etc/NEWS **scratch** 191 Lisp Interaction - **Messages** 1554 Fundamental \`.' in the first field indicates that this is the current buffer. \`%' indicates a read-only buffer. \`\*' indicates that the buffer is "modified". The buffer \`\*Help\*' was made by a help request (\*note Help::); it is not visiting any file. The buffer \`src' was made by Dired on the directory \`~/cvs/emacs/src/'. ### Killing The buffers can simply be done by just pressing C-x k BUFFER or in the C-x C-b we can select the buffer by pressing k and then exectue it. ## Windows
Key Bindings Description
'C-x 2' To split the windows into 2 one above the another.
'C-x 3' Split the windows side by side.
'C-x o' to move around windows, or click in the window with the mouse click to have the focus on that window.
'C-M-v' Scroll the next window.
'C-x 0' Delete the selected window
'C-x 1' Delete all windows except the select one.
'C-x 4 0' Delete the selected window and kill the buffer showing in that window.
'C-x ^' Make selected window taller.
'C-x }' Make selected window wider
'C-x {' Make selected window narrower
'C-x -' Shrink window if buffer dont need so many lines.
'C-x +' Make all window same height.

comments powered by Disqus