1 This is ../info/new-users-guide.info, produced by makeinfo version 4.0
2 from new-users-guide/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: Help, Next: Modes, Prev: Customization Basics, Up: Top
25 XEmacs provides a comprehensive Help facility. On the extreme right
26 of the menu-bar there is a Help menu. There are several help commands
27 provided by this menu. You can also use `C-h' for invoking the Help
28 facility. Type "?" for a list of keys you can type after typing `C-h'.
29 If you want more information on what your options are and what kind of
30 help you can get type "?" again. You will get a listing of all the keys
31 you can type and what they will do. Initially if you want help, type
36 * The Help Menu:: Items on the Help menu
39 File: new-users-guide.info, Node: The Help Menu, Prev: Help, Up: Help
44 When you click on the Help menu with any of the mouse buttons you
45 will get the following menu items:
48 Selecting this item will take you to the Info page which is the
49 online documentation browsing system. You can simply click on the
50 highlighted items and "Info" will take you to the document
51 providing information about that topic.
54 After you select this item, you will get a documentation on the
55 major and minor modes which are enabled in the buffer you are
56 working with. *Note Modes::, for information on Modes.
59 After you select this item, you will see the following message in
62 List symbols matching regexp:
64 If you type "mode" and hit <RET>, you will get a list of all the
65 symbols (like functions and commands). You can now get
66 documentation on any of the given symbols by "clicking" on any of
67 the symbols (i.e. drag your mouse on the appropriate symbol and
68 release the button). For example, if you "click" on the
69 'auto-fill-mode' you will get the following message in the window
76 Toggle auto-fill mode.
77 With arg, turn auto-fill mode on if and only if arg is positive.
78 In auto-fill mode, inserting a space at a column beyond `fill-column'
79 automatically breaks the line at a previous space.
85 variable not documented
88 Selecting this item will prompt you for a string just like when you
89 select Hyper Apropos.... After you give a string name, you will get
90 a listing of all the functions and commands containing that string
91 name with a very short description about what that command does.
94 After you select this item, you will be prompted for a string name
99 Now you can give any string name, for example "mode" and hit
100 <RET>. You will get a listing of all the variables and commands
101 containing that string i.e "mode" with a short description of its
105 Select this item and you will get a listing of all the keys and the
106 commands that they execute. Depending on which Major mode your
107 buffer is in, you will get a listing of the special keybindings
108 for that particular buffer also. For example, if you are in
109 "Texinfo" mode, part of your list will contain:
111 C-c C-c n texinfo-insert-@node
112 C-c C-c o texinfo-insert-@noindent
113 C-c C-c s texinfo-insert-@samp
114 C-c C-c t texinfo-insert-@table
115 C-c C-c v texinfo-insert-@var
116 C-c C-c x texinfo-insert-@example
117 C-c C-c { texinfo-insert-braces
119 These keybindings apply only to "Texinfo" mode. *Note Modes::, for
120 more information on various modes.
123 After you select this item, you will be see the following message
127 After you type a command key sequence, full documentation of that
128 command will be displayed. For example if you type `C-g', you will
129 see the following documentation for `C-g':
132 Signal a `quit' condition.
133 This means that `C-g' will quit whatever command you gave earlier.
136 This menu item provides documentation for a function. After you
137 select this item, it will prompt you for a function name in the
140 Describe function (default <some function name>):
142 If you hit <RET> without giving a function name, you will get
143 documentation for that default function name, otherwise if you
144 type a function name and hit <RET>, you will get documentation for
148 You can get documentation on any variable by selecting this menu
149 item. It is similar to Describe Function and will prompt you for a
153 After you select this item you will be prompted for a Unix command
154 for which you wish to see the man page. You will see the following
155 message in the echo area:
157 Manual entry: (default <some name>)
159 Now you can type any command, for example type `who' and press
160 <RET>. You will get the man page for the Unix command `who' which
161 lists who is on the system.
164 Select this item and you will get a tutorial on Emacs. It is good
168 Select this item and you will get a lot of historical and current
171 For more information on the Help facility, *Note Help: (xemacs)Help.
174 File: new-users-guide.info, Node: Modes, Next: Files, Prev: Help, Up: Top
176 Major and Minor Modes
177 *********************
179 XEmacs is "language sensitive". It has several "major" and "minor"
180 modes. The major modes customize Emacs to edit text of a particular
181 sort. There are major modes for C, Lisp, Emacs Lisp, LaTeX, English
182 etc. Within each major mode, certain functions and keys are redefined
183 to "suit" that particular sort of text. The minor modes provide certain
184 features which can be turned off or on at any time. Emacs can only be
185 in one major mode at any time, but it can turn on several minor modes
186 at the same time. After you have selected any major or minor mode, you
187 can select Describe Mode from the Help menu and you will get
188 documentation about those modes.
192 * Major Modes:: Choosing Major Modes
193 * Minor Modes:: Auto-Fill, Abbrev and other minor modes
196 File: new-users-guide.info, Node: Major Modes, Next: Minor Modes, Prev: Modes, Up: Modes
201 Emacs has several major modes which customize Emacs to edit text of
202 various sorts. You can have only one major mode at any time. Within each
203 major mode, Emacs redefines certain functions (like cursor movement,
204 indentation and text killing) to suit the needs of the text being
205 edited. When you are editing a specific type of text you should switch
206 to the appropriate mode. If you are working with C code, you should
207 switch to C mode; if you are working with Lisp code, then switch to lisp
208 mode and if you are working with English text switch to Text mode.
210 When you open a file to work on, Emacs usually selects the
211 appropriate mode. For example, if you open a file called `guide.c' then
212 Emacs will select the C mode because of the ".c" extension of the file.
213 To explicitly select a mode type the following command:
215 ;;; selects lisp mode
221 To select any other mode, just add the major mode name before the
222 '-mode'. The current mode in which you are in will be displayed in
223 parenthesis in the mode-line at the bottom of the frame. All major
224 modes have some special keybindings and you can get a listing of those
225 keybindings by selecting List Keybindings from the Help menu on the
228 Some of the available modes in XEmacs are :
231 When you start XEmacs, usually you start with the default
232 "Fundamental" mode. This mode has no special definitions or
236 Use this mode when you have to format a text with nroff before it
237 can be available in readable form. It redefines some indentation
238 commands. *Note Nroff Mode: (xemacs)Nroff Mode, for information on
242 Use this mode if you are using the LaTeX text-formatter. It
243 provides commands for insertion of quotes, braces and other
244 characters. It also allows you to format the buffer for printing.
245 *Note TeX Mode: (xemacs)TeX Mode, for information on this mode.
248 Texinfo is a documentation system that uses a single source file to
249 produce both printed output and on-line documentation. When you
250 use this mode, there will be some special keybindings for
251 inserting some characters and executing some commands.
253 This info file which you are reading right now is produced by
257 Use this mode for editing outlines. When you enable this mode, you
258 can make part of the text temporarily invisible so that you can
259 see the overall structure of the outline. *Note Outline Mode:
260 (xemacs)Outline Mode, for information on this mode.
263 Use this mode for C programs. It will redefine some indentation
264 commands. *Note C Indent: (xemacs)C Indent.
267 Use this mode for Lisp programs. Look at the XEmacs User's Manual
268 for more information.
271 Use this mode for Fortran programs. This mode provides special
272 commands to move around and some other indentation commands. For
273 more information on this mode, *Note Fortran: (xemacs)Fortran.
276 This is the picture mode which you can use to create a picture out
277 of text characters. *Note Picture: (xemacs)Picture, for more
281 Use asm-mode for editing files of assembler code. Look at the file
282 ` /usr/local/lib/xemacs-19.11/lisp/modes/asm.el' for more
285 There are some other modes and commands for working with other kinds
286 of text or programs. Emacs also provides commands for reading and
287 sending Mail. For more information on these features look at the XEmacs
288 Manual. Emacs also provides the functions of a desk calendar, with a
289 diary of past or planned events. For more information on the calendar
290 mode look at the manual for Calendar Mode and Diary.
293 File: new-users-guide.info, Node: Minor Modes, Prev: Major Modes, Up: Modes
298 The minor modes in Emacs provide some optional features which you can
299 turn on or off. Any number of minor modes can be active at the same time
300 with any major mode. You can enable a minor mode in one buffer and
301 disable it in other mode. To enable a minor mode, for example the
302 font-lock mode type the following command:
306 To enable the other minor modes, replace the "font-lock" with the name
307 of the minor mode. To disable the mode type the command again. A
308 positive argument will always turn the mode on. Whenever you type this
309 command, it will turn the mode on if it was off, OR it will turn it off
310 if it was on i.e. it toggles. Look at the mode-line at the bottom of the
311 frame. If it says FLock in parentheses, then it means that this mode is
312 on, otherwise it is off.
314 The following are some of the minor modes available in XEmacs. To
315 enable any one of them type "M-x" in front of them.
318 You can also choose this mode by selecting the Syntax Highlighting
319 menu item from the Options menu on the menu-bar at the top. If you
320 wish to have this mode enabled permanently, choose Save Options
321 from the Options menu. *Note Options Menu::, for more information
322 on the Options menu. You can also add statements in your `.emacs'
323 file. For each major mode in which you wish to enable this minor
324 mode, you need a statement in your `.emacs' file. The following
325 example shows how to enable the font-lock mode when the major mode
328 (add-hook 'c-mode-hook 'turn-on-font-lock)
330 *Note Other Customizations::.
332 When you enable this mode, the text will be displayed in different
333 colors and fonts depending on the type of the text. This makes the
334 text very easy to read and understand. For example, comments might
335 be displayed in red, variables in black, functions in blue and
336 other keywords in different colors and fonts. When you select More
337 from the Syntax Highlighting option, you get very detailed display
338 of colors and fonts; function names within comments themselves
339 might appear in a different font and color.
342 Enabling this mode will provide automatic word-wrapping. The <SPC>
343 key will break lines i.e. insert newlines as you type to prevent
344 lines from becoming too long.
347 When you enable this mode, the text that you type will replace the
348 existing text rather than moving it to the right (the default
349 case). You can enable this mode by selecting Overstrike menu-item
350 from the Options menu from the menu-bar.
353 After you enable this mode, you can define words which will expand
354 into some different text i.e. you can define abbreviations. For
355 example, you might define "expand" to "expand will eventually
356 expand to this text". After this definition you will be able to
357 get "expand will eventually expand to this text" simply by typing
361 *Note Abbrevs: (xemacs)Abbrevs, for more information on this mode
362 and on defining abbreviations.
365 After you enable this mode in a buffer, the contents of that
366 buffer will be saved periodically. This will reduce the amount you
367 might lose in case of a system crash.
370 After you enable this mode, the line number at which your cursor is
371 present will be displayed continuously in the mode line.
374 To enable this command, just type
377 Do not add the "-mode" to it. You can also select the Paren
378 Highlighting option from the Options menu. After you enable this
379 command, put your cursor on one of the left parenthesis. The other
380 matching parenthesis will start blinking. *Note Options Menu::,
381 for more information on the Paren Highlighting option.
383 For information on some other modes, look at the XEmacs User's Manual
384 and the associated files.
387 File: new-users-guide.info, Node: Files, Next: Other Customizations, Prev: Modes, Up: Top
392 The basic unit of stored data in Unix is the "file". To edit a file,
393 you must tell Emacs to read the file into a buffer. This is called
394 "visiting" the file. You can now edit the buffer and to save the
395 changes you must write the buffer back to the file.
397 In addition to visiting and saving files, Emacs can delete, copy,
398 rename, and append to files, and operate on file directories.
402 * File Names:: How to type and edit file name arguments.
403 * Visiting:: Visiting a file prepares Emacs to edit the file.
404 * Saving Files:: How to save Emacs files.
407 File: new-users-guide.info, Node: File Names, Next: Visiting, Prev: Files, Up: Files
412 Most of the Emacs commands that operate on a file require you to
413 specify a file name. For example, you might specify the file name
414 initially when you enter Emacs :
418 After you hit <RET>, you will enter XEmacs with "myfile" read into the
419 current buffer. If you do not specify the filename when entering Emacs,
420 you can use the Open... option from the File menu. You will be prompted
421 for a filename in the echo area:
423 Find file: /usr/workspace/
425 Type in a file name which you want to open after the "/" and hit <RET>.
426 The specified file will be read into the current buffer. The
427 "/usr/workspace" might be the "default directory". When Emacs prompts
428 you for a file, it uses the default-directory unless you specify a
429 directory. You can see what the default directory of the current buffer
430 is by using the Describe Variable option from the Help menu. When Emacs
431 prompts you for the variable name to describe, type DEFAULT-DIRECTORY.
432 If you wish to open a file in some other directory, use <DEL> or the
433 <BackSpace> key to go back and type the path name of the new directory.
435 You can create a new directory by typing `M-x make-directory'. This
436 command will prompt you for a directory name:
438 Create directory: /usr/workspace/
440 After you type a directory name and press <RET>, a new directory with
441 the specified name will be created. If you do not wish to create a new
442 directory, then simply press `C-g' to quit the command. Similarly, you
443 can also remove a directory by using the command `remove-directory'.
444 The command `M-x pwd' will print the current buffer's default
445 directory. For more information on file names, *Note File Names:
449 File: new-users-guide.info, Node: Visiting, Next: Saving Files, Prev: File Names, Up: Files
454 To edit a file in Emacs you need to "visit" it. "Visiting" a file
455 means copying its contents (or reading them) into the current buffer.
456 Emacs will create a new buffer for each file that you visit. The buffer
457 will be named after the file that you open. If you open a file
458 `/usr/workspace/myfile.texinfo', the buffer will be called
459 "myfile.texinfo". If a buffer with this name already exists, a unique
460 name will be constructed by appending `<2>', `<3>', etc. If this is the
461 second buffer with the same name, a "<2>" will be appended, "<3>" for a
462 third buffer and so on. The name of the buffer which is being displayed
463 in the window will be shown both at the top and bottom of the frame.
464 Once you are in XEmacs, you can use the following commands:
467 This command will visit a file (`find-file'). It will prompt you
468 for a file name to visit. The Open... option from the File menu
471 Find file: /usr/workspace/
473 Type in a filename and press <RET>. You will see a new buffer on
474 the screen with its name in the mode-line. If the filename you
475 specify already exists in Emacs, the buffer containing that file
476 will be selected. You will get an error message if the filename
477 does not exist. If you still press <RET>, a new buffer with the
478 given filename will be displayed on the screen.
481 This command (`find-alternate-file'), will visit a different file
482 instead of the one visited last. It is similar to `C-c C-f' except
483 that it kills the current buffer (after offering to save it).
486 This command will visit a file in another frame
487 (`find-file-other-frame') without changing the current window or
488 frame. The Open in New Frame... from the File menu will do the
489 same thing. It will prompt you for a file name in the echo area.
490 After you type the file name and press <RET>, the specified file
491 will be read into a new buffer and displayed on a new frame.
494 File: new-users-guide.info, Node: Saving Files, Prev: Visiting, Up: Files
499 The changes that you make after visiting a file will not be saved
500 unless you save the buffer. When you save the buffer, Emacs writes the
501 current contents of the buffer into the visited file. Some commands to
505 This command will permanently save the current buffer in its
506 visited file (`save-buffer'). You will see the following message
507 in the echo area if you save a file called "myfile.texinfo" :
509 Wrote /usr/workspace/myfile.texinfo
511 Try using this command twice. You will get the above message the
512 first time you use this command, the second time you will get the
515 (No changes need to be saved)
517 This message indicates that you haven't made any changes since the
518 last time you saved the file.
521 This command will save all the buffers in their visited files
522 (`save-some-buffers'). It will prompt you for typing yes or no:
524 Save file /usr/workspace/myfile.texinfo? (y or n)
526 You will get the above message for all the buffers. Type "y" if
527 you want to save the buffer.
530 This command will prompt you for a file name and save the current
531 buffer in that file. (`write-file'). You will see the following
532 message in the echo area:
534 Write file: /usr/workspace/
536 After you type in a file name, press <RET>. The buffer will be
537 saved in a new file. You can make copies of a particular file
540 You can also undo all the changes made since the file was visited or
541 saved by reading the text from the file again (called "reverting"). For
542 more information on this option, *Note Reverting: (xemacs)Reverting.
544 When you save a file in Emacs, it destroys its old contents. However,
545 if you set the variable MAKE-BACKUP-FILES to non-NIL i.e. `t', Emacs
546 will create a "backup" file. Select the Describe variable option from
547 the Help menu and look at the documentation for this variable. Its
548 default value should be `t'. However, if its not then use `M-x
549 set-variable' to set it to `t' (*note Setting Variables::). The backup
550 file will contain the contents from the last time you visited the file.
551 Emacs also provides options for creating numbered backups. For more
552 information on backups, *Note Backup: (xemacs)Backup.
554 Emacs also saves all the files from time to time so that in case of a
555 system crash you don't lose lot of your work. You will see the message
556 `Auto-saving...' displayed in the echo area when the buffer is being
557 saved automatically. The auto saved files are named by putting the
558 character `#' in front and back. For example a file called
559 "myfile.texinfo" would be named as `#myfile.texinfo#'. For information
560 on controlling auto-saving and recovering data from auto-saving, *Note
561 Auto Save Files: (xemacs)Auto Save Files.
563 Emacs provides protection from simultaneous editing which occurs if
564 two users are visiting the same file and trying to save their changes.
565 It will put a lock on a file which is being visited and modified. If
566 any other user tries to modify that file, it will inform the user about
567 the lock and provide some options. For more information on protection
568 against simultaneous editing, *Note Interlocking: (xemacs)Interlocking.
571 File: new-users-guide.info, Node: Other Customizations, Next: Select and Move, Prev: Files, Up: Top
576 You can modify the behavior of Emacs in minor ways permanently by
577 putting your changes in your `.emacs' file. This file contains Lisp
578 function call expressions. Each of these expressions will consist of a
579 function name followed by arguments, all surrounded by parentheses. For
580 example, to turn on the auto-fill-mode (i.e. break lines automatically
581 when they become too long) , put the following line in your `.emacs'
584 (add-hook 'text-mode-hook
585 '(lambda() (auto-fill-mode 1)))
587 Emacs has a function named "turn-on-auto-fill" which is defined as
588 "(lambda() (auto-fill-mode 1))". Therefore you can also write the above
591 (add-hook 'text-mode-hook 'turn-on-auto-fill)
593 Emacs provides a number of hooks for the sake of customization. The hook
594 variables contain list of functions to be called with no arguments. To
595 turn on the auto-fill-mode, add the appropriate hook as shown in the
598 Similarly, to enable the "font-lock mode" which displays your
599 program in different fonts and colors(*note Modes::), put the following
600 in your `.emacs' file. The comments above the statement explain what the
603 ;;; enables the font-lock-mode in Lisp Mode
604 (add-hook 'lisp-mode-hook 'turn-on-font-lock)
606 ;;; enables the font-lock-mode in Texinfo Mode
607 (add-hook 'texinfo-mode-hook 'turn-on-font-lock)
609 ;;; enables the font-lock mode in C Mode
610 (add-hook 'c-mode-hook 'turn-on-font-lock)
612 To turn on the font-lock mode in other Major Modes like emacs-lisp,
613 just put the name of the mode with "-hook" appended to it as the middle
614 parameter in the above examples. You can also select the color that the
615 functions, comments or other keywords should be displayed in :
617 ;;; the function names will now be displayed in blue color
618 (set-face-foreground 'font-lock-function-name-face "blue")
620 ;;; the comments will be displayed in forest green
621 (set-face-foreground 'font-lock-comment-face "forest green")
623 For other customizations regarding the font-lock face, look at the file
624 `/usr/local/lib/xemacs-19.11/etc/sample.emacs'.
628 * Setting Variables:: Customizing Emacs variables
629 * Init File:: Some examples of Lisp expressions in
633 File: new-users-guide.info, Node: Setting Variables, Next: Init File, Prev: Other Customizations, Up: Other Customizations
638 In XEmacs, "variables" are used for internal record-keeping and
639 customizations. There are some variables called "options" which you can
640 use for customizations. To examine a variable use:
642 ;;; print the value and documentation of the variable, use either of the
643 ;;; following commands
645 M-x describe variable
647 After you type any of the above commands, you will be prompted for a
648 variable name in the "echo area". Type in the name of the variable, for
649 example, type CASE-FOLD-SEARCH <RET> Your window will split into two
650 and you will see the following message in that window:
652 case-fold-search's value is t
653 This value is specific to the current buffer.
656 *Non-nil if searches should ignore case.
657 Automatically becomes buffer-local when set in any fashion.
659 Since this variable's value is 't' searches will ignore case. If you
660 want case-sensitive-search (i.e. if you are searching for "Foo" and you
661 do not want "foo" to be included in the search, you need to set this
662 variable to "nil". In order to do that, use:
666 Emacs will prompt you for the variable which you wish to set. Type in
667 "case-fold-search" and hit <RET>. You will see the following message:
669 Set case-fold-search to value:
671 Type "nil" and hit <RET>. Now if you again use `M-x describe variable'
672 , you will see that the new value of case-fold-search will be "nil" and
673 your searches will be case-sensitive. This will be effective only for
674 that Emacs session. If you want to change the value of a variable
675 permanently put the following statement in your `.emacs' file :
677 (setq case-fold-search nil)
679 This statement will make searches case-sensitive only in the current
680 buffer which is the `.emacs' file. This will not be very useful. To
681 make searches case-sensitive globally in all buffers, use:
683 (setq-default case-fold-search nil)
685 If you want to change the value of any other variable, use :
687 (setq <variable-name> <new value>)
689 "setq" will assign the "new value" to the "variable-name" .
691 If you want a list of the "options" i.e. the variables available for
695 ;;; displays a buffer listing names, values and documentation of options
698 ;;; displays options and allows you to edit those list of options
701 Try these options. If you are using edit-options to edit a variable,
702 just point at the variable you wish to edit and use one of the following
706 Set the value of the variable to t (non-nil).
709 Set the value of the variable to nil.
712 Move to the next variable.
715 Move to the previous variable.
717 There are some other options available to make the value of a
718 variable local to a buffer and then to switch to its global value. You
719 can also have a "local variables list" in a file which specifies the
720 values to use for certain Emacs variables when you edit that file.
721 *Note Variables: (xemacs)Variables, for information on these options.
724 File: new-users-guide.info, Node: Init File, Prev: Setting Variables, Up: Other Customizations
729 For customizing Emacs, you need to put Lisp expressions in your
730 `.emacs' file. The following are some useful Lisp expressions. If you
731 find any of them useful, just type them in your `.emacs' file:
733 * The following expression will make <TAB> in C mode insert a real
734 tab character if the cursor or point is in the middle of the line.
735 Now hitting the <TAB> key will indent a line only if the cursor is
736 at the left margin or in the line's indentation:
738 (setq c-tab-always-indent nil)
740 The value of the variable C-TAB-ALWAYS-INDENT is usually `t' for
741 `true'. When this variable is true, then hitting the <TAB> key
742 always indents the current line.
744 * This expression will turn on the AUTO-FILL-MODE when you are in
747 (setq text-mode-hook 'turn-on-auto-fill)
749 This mode will automatically break lines when you type a space so
750 that the lines don't become too long. The length of the lines is
751 controlled by the variable FILL-COLUMN. You can set this variable
752 to a value you wish. Look at the documentation for this variable
753 to see its default value. To change the value to 75 for example,
756 (setq-default fill-column 75)
758 This will change the value of this variable globally.
760 * The following expression will enable the use of EVAL-EXPRESSION
761 without confirmation:
763 (put 'eval-expression 'disabled nil)
765 Now when you use EVAL-EXPRESSION, it will print the value of the
766 expression you specify in the "echo area" without confirming with
769 * This expression will remove the binding of `C-x C-c', because its
770 easy to hit this key by mistake and you will exit Emacs
771 unintentionally. You can use the Exit Emacs option from the File
774 (global-set-key "\C-x\C-c" nil)
776 Now if you type `C-x C-c', you won't exit Emacs.
778 * The following expression will make the <BACKSPACE> and the <DEL>
779 key work in the same manner:
781 (global-set-key 'backspace [delete])
783 * This expression will make searches case sensitive:
785 (setq-default case-fold-search nil)
787 If we use "setq" instead of "setq-default" then searches will be
788 case-sensitive only in the current buffer's local value. In this
789 case the buffer would be the `.emacs' file. Since this would not
790 be too helpful and we want to have case-sensitive searches in all
791 buffers, we have to use "setq-default".
793 * This expression will enable the font-lock mode when you are using
796 (add-hook 'texinfo-mode-hook 'turn-on-font-lock)
798 *Note Minor Modes::, for information on font-lock mode.
800 * Rebinds the key `C-x l' to run the function `make-symbolic-link':
802 (global-set-key "\C-xl" 'make-symbolic-link)
804 We use the single quote before "make-symbolic-link" because its a
805 function name. You can also use the following expression which
808 (define-key global-map "C-xl" 'make-symbolic-link)
810 * The following expression will bind `C-x l' to run the function
811 `make-symbolic-link' in C mode only:
813 (define-key c-mode-map "C-xl" 'make-symbolic-link)
815 Instead of binding `C-xl' to run `make-symbolic-link', you can
816 bind the <F1> key to run this function:
818 (define-key c-mode-map 'f1 'make-symbolic-link)
820 Here, you have to use lower case for naming function keys like
823 * You can bind the function `undo' i.e. `C-x u' to any key, for
826 (global-set-key 'f2 'undo)
828 * The following statement will display the current time in the
829 modeline of the buffer:
833 * This displays the current line number on which the cursor is
834 present in the modeline:
836 (setq line-number-mode t)
838 * If you don't want the text to be highlighted when you use commands
839 for marking regions so as to use the "kill" and "yank" commands
840 later, you can use the following expression in your `.emacs' file:
842 (setq zmacs-regions nil)
844 Now if you use a command like `C-x C-p' (`mark-page'), the text
845 will not be highlighted.
847 * To control the number of buffers listed when you select the Buffers
848 menu, you need to set the variable BUFFERS-MENU-MAX-SIZE to
849 whatever value you wish. For example, if you want 20 buffers to be
850 listed when you select Buffers use:
852 (setq buffers-menu-max-size 20)
854 * If you want the window title area to display the full
855 directory/name of the current buffer's file, and not just the
858 (setq frame-title-format "%S: %f")
860 * To get rid of the menu, use :
864 * If you want an extensive menu-bar use the following expression in
869 If you want to write your own menus, you can look at some of the
871 `/usr/local/lib/xemacs-20.0/lisp/packages/big-menubar.el' file.
874 For more information on initializing your `.emacs' file, *Note Init
875 File: (xemacs)Init File. You should also look at
876 `/usr/local/lib/xemacs-20.0/etc/sample.emacs', which is a sample
877 `.emacs' file. It contains some of the commonly desired customizations
881 File: new-users-guide.info, Node: Select and Move, Next: Search and Replace, Prev: Other Customizations, Up: Top
883 Selecting and Moving Text
884 *************************
886 Many Emacs commands operate on an arbitrary contiguous part of the
887 current buffer. You can select some part of the buffer and edit only
888 that part of the buffer. This selected buffer is called a "region". You
889 can select text in two ways:
891 * You use special keys to select text by defining a region between
892 the cursor and "the mark" (which you set).
894 * If you are running XEmacs under X, you can also select text with
899 * Selecting Text:: Select a region of text by setting the Mark
900 * Mouse:: Selecting Text with Mouse
901 * Region Operation:: Various ways to operate on a selected text
902 * Moving Text:: Moving Text
903 * Accumulating text:: Accumulating Text from several buffers
906 File: new-users-guide.info, Node: Selecting Text, Next: Mouse, Prev: Select and Move, Up: Select and Move
911 To define a region you need to set "the mark" at one end of it and
912 move the cursor to the other end. Once you set the mark, it remains
913 there until you set it again to some other place. Each buffer has its
914 own "mark ring" (a place where Emacs remembers 16 previous locations of
915 the mark). To set "the mark", you can use the following commands:
918 This command will set "the mark" at the position of your cursor
919 (`set-mark-command'). You can move your cursor around and "the
920 mark" will stay there.
923 Interchange mark and point (`exchange-point-and-mark'). Since Emacs
924 will have only one cursor, after you move the cursor it will be
925 unable to show you where you set the "the mark". In order to see
926 "the mark" you can type the command `C-x C-x' which will put your
927 cursor on the position of your mark and your mark on the position
928 of your cursor. Use the command again to reset the positions of
929 your cursor and mark.
932 This command will push the mark at the beginning of the buffer
933 without changing the position of your cursor.
936 This command will push the mark at the end of the buffer without
937 changing the position of your cursor.
939 You can also give arguments to `C-<' or `C->'. *Note The Mark and the
940 Region: (xemacs)The Mark and the Region, for more information.
943 File: new-users-guide.info, Node: Mouse, Next: Region Operation, Prev: Selecting Text, Up: Select and Move
945 Selecting Text with Mouse
946 =========================
948 If you are using XEmacs under X, you can use the mouse to select
949 text. The selected text will always be highlighted, so just by looking
950 at the text you know what you have selected so far. To select a word
951 just double-click with the left-mouse-button on the word. To select a
952 whole line triple-click anywhere on the line with the
953 left-mouse-button. You can also use the Copy item from the Edit menu on
954 the menu-bar to select text. This kind of selection is called Clipboard
955 selection, *Note X Clipboard Selection: (xemacs)X Clipboard Selection,
956 for more information. To select an arbitrary region, follow these steps:
958 1. Move the mouse cursor over the character at the beginning of the
959 region of text you want to select.
961 2. Press and hold the left mouse button.
963 3. While holding the left mouse button down, drag the cursor to the
964 character at the end of the region of text you want to select.
966 4. Release the left mouse button.
967 The selected region of text is highlighted.
969 *Note Selecting Text with the Mouse: (xemacs)Selecting Text with the
970 Mouse, for more information regarding the Mouse and additional mouse
974 File: new-users-guide.info, Node: Region Operation, Next: Moving Text, Prev: Mouse, Up: Select and Move
976 Operating on the Region
977 =======================
979 Once you have selected a region you can do a lot of things to the
981 * Kill the text with `C-w'. For example if you want to kill a
982 paragraph, position the cursor to the beginning of the paragraph
983 and type `C-SPC'. Then go to the end of the paragraph and type
984 `C-w'. The entire paragraph will be deleted. You can also select
985 the text with a mouse and type `C-w' to kill the entire region.
986 *Note Killing: (xemacs)Killing, for more information.
988 * Save the text in a buffer or a file (*note Accumulating Text:
989 (xemacs)Accumulating Text.).
991 * You can convert the case of the text with `C-x C-l' or `C-x C-u'
992 If you type `C-x C-u' the selected text will become all
993 upper-case. If you type `C-x C-l' the selected text will become all
996 * Print hardcopy with `M-x print-region'. *Note Hardcopy:
997 (xemacs)Hardcopy, for more information. This command will print a
998 hardcopy of only the selected text.
1000 * Indent it with `C-x <TAB>' or `C-M-\' *Note Indentation:
1001 (xemacs)Indentation, for more information.
1004 File: new-users-guide.info, Node: Moving Text, Next: Accumulating text, Prev: Region Operation, Up: Select and Move
1009 The most common way to move or copy text in Emacs is through
1010 "killing" or `cutting' it and then "yanking" or `pasting' it. You can
1011 also use the Cut or Copy option from the Edit menu for killing and
1012 copying respectively. *Note Edit menu::, for reviewing the commands for
1013 killing text. All the killed text in Emacs is recorded in the "kill
1014 ring". Since there is only one kill ring in Emacs, you can kill text in
1015 one buffer and yank it in another buffer. To `paste' or `yank' the
1016 killed text you can use the following commands:
1018 This command will yank or paste the last killed text (`yank').
1021 Save region as last killed text without actually killing it
1022 (`copy-region-as-kill'). You can use this command to copy a
1023 selected region and then yank (or paste) it without actually
1024 removing it from the buffer.
1027 Append next kill to last batch of killed text
1028 (`append-next-kill'). This command will append whatever you killed
1029 last to what you kill now. Then later you will be able to yank the
1030 entire appended text from the "kill ring".
1033 File: new-users-guide.info, Node: Accumulating text, Prev: Moving Text, Up: Select and Move
1038 The following commands can be used for accumulating text from
1039 different buffers into one place or for copying one region of text into
1042 `M-x append-to-buffer'
1043 Append region to contents of specified buffer
1044 (`append-to-buffer'). After you type in this command and press
1045 <RET>, Emacs will prompt you for a buffer name. You will see a
1046 message in the echo area:
1047 Append to buffer: (default <buffer name>)
1049 After you type in a buffer name, a copy of the region will be
1050 inserted at the location of the cursor into that buffer. If there
1051 is no buffer with the name given by you, Emacs will create a new
1052 buffer with that name. By default the cursor's position in the
1053 <buffer name> is at the end.
1055 `M-x prepend-to-buffer'
1056 Prepend region to contents of specified buffer. This command is
1057 similar to the above command except that the cursor in the buffer
1058 (by default) is at the beginning rather than at the end.
1060 `M-x copy-to-buffer'
1061 Copy region into specified buffer, deleting that buffer's old
1062 contents. This command will also prompt you for a buffer name.
1065 Insert contents of specified buffer into current buffer at point.
1066 This command will prompt you for a buffer name which you want to
1067 be copied into the current buffer at the location of the cursor.
1069 `M-x append-to-file'
1070 This command will prompt you for a filename and append the region
1071 to the end of the contents of the specified file.
1073 *Note Accumulating Text: (xemacs)Accumulating Text, for more
1074 information regarding this topic.
1076 You can also use "rectangle commands" for operating on rectangular
1077 areas of text. *Note Rectangles: (xemacs)Rectangles, for more
1078 information regarding rectangle commands.
1080 Emacs also provides "registers" which serve as temporary storage for
1081 text or positions. Each register has a one character name and they can
1082 store "regions", a "rectangle", or a "mark" i.e. a cursor position.
1083 Whatever you store in register stays there until you store something
1084 else in that register. To find out about commands which manipulate
1085 registers *Note Registers: (xemacs)Registers.
1088 File: new-users-guide.info, Node: Search and Replace, Prev: Select and Move, Up: Top
1090 Searching and Replacing
1091 ***********************
1093 Emacs provides commands for searching for occurrences of a particular
1094 string. The search is incremental i.e. it begins even before you
1095 complete typing the whole string. All searches in Emacs ignore the case
1096 of the text they are searching, i.e. if you are searching for "String",
1097 then "string" will also be one of the selections. If you want a case
1098 sensitive search select the Case Sensitive Search from the Option menu.
1099 You can also set the variable CASE-FOLD-SEARCH to NIL for making
1100 searches case-sensitive. For information on setting variables, *Note
1101 Setting Variables::. The two commands for searching for strings in
1105 This command will prompt you for a string to search :
1109 If you type "myname" as the string to be searched, then Emacs will
1110 start searching for "m", "my", "myn", etc as you go on typing the
1111 whole string in the forward direction. The cursor will be on the
1112 matching string which has been found so far. If you find the
1113 correct match just hit <RET> or type `C-f' or `C-b' to set the
1114 cursor's position. If you find a matching string "myname" but you
1115 were looking for a different occurrence of it, use `C-s' again. If
1116 the search is unable to find the string, it will give you an error
1120 This command will perform an incremental search in the backward
1121 direction. It will prompt you for a string name:
1125 After you start typing the string name, it will search for the
1126 string in the same fashion as it does for `C-s' except that it
1127 will search in the backward direction. If it cannot find the
1128 string name, it will give you an error message.
1130 If you make a mistake while typing the string names when you use the
1131 above commands, you can use the <DEL> key to erase characters. Each
1132 <DEL> will erase the last character. At any time if you want to quit
1133 the search, just type `C-g'.
1135 To do a non-incremental search i.e. to start the search only after
1136 you have typed the whole string you can use the following commands:
1138 `C-s RET "string" RET'
1139 This command will search for the specified string in the forward
1140 direction and will give an error message if the string is not
1143 `C-r RET "string" RET'
1144 This command will search for the specified string in the backward
1147 For information on how Emacs searches for words and regular
1148 expressions, *Note Search: (xemacs)Search.
1150 To replace all occurrences of a string in Emacs, you can use the
1154 After you type `M-x replace-string', you will be prompted for a string
1159 After you type in a string name, for example "FOO" and press <RET>, you
1160 will see another prompt:
1162 Replace string FOO with:
1164 Now type the string which you want to replace "FOO" with and press
1165 <RET>. After all the occurrences are replaced you will see the message
1166 "Done" in the echo area. If you want only some occurrences of the
1167 string to be replaced, use `M-x query-replace RET <string> RET
1168 <newstring> RET'. For more information, *Note Query Replace:
1169 (xemacs)Query Replace.
1171 XEmacs also provides a utility for checking spellings. Use `M-x
1172 ispell-buffer' to check for spellings in the whole buffer. You can also
1173 check the spelling of a word or a region. You can use menus to check
1176 Evaluate the expression `(load "big-menubar")'. To evaluate this
1177 expression you need to hit the <META> or the <ESC> key twice and type
1178 in the expression in the echo area before hitting <RET>. You will get
1179 an extensive menubar. Select the Spell Check menu item from the
1180 Utilities menu for checking spellings.
1183 File: new-users-guide.info, Node: Key Index, Next: Command Index, Prev: Intro, Up: Top
1185 Key (Character) Index
1186 *********************
1190 * C-<: Selecting Text.
1191 * C->: Selecting Text.
1192 * C-a: Cursor Position.
1193 * C-b: Cursor Position.
1195 * C-e: Cursor Position.
1196 * C-fx: Cursor Position.
1197 * C-g: The Help Menu.
1198 * C-h d: The Help Menu.
1199 * C-h k: The Help Menu.
1202 * C-M-\: Region Operation.
1203 * C-n: Cursor Position.
1204 * C-p: Cursor Position.
1205 * C-r: Search and Replace.
1206 * C-s: Search and Replace.
1207 * C-SPC <1>: Region Operation.
1208 * C-SPC: Selecting Text.
1209 * C-t: Cursor Position.
1210 * C-u: Numeric Argument.
1211 * C-v: Cursor Position.
1212 * C-w: Region Operation.
1213 * C-x 0: XEmacs Window.
1214 * C-x 1: XEmacs Window.
1215 * C-x 2: XEmacs Window.
1216 * C-x 3: XEmacs Window.
1217 * C-x 4: XEmacs Window.
1218 * C-x 4 b: XEmacs Window.
1219 * C-x 4 d: XEmacs Window.
1220 * C-x 4 f: XEmacs Window.
1221 * C-x 4 m: XEmacs Window.
1222 * C-x 5 C-f: Visiting.
1224 * C-x C-f: Visiting.
1225 * C-x C-l: Region Operation.
1226 * C-x C-s: Saving Files.
1227 * C-x C-u: Region Operation.
1228 * C-x C-v: Visiting.
1229 * C-x C-w: Saving Files.
1230 * C-x C-x: Selecting Text.
1231 * C-x s: Saving Files.
1232 * C-x TAB: Region Operation.
1237 * M--: Numeric Argument.
1238 * M-<: Cursor Position.
1239 * M->: Cursor Position.
1240 * M-C-v: XEmacs Window.
1244 * M-v: Cursor Position.