1 This is Info file ../../info/new-users-guide.info, produced by Makeinfo
2 version 1.68 from the input file new-users-guide.texi.
4 INFO-DIR-SECTION XEmacs Editor
6 * Intro: (new-users-guide). Introduction to the XEmacs Editor.
9 This manual serves as an introduction to the XEmacs editor.
11 Copyright (C) 1985, 1986, 1988 Richard M. Stallman. Copyright (C)
12 1991, 1992, 1993, 1994 Lucid, Inc. Copyright (C) 1993, 1994 Sun
15 Permission is granted to make and distribute verbatim copies of this
16 manual provided the copyright notice and this permission notice are
17 preserved on all copies.
20 File: new-users-guide.info, Node: Top, Next: Intro, Prev: (dir), Up: (dir)
22 The Emacs Editor ****************
24 Emacs is the extensible, customizable, self-documenting real-time
25 display editor. This Info file will help you get started on using
26 XEmacs. It corresponds to XEmacs version 19.13.
30 * Intro:: Introduction to XEmacs editor
32 Indices, nodes containing large menus
33 * Key Index:: An item for each standard Emacs key sequence.
34 * Command Index:: An item for each command and function name
35 * Variable Index:: An item for each variable in User-Guide
36 * Concept Index:: An item for the concepts introduced
38 Entering, Exiting and Editing Emacs
39 * Entering:: Starting Emacs from the shell and Exiting
40 * Windows and Menus:: Description of Pull-down menus
41 * Edit:: Basic Editing commands
43 Other Features of XEmacs
44 * Customization Basics:: Customize Emacs menus and keybindings
45 * Help:: Help menu and other help commands
46 * Modes:: Major and Minor modes in XEmacs
47 * Files:: Visiting, Saving and Listing Files
48 * Other Customizations:: Customizing Variables, Modes, etc
49 * Select and Move:: Selecting text and moving text
50 * Search and Replace:: Searching and Replacing text
54 -- The Detailed Node Listing --
56 Entering and Exiting Emacs
58 * Enter:: Entering Emacs from the shell
59 * Frame:: Basic information about the XEmacs Frame
60 * Exiting:: Exiting Emacs
61 * Mode Line:: Interpreting the mode line.
62 * Echo Area:: Bottom of the frame where you interact
65 XEmacs Windows and Menus
67 * XEmacs Window:: Manipulating XEmacs Windows
68 * Pull-down Menus:: Description of XEmacs Pull-down Menus
72 * File menu:: Items on the File Menu
73 * Edit menu:: Items on the Edit Menu
74 * Options Menu:: Items on the Options Menu
75 * Buffers Menu:: Items on the Buffers Menu
76 * Help menu:: The Help Menu at the extreme right on
79 Basic Editing Commands
81 * Insert:: Insert text in Emacs by simply typing at
83 * Cursor Position:: Moving Around the cursor in the buffer,
84 * Erase:: Different commands for erasing text
85 * Numeric Argument:: Giving Numeric Arguments to commands
86 * Undo:: Undoing Changes made by mistake
88 Customize key bindings and menus
90 * Customizing key Bindings:: Changing Key Bindings
91 * Customizing Menus:: Adding, Deleting, Enabling and Disabling Menus
95 * The Help Menu:: Items on the Help Menu
99 * Major Modes:: Choosing Major Modes
100 * Minor Modes:: Auto-Fill, Abbrev and other minor modes
104 * File Names:: How to type and edit file name arguments.
105 * Visiting:: Visiting a file prepares Emacs to edit the file.
106 * Saving Files:: How to save Emacs files.
110 * Setting Variables:: Customizing Emacs variables
111 * Init File:: Some examples of Lisp expressions in
114 Selecting and Moving Text
116 * Selecting Text:: Select a region of text by setting the Mark
117 * Mouse:: Selecting Text with Mouse
118 * Region Operation:: Various ways to operate on a selected text
119 * Moving Text:: Moving Text
120 * Accumulating text:: Accumulating Text from several buffers
122 No sub menu for the node search and replace
125 File: new-users-guide.info, Node: Intro, Next: Key Index, Prev: Top, Up: Top
130 You are reading about XEmacs which is a self-documenting,
131 customizable, extensible real-time display editor.
133 XEmacs is a "display" editor because normally the text being edited
134 is visible on the screen and is updated automatically as you type.
135 *Note Display: (xemacs)Frame.
137 It is a "real-time" editor because the display is updated very
138 frequently, usually after each character or pair of characters you type.
139 This minimizes the amount of information you must keep in your head as
140 you edit. *Note Real-time: (xemacs)Basic.
142 It is advanced because it provides facilities that go beyond simple
143 insertion and deletion: filling of text; automatic indentation of
144 programs; viewing two or more files at once; and dealing in terms of
145 characters, words, lines, sentences, paragraphs, and pages, as well as
146 expressions and comments in several different programming languages.
147 It is much easier to type one command meaning "go to the end of the
148 paragraph" than to find that spot with simple cursor keys.
150 "Self-documenting" means that at any time you can type a special
151 character, `Control-h', to find out what your options are. You can
152 also use `C-h' to find out what a command does, or to find all the
153 commands relevant to a topic. *Note Help: (xemacs)Help.
155 "Customizable" means you can change the definitions of Emacs
156 commands. For example, if you use a programming language in which
157 comments start with `<**' and end with `**>', you can tell the Emacs
158 comment manipulation commands to use those strings (*note Comments:
159 (xemacs)Comments.). Another sort of customization is rearrangement of
160 the command set. For example, you can set up the four basic cursor
161 motion commands (up, down, left and right) on keys in a diamond pattern
162 on the keyboard if you prefer. *Note Customization:
163 (xemacs)Customization.
165 "Extensible" means you can go beyond simple customization and write
166 entirely new commands, programs in the Lisp language to be run by
167 Emacs's own Lisp interpreter. Emacs is an "on-line extensible" system:
168 it is divided into many functions that call each other. You can
169 redefine any function in the middle of an editing session and replace
170 any part of Emacs without making a separate copy of all of Emacs. Most
171 of the editing commands of Emacs are written in Lisp; the few
172 exceptions could have been written in Lisp but are written in C for
173 efficiency. Only a programmer can write an extension to Emacs, but
174 anybody can use it afterward.
177 File: new-users-guide.info, Node: Entering, Next: Windows and Menus, Prev: Concept Index, Up: Top
179 Entering and Exiting Emacs
180 **************************
182 While using Emacs you should be familiar with the following three
186 A buffer is a region of memory holding characters. It is the basic
187 editing unit; one buffer corresponds to one piece of text being
188 edited. You can have multiple buffers but you can edit only one
189 buffer at any one time. For more information, *Note Buffers:
193 A file is a region of disk space holding characters. Emacs edits a
194 file by reading it into a buffer, editing that buffer and writing
195 out the buffer back to the file. To save your work permanently you
196 have to write it to a file. So after you load and work with a
197 file, you have to save it back.
200 A window is a rectangular region in which a buffer is displayed.
201 You can open multiple windows with multiple buffers and edit them
202 by selecting the corresponding buffer. Initially, when you start
203 emacs, it will automatically open up a window for you.
207 * Enter:: Entering Emacs from the shell
208 * Frame:: Basic information about the XEmacs Frame
209 * Exiting:: Exiting Emacs
210 * Mode Line:: Interpreting the mode line.
211 * Echo Area:: Bottom of the frame where you interact
215 File: new-users-guide.info, Node: Enter, Next: Frame, Prev: Entering, Up: Entering
220 To enter Emacs type `xemacs' and press the Return key at the shell
221 i.e. `xemacs <RET>'. This will bring up an emacs window with
222 `*scratch*' as the default buffer because Emacs must always have a
223 buffer to work on. Then choose the Open... option from the File menu on
224 the menubar at the top of the frame. It will prompt you to enter a
225 filename. After you enter the filename, Emacs will read that file into
226 the current buffer. You can also type :
227 xemacs <filename> <RET>
228 directly which will bring up an Emacs frame with the "filename" as
232 File: new-users-guide.info, Node: Frame, Next: Exiting, Prev: Enter, Up: Entering
237 When you run XEmacs under X, a menu bar on top of the Emacs frame
238 provides access to pull-down menus of file, edit, and help-related
239 commands. The menus only provide convenient shortcuts, the options that
240 they provide are available via key commands. You can invoke those
241 commands from the keyboard also. For many of the options, their
242 corresponding key commands are displayed right besides them. The five
243 default menus on the menubar that you will see on the frame are File,
244 Edit, Options, Buffers and Help. *Note XEmacs Pull-down Menus:
245 (xemacs)XEmacs Pull-down Menus, for detailed information on the
246 functions provided by the pull-down menus.
248 The Emacs frame has a rectangle shaped box at the extreme right and
249 you can drag it up or down to scroll the window accordingly. Clicking
250 on the arrows also serves the same purpose.
252 The last line in your window is `the Mode line' which will give you
253 a description of what's going on in that particular window. *Note Mode
254 Line::, for more information. Below the mode line is the `Echo area'.
255 Emacs uses this area to interact with the user. *Note Echo Area::.
257 If you wish to open another file in a new window after you enter
258 XEmacs, select Open in New Frame... from the File menu, which will
259 prompt you for a filename and open a new window with that filename as
260 the current buffer. If you want to open a new file in the same window,
261 select Open.. from the File menu. You need to enter XEmacs only once,
262 you can edit multiple files by opening several other frames or by
263 switching between buffers.
266 File: new-users-guide.info, Node: Exiting, Next: Mode Line, Prev: Frame, Up: Entering
271 There are two commands for exiting Emacs, one for "suspending" Emacs
272 and the other for "killing" Emacs. "Suspending" means stopping Emacs
273 temporarily and returning control to the shell, allowing you to resume
274 editing later in the same Emacs job, with the same files, same kill
275 ring, same undo history, and so on. This is the usual way to exit.
276 "Killing" Emacs means destroying the Emacs job. You can run Emacs
277 again later, but you will get a fresh Emacs; there is no way to resume
278 the same editing session after it has been killed.
281 Suspend Emacs (`suspend-emacs'). If used under the X window
282 system, this command will shrink the X window containing the Emacs
283 frame to an icon. Clicking on the icon will resume that Emacs
284 process again. *Note Exiting Emacs: (xemacs)Exiting Emacs.
287 Kill Emacs (`save-buffers-kill-emacs'). You can also select Exit
288 Emacs option from the File menu to kill that Emacs process. If you
289 haven't saved the file, Emacs will ask you if you wish to save the
290 file before killing that process.
293 File: new-users-guide.info, Node: Mode Line, Next: Echo Area, Prev: Exiting, Up: Entering
298 When you enter XEmacs, each text window's last line is a "mode line"
299 which describes what is going on in that window. Normally, the mode
302 --CH-XEmacs: BUF (MAJOR MINOR)----POS------
304 This gives information about the buffer being displayed in the window:
305 the buffer's name, what major and minor modes are in use, whether the
306 buffer's text has been changed, and how far down the buffer you are
311 if the text in the buffer has been edited
314 if the text in the buffer has not been edited
317 if the buffer is a read-only-buffer i.e. it cannot be edited
319 BUF is the name of the window's chosen "buffer". If you are editing
320 a file (which is the selected buffer), the file name appears in BUF.
321 *Note Buffers: (xemacs)Buffers.
325 if your entire file is visible on the screen.
328 if you are looking at the beginning of the file.
331 if you are looking at the end of the file.
334 NN will be a number corresponding to the percentage of the file
335 above the top of the screen, for example `52', which means that 52%
336 of the file is above the top of the screen.
338 MAJOR is the name of the "major mode" in effect in the buffer. At
339 any time, each buffer is in one and only one major mode. The available
340 major modes include Fundamental mode (the least specialized), Text
341 mode, Lisp mode, and C mode. *Note Major Modes: (xemacs)Major Modes,
342 for details on how the modes differ and how you select one.
344 MINOR is a list of some of the "minor modes" that are turned on in
345 the window's chosen buffer. For example, `Fill' means that Auto Fill
346 mode is on which means that lines are broken automatically when they
347 become too wide. *Note Minor Modes: (xemacs)Minor Modes, for more
348 information on various minor modes and how to enable them.
350 You can also display time in the mode line. *Note The Mode Line:
351 (xemacs)The Mode Line, for more information regarding the mode line.
354 File: new-users-guide.info, Node: Echo Area, Prev: Mode Line, Up: Entering
359 The line at the bottom of the frame (below the mode line) is the
360 "echo area". Emacs uses this area to communicate with you:
362 * The "echo area" will print out the characters that you type. For
363 example, if you choose the Open... option from the File menu you
364 might get the following in the echo area:
366 Find file: /usr/lib/x11/
368 Now you need to give a file name to open, for example if the file
369 name is `myfile', you will type `myfile' after `/usr/lib/x11/' and
370 press the <Return> key. If you pause for more than a second while
371 typing, you will see the characters that you type in the "echo
374 * The "echo area" also prints error messages. For example, if you
375 misspell `usr' and type `/urs/lib/x11/myfile' <RETURN> in the
376 above example you might get an error message. Since Emacs will not
377 be able to find the `/urs' directory, the "echo area" will say:
379 error--> Opening directory: no such file or directory, /urs/lib/x11/myfile
381 This error message will be accompanied by a beep. Some XEmacs
382 commands will print informative messages in the "echo area". *Note
383 The Echo Area: (xemacs)The Echo Area, for more information on the
387 File: new-users-guide.info, Node: Windows and Menus, Next: Edit, Prev: Entering, Up: Top
389 XEmacs Windows and Menus
390 ************************
392 The first section of this chapter will show you how you can
393 manipulate XEmacs Windows and the other section will explain the
394 Pull-down Menus of an XEmacs window.
398 * XEmacs Window:: Manipulating XEmacs Windows
399 * Pull-down Menus:: Description of XEmacs Pull-down Menus
402 File: new-users-guide.info, Node: XEmacs Window, Next: Pull-down Menus, Prev: Windows and Menus, Up: Windows and Menus
407 When you use XEmacs under X, you can open multiple windows and each
408 window can display one buffer or multiple parts of one buffer. Each
409 window will have its own "mode line" and "echo area". At any one time
410 there is only one "selected window" and the buffer it displays is the
411 "selected buffer". There are some commands for manipulating windows:
414 This command will scroll the window which is not "selected"
415 (`scroll-other-window').
418 This command will get rid of the selected window (`delete-window').
419 That is a zero. If there is more than one Emacs frame, deleting the
420 sole remaining window on that frame deletes the frame as well. If
421 the current frame is the only frame, it is not deleted.
424 This command will get rid of all the windows except the selected
425 one. (`delete-other-windows'). For example, if you use the
426 Describe variable option from the Help menu, the window will split
427 vertically and the bottom window will contain documentation for
428 that variable. After you are done looking at that variable's
429 documentation you might want to come back to your original single
430 window. Just type `C-x 1' after your cursor is in the top window
431 (the window which you want to keep) and hit <RET>.
434 This command will split the selected window into two windows, one
435 above the other (`split-window-vertically'). Both the windows will
436 start out by displaying the same buffer. The window in which you
437 have your cursor will be your "selected window".
440 This will split the selected window into two windows positioned
441 side by side (`split-window-horizontally'). A line of vertical
442 bars will separate the window.
444 You can select a buffer in another window by using some other commands.
445 These commands all have a prefix key `C-x 4'
446 `C-x 4 b BUFNAME <RET>'
447 This command will select a buffer BUFNAME in another window. This
448 runs `switch-to-buffer-other-window'. It will prompt you for a
451 `C-x 4 f FILENAME <RET>'
452 Visit file FILENAME and select its buffer in another window. This
453 runs `find-file-other-window'. *Note Visiting: (xemacs)Visiting.
454 It will prompt you for a filename.
456 `C-x 4 d DIRECTORY <RET>'
457 Select a Dired buffer for directory DIRECTORY in another window.
458 This runs `dired-other-window'. *Note Dired: (xemacs)Dired.
461 Start composing a mail message in another window. This runs
462 `mail-other-window', and its same-window version is `C-x m'.
463 *Note Sending Mail: (xemacs)Sending Mail, for information on how
464 to Send Mail using XEmacs. *Note Reading Mail With Rmail:
465 (xemacs)Reading Mail With Rmail, for information on reading mail
468 If you click the right button on the mouse on a mode line, you will
469 get a menu with following options:
471 Choosing this menu will remove the window above this modeline from
475 Delete all windows on the frame except for the one above this
479 Split the window above the mode line in half, creating another
482 Split Window Horizontally
483 Split the window above the mode line in half horizontally, so that
484 there will be two windows side-by-side.
487 Readjust the sizes of all windows on the frame until all windows
488 have roughly the same number of lines.
491 File: new-users-guide.info, Node: Pull-down Menus, Prev: XEmacs Window, Up: Windows and Menus
493 XEmacs Pull-down Menus
494 ======================
496 When you run XEmacs under X, each Emacs frame has a menu-bar at the
497 top which provides commands for editing, help and other options. All
498 these options are also available via key commands, the menus just
499 provide convenient short-cuts. The key commands are displayed right
500 besides some of the options. The following is a brief description of
501 the four default menus on the menu bar:
505 * File menu:: Items on the File menu
506 * Edit menu:: Items on the Edit menu
507 * Options Menu:: Items on the Options Menu
508 * Buffers Menu:: Items on the Buffers Menu
509 * Help menu:: The Help Menu at the extreme right on
513 File: new-users-guide.info, Node: File menu, Next: Edit menu, Prev: Pull-down Menus, Up: Pull-down Menus
518 The File menu bar contains the following items. To choose a
519 particular option, press the left mouse button and drag it to the item
520 you wish to select. Then release the button.
523 This option will prompt you for a file name. You will get a
524 message in the echo area:
528 After Find File, there might be a directory path also. After you
529 type the file name and press <RET> the file will be loaded into a
533 It prompts you for a file name and loads that file in a new buffer
534 in a new frame. You can open many frames for the same Emacs
535 session. You can delete the frame by selecting Delete Frame.
538 Prompts you for a filename and inserts the contents of this
539 filename in your current buffer. Position your cursor at the place
540 you wish to insert the file and select this option. You will get
541 the following message in the echo area:
545 Insert the file name and press <RET>.
548 It saves the changes you have made to the buffer. If you have made
549 changes which are not saved yet, the option will appear dark,
550 otherwise it will be light and unselectable. If you do not wish to
551 save the changes, select Revert Buffer.
554 Prompts you for a filename and saves the current buffer in that
555 file. It loads the new file if the filename you specify is
556 different from the one you were working with.
558 Print Buffer <buffername>
559 Prints a hardcopy of the current or "selected" buffer.
562 Opens a new frame with *scratch* as the default buffer. It doesn't
563 prompt you for a filename. To open a file you need to go to that
564 frame and select Open...
567 Splits the current window into two equal-sized windows with the
568 same buffer. To get back a single frame, select Un-Split (Keep
569 This). *Note XEmacs Window::, for more information about windows.
572 If the frame contains multiple windows, it will remove all windows
573 except the selected one.
575 Un-Split (Keep Others)
576 If the frame contains multiple windows, it will remove the selected
577 window and keep the other one.
579 Revert Buffer <buffername>
580 If you do not wish to save the changes you made to the file since
581 you opened it, select this option. It will restore the last saved
582 version of the file to the current buffer.
584 Kill Buffer <buffername>
585 It will kill the current buffer. If will prompt you if there are
589 It will kill the Emacs "process" as opposed to simply killing the
590 "buffer". Before it kills the process, it will prompt you as to
591 which unsaved buffers you wish to save by going through the list
596 * Edit menu:: Items on the Edit Menu
597 * Options Menu:: Items on the Options Menu
598 * Buffers Menu:: Items on the Buffers Menu
599 * Help menu:: The Help Menu at the extreme right on
603 File: new-users-guide.info, Node: Edit menu, Next: Options Menu, Prev: File menu, Up: Pull-down Menus
608 Most of the commands in this menu work on a block of text or a
609 selected region. The text will be highlighted as you select it.
611 Undoes the previous command. If you type something by mistake you
612 can use this command. For example, if you select Insert File...
613 from the File menu and insert a wrong file by mistake, you can
614 select this item and it will remove the inserted file. It undoes a
615 batch of text which is worth an emacs command.
618 Removes the selected text block from the current buffer, makes it
619 the X clipboard selection, and places it in the kill ring (*note
620 Moving Text::.). Before executing this command, you have to select
621 a region using Emacs region selection commands or with the mouse.
622 *Note Selecting Text::.
625 Makes a selected text block the X clipboard selection, and places
626 it in the kill ring. You can select text using one of the Emacs
627 region selection commands or by selecting a text region with the
628 mouse. *Note Selecting Text::, for more information.
631 Inserts the current value of the X clipboard selection in the
632 current buffer. Note that this is not necessarily the same as the
633 Emacs `yank' command, because the Emacs kill ring and the X
634 clipboard selection are not the same thing. You can paste in text
635 you have placed in the clipboard using Copy or Cut. You can also
636 use Paste to insert text that was pasted into the clipboard from
637 other applications. *Note X Clipboard Selection: (xemacs)X
638 Clipboard Selection, for information on using Clipboard Selection.
641 Removes the selected text block from the current buffer but does
642 not place it in the kill ring or the X clipboard selection. You
643 will not be able to get this text back.
645 Start Macro Recording
646 After selecting this, Emacs will remember every keystroke you type
647 until End Macro Recording is selected.
650 Selecting this tells emacs to stop remembering your keystrokes.
653 Selecting this item will cause emacs to re-interpret all of the
654 keystrokes which were saved between selections of the Start Macro
655 Recording and End Macro Recording menu items. You can now execute
656 the most recent keyboard macro. *Note Keyboard Macros:
657 (xemacs)Keyboard Macros, for further information.
660 File: new-users-guide.info, Node: Options Menu, Next: Buffers Menu, Prev: Edit menu, Up: Pull-down Menus
665 There are sub-menus for some of the menus which you will need to
666 select. If sub-menus exist for an item, they will be displayed
667 automatically when you drag the mouse on that item. The items in this
668 menu provide some fancy editing operations.
671 Selecting this item will cause the buffer to visit the file in a
672 read-only mode. Changes to the file will not be allowed.
674 Case Sensitive Search
675 Selecting this item will cause searches to be case-sensitive. If
676 its not selected then searches will ignore case. This option is
677 local to the buffer. For example, if this item is selected and you
678 are searching for `Smile', then an occurrence of `smile' will not
679 be recognized because of the smaller case of `s'.
682 After selecting this item, when you type letters they will replace
683 existing text on a one-to-one basis, rather than pushing it to the
684 right. At the end of a line, such characters extend the line.
685 Before a tab, such characters insert until the tab is filled in.
687 Auto Delete Selection
688 Selecting this item will cause automatic deletion of the selected
689 region. After you select a region and hit the <RET> key, the
690 selected text will be deleted. The typed text will replace the
691 selection if the selection is active (i.e. if its highlighted). If
692 the option is not selected then the typed text is just inserted at
695 Teach Extended Commands
696 After you select this item, any time you execute a command with
697 `M-x' which has a shorter keybinding, you will be shown the
698 alternate binding before the command executes. For example if you
699 type `M-x find-file-other-window' which performs the same function
700 as the Open in Other Window... in File menu you will see the
703 M-x find-file-other-window (bound to keys: C-x 4 f, C-x 4 C-f)
706 You can customize your `.emacs' file to include the font-lock mode
707 so that when you select this item, the comments will be displayed
708 in one face, strings in another, reserved words in another, and so
709 on. *Note Customization: (xemacs)Customization, for more
710 information on customizing `.emacs' file. After selecting this
711 item, you will find your code a lot easier to read. When Fonts is
712 selected, different parts of the program will appear in different
713 Fonts. When Colors is selected, then the program will be displayed
714 in different colors. Selecting None causes the program to appear in
715 just one Font and Color. Selecting Less resets the Fonts and Colors
716 to a fast, minimal set of decorations. Selecting More resets the
717 Fonts and Colors to a larger set of decorations. For example, if
718 Less is selected (which is the default setting) then you might have
719 all comments in green color. It does not matter what the comments
720 contain. Whereas, if More is selected then a function name in the
721 comments themselves might appear in a different Color or Font. Even
722 though the comments themselves might appear in green color, a
723 function name "within" the comments might appear in red color.
726 After selecting Blink from this item, if you place the cursor on a
727 parenthesis, the matching parenthesis will blink. If you select
728 Highlight and place the cursor on a parenthesis, the whole
729 expression of the parenthesis under the cursor will be highlighted.
730 Selecting None will turn off the options (regarding Paren
731 Highlighting) which you had selected earlier.
734 You can select any Font for your program by choosing from one of
735 the available Fonts. The whole buffer will be converted to the
739 You can select any size for the text in your buffer (ranging from
740 2 to 24) by selecting the appropriate option.
743 You can choose either Bold or Medium for the weight of the text of
746 Buffers Menu Length...
747 Prompts you for the number of buffers to display. Then it will
748 display that number of most recently selected buffers.
751 After selection of this item the Buffers menu will contain several
752 commands, as submenus of each buffer line. If this item is
753 unselected, then there are no submenus for each buffer line, the
754 only command available will be selecting that buffer.
757 Selecting this item will save the current settings of your Options
758 menu to your `.emacs' file so that the next time you start XEmacs,
759 you won't need to select the options again.
762 File: new-users-guide.info, Node: Buffers Menu, Next: Help menu, Prev: Options Menu, Up: Pull-down Menus
767 The Buffers menu provides a selection of up to ten buffers and the
768 item List All Buffers, which provides a Buffer List. If you select
769 Buffers Sub-menus from the Options menu, you will get some sub-menus
770 for each of the buffer listing.
773 File: new-users-guide.info, Node: Help menu, Prev: Buffers Menu, Up: Pull-down Menus
778 The Help Menu gives you access to Emacs Info and provides a menu
779 equivalent for some of the choices you have when using `C-h'. *Note
780 Help::, for more information.
782 The Describe variable and Describe function will provide
783 documentation for the corresponding variable or function. The Help menu
784 also gives access to UNIX online manual pages via the UNIX Manual...
788 File: new-users-guide.info, Node: Edit, Next: Customization Basics, Prev: Windows and Menus, Up: Top
790 Basic Editing Commands
791 **********************
793 This chapter will introduce you to some basic editing commands. You
794 can also learn the basic editing commands by typing `Control-h t'
795 (`help-with-tutorial' OR by selecting Emacs Tutorial from the Help menu
796 on the menu bar. Most of the Emacs commands will use the <CONTROL> key
797 or the <META> key. The following abbreviations will be used for the
798 <CONTROL> and <META> key in this manual:
801 This means that you should hold down the <CONTROL> key while typing
802 `<chr>'. For example, if the command is `C-g', you should hold the
803 <CONTROL> key and type <g>.
806 This means that you should hold down the `META' key while typing
807 `<chr>'. If there is no `META' key on your keyboard, use the `ESC'
808 key instead. For example, if the command is `M-x', then type
809 `ESC', release it and type `x'.
811 The following abbreviations will be used for some other keys:
833 * Insert:: Insert text in Emacs by simply typing at
835 * Cursor Position:: Moving Around the cursor in the buffer,
836 * Erase:: Different commands for erasing text
837 * Numeric Argument:: Giving Numeric Arguments to commands
838 * Undo:: Undoing Changes made by mistake
841 File: new-users-guide.info, Node: Insert, Next: Cursor Position, Prev: Edit, Up: Edit
846 To insert printing characters into the text you are editing, just
847 type them. Emacs will automatically insert the characters that you type
848 into the buffer at the cursor. The cursor moves forward, but if you
849 prefer to have text characters replace (overwrite) existing text
850 characters, you can enable the Overstrike option from the Options menu
853 To "delete" text you have just inserted, use <DEL>. <DEL> deletes
854 the character BEFORE the cursor (not the one that the cursor is on top
855 of or under; that is the character AFTER the cursor). The cursor and
856 all characters after it move backwards. Therefore, if you type a
857 printing character and then type <DEL>, they cancel out.
859 To end a line and start typing a new one, type <RET>. This inserts
860 a newline character in the buffer. If point is in the middle of a
861 line, <RET> splits the line. Typing <DEL> when the cursor is at the
862 beginning of a line rubs out the newline before the line, thus joining
863 the line with the preceding line.
865 Emacs automatically splits lines when they become too long, if you
866 turn on a special mode called "Auto Fill" mode. *Note Filling:
867 (xemacs)Filling, for information on using Auto Fill mode.
870 File: new-users-guide.info, Node: Cursor Position, Next: Erase, Prev: Insert, Up: Edit
875 The following commands will allow you to move the cursor around the
876 screen. The actual function names corresponding to these commands are
877 given in parenthesis. You can also invoke these commands by typing `M-x
878 <function name>'. You can do this for any command in XEmacs.
881 Move the cursor backward one character (`backward-char').
884 Move the cursor forward one character (`forward-char').
887 Move the cursor up one line vertically (`previous-line').
890 Move the cursor down one line vertically (`next-line').
893 Move the cursor to the beginning of the line (`beginning-of-line').
896 Move the cursor to the end of the line (`end-of-line').
899 Move the cursor forward one word (`forward-word').
902 Move the cursor backword one word (`backward-word').
905 Move the cursor to the top of the buffer (`beginning-of-buffer').
908 Move the cursor to the end of the buffer (`end-of-buffer').
910 `M-x goto-char RET <number> RET'
911 To enable this command type `M-x goto-char', and hit <RETURN> key.
912 In the "echo area" you will see:
916 You should then type in a number right after the colon and hit the
917 `RETURN' key again. After reading a number N this command will
918 move the cursor to character number N. Position 1 is the
919 beginning of the buffer. For example, if you type `M-x goto-char
920 RET 200 RET', then the cursor will move to the 200th character
921 starting from the beginning of the buffer.
923 `M-x goto-line RET <number> RET'
924 To enable this command type `M-x goto-line', and hit the <RETURN>
925 key. After you see `Goto line:' in the "echo area", type in a
926 number N and hit <RETURN> key again. This command will position
927 the cursor on the nth line starting from the beginning of the
931 This command will display the current line number in the echo area.
934 File: new-users-guide.info, Node: Erase, Next: Numeric Argument, Prev: Cursor Position, Up: Edit
940 If you press <DEL> i.e. the "delete" key, it will delete the
941 character before the cursor (`delete-backward-char').
944 This will delete the character after the cursor (`delete-char').
947 Kill to the end of the line (`kill-line'). If you kill the line by
948 mistake you can "yank" or `paste' it back by typing `C-y'. *Note
949 Moving Text::, for more information on yanking.
952 Kill forward to the end of the next word (`kill-word').
955 Kill back to the beginning of the previous word
956 (`backward-kill-word').
959 Kill to the end of current sentence (`kill-sentence').
962 Kill up to next occurrence of CHAR (`zap-to-char'). To use this
963 command type `M-z'. You will see the following statement in the
968 Type any char and press the <RET> key. For example, if you type
969 `p' then the entire text starting from the position of the cursor
970 until the first occurrence of `p' is killed.
973 File: new-users-guide.info, Node: Numeric Argument, Next: Undo, Prev: Erase, Up: Edit
975 Giving Numeric Arguments
976 ========================
978 Any Emacs command can be given a "numeric argument". Some commands
979 interpret the argument as a repetition count. For example, if you want
980 to move forward ten characters, you could type `C-f' ten times.
981 However, a more efficient way to do this would be to give an argument
982 of ten to the key `C-f' (the command `forward-char', move forward one
983 character). Negative arguments are also allowed. Often they tell a
984 command to move or act backwards. For example, if you want to move down
985 ten lines, type the following:
988 After you press <RET> key, the cursor will move ten lines downward. You
992 Both `C-u' and `M-' allow you to give numeric arguments. If you want to
993 move ten lines backward, you can also give negative arguments, like:
996 OR you could also type:
999 You can obviously use `C-b' to move backward rather than giving
1000 negative arguments to `C-n'. *Note Numeric Arguments: (xemacs)Numeric
1001 Arguments, for more information on numeric arguments.
1004 File: new-users-guide.info, Node: Undo, Prev: Numeric Argument, Up: Edit
1009 When you are editing a buffer, you might type something by mistake.
1010 Emacs allows you to undo all changes you make to a buffer (but not more
1011 than 8000 characters). Each buffer in Emacs keeps a record of the
1012 changes made to it individually, so the undo command applies to the
1013 current buffer. There are two undo commands:
1016 Undo one batch of changes (usually, one command's worth).
1020 The same as above, but this command might not be obvious to type
1021 on some keyboards so it might be better to use the above command.
1023 *Note Undoing Changes: (xemacs)Undoing Changes, for more information
1027 File: new-users-guide.info, Node: Customization Basics, Next: Help, Prev: Edit, Up: Top
1029 Customize key bindings and menus
1030 ********************************
1032 When you start Emacs, it reads the file `~/.emacs' in your home
1033 directory. You can use this file to initialize and customize Emacs to
1034 your liking. This file should contain lisp-code. You can customize your
1035 `.emacs' file to create new menus, disable menus, change key bindings,
1036 enable a minor mode, etc. Any kind of customization affects only a
1037 particular Emacs job that you do them in. If you want to save your
1038 customizations `permanently' i.e. for future use also, you have to put
1039 it in your `.emacs' file. After you make changes to your `.emacs' file
1040 and save it, the changes will be effective only after you start Emacs
1041 again i.e. for a new Emacs process. To try out some of the examples in
1042 this section, highlight that region and evaluate the region by giving
1043 the command `M-x eval-region'. You will be able to see the results of
1044 your customizations in that Emacs session only (*note Lisp Eval:
1045 (xemacs)Lisp Eval.).
1049 * Customizing key Bindings:: Changing Key Bindings
1050 * Customizing Menus:: Adding, Deleting, Enabling and Disabling Menus
1053 File: new-users-guide.info, Node: Customizing key Bindings, Next: Customizing Menus, Prev: Customization Basics, Up: Customization Basics
1055 Customize key bindings
1056 ======================
1058 Most of Emacs commands use key sequences. *Note Keystrokes:
1059 (xemacs)Keystrokes, for more information about Keys and Commands. In
1060 Emacs, the keys themselves carry no meaning unless they are bound to a
1061 function. For example, `C-n' moves the cursor to the next line because
1062 its bound to the function next-line. Similarly, `C-p' moves to the
1063 previous line because its bound to the function previous-line. The
1064 functions themselves define a particular behavior. You can customize
1065 the key `C-n' to move to the previous line by binding it to
1066 previous-line and `C-p' to move to the next line by binding it to
1067 next-line. To bind keys to globally run commands you need to use the
1068 following syntax in your .emacs file:
1070 `(global-set-key KEYS CMD)'
1072 Here, `global-set-key' is a function which will bind the "keys" to the
1073 specified "cmd". For example, if you type the following in your .emacs
1076 (global-set-key "\C-p" 'next-line)
1077 (global-set-key "\C-n" 'previous-line)
1079 then `C-p' will move to the next line and `C-n' to the previous line.
1081 You can also disable a key binding, by using `nil' as the CMD in the
1082 syntax stated above. Here, `nil' stands for `false' which means disable
1083 a command or turn off a feature. If you want to enable a command or
1084 turn on a particular feature use `t' which stands for `true'. For
1085 example, if you do not wish `C-x C-c' to `Exit Emacs' you can type the
1086 following expression in your `.emacs' file:
1088 (global-set-key "\C-x\C-c" nil)
1090 You might want to have this statement in your `.emacs' file because its
1091 easy to hit this command by mistake and it could be annoying to exit
1092 Emacs unintentionally. There is a Exit Emacs option in the File menu
1093 which you might want to use instead. To make a particular key undefined
1096 (global-unset-key "\C-x\C-c")
1098 Now if you use the command `C-x C-c', you will get an error saying that
1099 the command is undefined.
1101 Some other customizations you could try are:
1102 * (global-set-key 'button3 'beginning-of-buffer)
1104 Now when you press the third button of your mouse, the cursor will
1105 be placed at the `beginning-of-buffer'.
1107 * (global-set-key 'f1 'goto-line)
1109 If you press the <F1> key, you will be prompted for a line number.
1110 After you type the line number and hit <RET>, the cursor will be
1111 placed on that line number.
1113 * (global-set-key 'f2 'undo)
1115 Pressing <F2> will undo the last command. If you have a <undo> key
1116 on your keyboard, try binding that key to the undo command.
1118 Another syntax for customizing key bindings is: `(define-key KEYMAP
1119 KEYS DEF)' It defines KEYS to run DEF in the keymap KEYMAP.
1121 KEYMAP is a keymap object which records the bindings of keys to the
1122 commands that they run.
1124 KEYS is the sequence of keystrokes to bind.
1126 DEF is anything that can be a key's definition:
1128 Look at the following two examples:
1130 (define-key global-map "\C-xl" 'make-symbolic-link)
1131 (define-key c-mode-map "\C-xl" 'make-symbolic-link)
1133 Both the examples bind the key `C-xl' to run the function
1134 `make-symbolic-link' (*note Misc File Ops: (xemacs)Misc File Ops.).
1135 However, the second example will bind the key only for C mode. *Note
1136 Major Modes: (xemacs)Major Modes, for more information on Major Modes
1140 File: new-users-guide.info, Node: Customizing Menus, Prev: Customizing key Bindings, Up: Customization Basics
1145 You can customize any of the XEmacs Pull-down-Menus. You can create
1146 your own menu, delete an existing one, enable a menu or disable a menu.
1147 For more information on the default menus available to you, *Note
1150 Some of the functions which are available to you for customization
1152 1. add-menu-item: (MENU-NAME ITEM-NAME FUNCTION ENABLED-P &OPTIONAL
1155 This function will add a menu item to a menu, creating the menu
1156 first if necessary. If the named item already exists, the menu
1157 will remain unchanged. For example, if you add the following
1158 example to your `.emacs' file or evaluate it (*note Customization
1161 (add-menu-item '("Edit") "Replace String" replace-string t "Clear")
1163 a sub-menu Replace String will be created under Edit menu before
1164 the sub-menu Clear. The Edit menu will now look like:
1172 Start Macro Recording C-x(
1173 End Macro Recording C-x)
1174 Execute Last Macro C-xe
1176 Replace String will now execute the function `replace-string'.
1177 Select this menu item. Emacs will prompt you for a string name to
1178 be replaced. Type a string and hit <RET>. Now type a new string to
1179 replace the old string and hit <RET>. All occurrences of the old
1180 string will be replaced by the new string. In this example,
1182 `Edit' is the MENU-NAME which identifies the menu into which the
1183 new menu item should be inserted.
1185 `Replace String' is the ITEM-NAME which names the menu item to be
1188 `replace-string' is the FUNCTION i.e. the command to be invoked
1189 when the menu item "Replace String" is selected.
1191 `t' is the ENABLED-P parameter which controls whether the menu
1192 item is selectable or not. This parameter can be either `t'
1193 (selectable), `nil' (not selectable), or a form to evaluate. This
1194 form is evaluated just before the menu is displayed, and the menu
1195 item will be selectable if the form returns non-`nil'.
1197 `Clear' is the &OPTIONAL BEFORE parameter which is the name of the
1198 menu before which the new menu or sub-menu should be added. The
1199 &OPTIONAL string means that this parameter is optional. You do not
1200 need to specify this parameter. If you do not specify this
1201 parameter in the example above, the Replace String menu item will
1202 be added at the end of the list of sub-menus in the Edit menu i.e.
1203 after Execute Last Macro.
1205 If you wish to add a new menu to the menubar, try:
1207 (add-menu-item nil "Bot" 'end-of-buffer t)
1209 This will create a new menu Bot on the menu bar. Selecting this
1210 menu will take you to the end of the buffer. Using `nil' for the
1211 parameter MENU-NAME will create a new menu. Your menu-bar will now
1214 File Edit Options Buffers Bot Help
1216 The following example will illustrate how you can add sub-menus to
1217 the submenus themselves:
1219 (add-menu-item '("File" "Management") "Copy File" 'copy-file t)
1220 (add-menu-item '("File" "Management") "Delete File" 'delete-file t)
1221 (add-menu-item '("File" "Management") "Rename File" 'rename-file t)
1223 This will create a sub-menu Management under the File menu. When
1224 you select the submenu Management, it will contain three submenus:
1225 Copy File, Delete File and Rename File.
1227 2. delete-menu-item: (MENU-PATH) This function will remove the menu
1228 item defined by MENU-NAME from the menu hierarchy. Look at the
1229 following examples and the comments just above them which specify
1230 what the examples do.
1232 ;; deletes the "Replace String" menu item created earlier
1233 (delete-menu-item '("Edit" "Replace String"))
1235 ;; deletes the "Bot" menu created earlier
1236 (delete-menu-item '("Bot"))
1238 ;; deletes the sub-menu "Copy File" created earlier
1239 (delete-menu-item '("File" "File Management" "Copy File"))
1241 ;; deletes the sub-menu "Delete File" created earlier
1242 (delete-menu-item '("File" "Management" "Delete File"))
1244 ;; deletes the sub-menu "Rename File" created earlier
1245 (delete-menu-item '("File" "Management" "Rename File"))
1247 3. disable-menu-item: (MENU-NAME) Disables the specified menu item.
1248 The following example
1250 (disable-menu-item '("File" "Management" "Copy File"))
1252 will make the Copy File item unselectable. This menu-item would
1253 still be there but it will appear faded which would mean that it
1256 4. enable-menu-item: (MENU-NAME) Enables the specified previously
1259 (enable-menu-item '("File" "Management" "Copy File"))
1261 This will enable the sub-menu Copy File, which was disabled by the
1264 5. relabel-menu-item: (MENU-NAME NEW-NAME) Change the string of the
1265 menu item specified by MENU-NAME to NEW-NAME.
1267 (relabel-menu-item '("File" "Open...") "Open File")
1269 This example will rename the Open... menu item from the File menu