home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / info / emacs-7 (.txt) < prev    next >
GNU Info File  |  1996-09-28  |  48KB  |  847 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Variables for Check-in/out,  Next: Log Entries,  Prev: Editing with VC,  Up: Version Control
  4. Variables Affecting Check-in and Check-out
  5. ------------------------------------------
  6.    If `vc-suppress-confirm' is non-`nil', then `C-x C-q' and `C-x v i'
  7. can save the current buffer without asking, and `C-x v u' also operates
  8. without asking for confirmation.  (This variable does not affect `C-x v
  9. c'; that is so drastic that it should always ask for confirmation.)
  10.    VC mode does much of its work by running the shell commands for RCS
  11. and SCCS.  If `vc-command-messages' is non-`nil', VC displays messages
  12. to indicate which shell commands it runs, and additional messages when
  13. the commands finish.
  14.    Normally, VC assumes that it can deduce the locked/unlocked state of
  15. files by looking at the file permissions of the work file; this is
  16. fast.  However, if the `RCS' or `SCCS' subdirectory is actually a
  17. symbolic link, then VC does not trust the file permissions to reflect
  18. this status.
  19.    You can specify the criterion for whether to trust the file
  20. permissions by setting the variable `vc-mistrust-permissions'.  Its
  21. value may be `t' (always mistrust the file permissions and check the
  22. master file), `nil' (always trust the file permissions), or a function
  23. of one argument which makes the decision.  The argument is the directory
  24. name of the `RCS' or `SCCS' subdirectory.  A non-`nil' value from the
  25. function says to mistrust the file permissions.  If you find that the
  26. file permissions of work files are changed erroneously, set
  27. `vc-mistrust-permissions' to `t'.  Then VC always checks the master
  28. file to determine the file's status.
  29.    You can specify additional directories to search for version control
  30. programs by setting the variable `vc-path'.  These directories are
  31. searched before the usual search path.  But the proper files are usually
  32. found automatically.
  33. File: emacs,  Node: Log Entries,  Next: Change Logs and VC,  Prev: Variables for Check-in/out,  Up: Version Control
  34. Log Entries
  35. -----------
  36.    When you're editing an initial comment or log entry for inclusion in
  37. a master file, finish your entry by typing `C-c C-c'.
  38. `C-c C-c'
  39.      Finish the comment edit normally (`vc-finish-logentry').  This
  40.      finishes check-in.
  41.    To abort check-in, just *don't* type `C-c C-c' in that buffer.  You
  42. can switch buffers and do other editing.  As long as you don't try to
  43. check in another file, the entry you were editing remains in its
  44. buffer, and you can go back to that buffer at any time to complete the
  45. check-in.
  46.    If you change several source files for the same reason, it is often
  47. convenient to specify the same log entry for many of the files.  To do
  48. this, use the history of previous log entries.  The commands `M-n',
  49. `M-p', `M-s' and `M-r' for doing this work just like the minibuffer
  50. history commands (except that these versions are used outside the
  51. minibuffer).
  52.    Each time you check in a file, the log entry buffer is put into VC
  53. Log mode, which involves running two hooks: `text-mode-hook' and
  54. `vc-log-mode-hook'.  *Note Hooks::.
  55. File: emacs,  Node: Change Logs and VC,  Next: Old Versions,  Prev: Log Entries,  Up: Version Control
  56. Change Logs and VC
  57. ------------------
  58.    If you use RCS for a program and also maintain a change log file for
  59. it (*note Change Log::.), you can generate change log entries
  60. automatically from the version control log entries:
  61. `C-x v a'
  62.      Visit the current directory's change log file and create new
  63.      entries for versions checked in since the most recent entry in the
  64.      change log file (`vc-update-change-log').
  65.      This command works with RCS only; it does not work with SCCS.
  66.    For example, suppose the first line of `ChangeLog' is dated 10 April
  67. 1992, and that the only check-in since then was by Nathaniel Bowditch
  68. to `rcs2log' on 8 May 1992 with log text `Ignore log messages that
  69. start with `#'.'.  Then `C-x v a' visits `ChangeLog' and inserts text
  70. like this:
  71.      Fri May  8 21:45:00 1992  Nathaniel Bowditch  <nat@apn.org>
  72.      
  73.              * rcs2log: Ignore log messages that start with `#'.
  74. You can then edit the new change log entry further as you wish.
  75.    Normally, the log entry for file `foo' is displayed as `* foo: TEXT
  76. OF LOG ENTRY'.  The `:' after `foo' is omitted if the text of the log
  77. entry starts with `(FUNCTIONNAME): '.  For example, if the log entry
  78. for `vc.el' is `(vc-do-command): Check call-process status.', then the
  79. text in `ChangeLog' looks like this:
  80.      Wed May  6 10:53:00 1992  Nathaniel Bowditch  <nat@apn.org>
  81.      
  82.              * vc.el (vc-do-command): Check call-process status.
  83.    When `C-x v a' adds several change log entries at once, it groups
  84. related log entries together if they all are checked in by the same
  85. author at nearly the same time.  If the log entries for several such
  86. files all have the same text, it coalesces them into a single entry.
  87. For example, suppose the most recent checkins have the following log
  88. entries:
  89. * For `vc.texinfo': `Fix expansion typos.'
  90. * For `vc.el': `Don't call expand-file-name.'
  91. * For `vc-hooks.el': `Don't call expand-file-name.'
  92. They appear like this in `ChangeLog':
  93.      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  <nat@apn.org>
  94.      
  95.              * vc.texinfo: Fix expansion typos.
  96.      
  97.              * vc.el, vc-hooks.el: Don't call expand-file-name.
  98.    Normally, `C-x v a' separates log entries by a blank line, but you
  99. can mark several related log entries to be clumped together (without an
  100. intervening blank line) by starting the text of each related log entry
  101. with a label of the form `{CLUMPNAME} '.  The label itself is not
  102. copied to `ChangeLog'.  For example, suppose the log entries are:
  103. * For `vc.texinfo': `{expand} Fix expansion typos.'
  104. * For `vc.el': `{expand} Don't call expand-file-name.'
  105. * For `vc-hooks.el': `{expand} Don't call expand-file-name.'
  106. Then the text in `ChangeLog' looks like this:
  107.      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  <nat@apn.org>
  108.      
  109.              * vc.texinfo: Fix expansion typos.
  110.              * vc.el, vc-hooks.el: Don't call expand-file-name.
  111.    A log entry whose text begins with `#' is not copied to `ChangeLog'.
  112. For example, if you merely fix some misspellings in comments, you can
  113. log the change with an entry beginning with `#' to avoid putting such
  114. trivia into `ChangeLog'.
  115. File: emacs,  Node: Old Versions,  Next: VC Status,  Prev: Change Logs and VC,  Up: Version Control
  116. Examining And Comparing Old Versions
  117. ------------------------------------
  118. `C-x v ~ VERSION RET'
  119.      Examine version VERSION of the visited file, in a buffer of its
  120.      own (`vc-version-other-window').
  121. `C-x v ='
  122.      Compare the current buffer contents with the latest checked-in
  123.      version of the file.
  124. `C-u C-x v = FILE RET OLDVERS RET NEWVERS RET'
  125.      Compare the specified two versions of FILE.
  126.    You can examine any version of a file by first visiting it, and then
  127. using `C-x v ~ VERSION RET' (`vc-version-other-window').  This puts the
  128. text of version VERSION in a file named `FILENAME.~VERSION~', then
  129. visits it in a separate window.
  130.    To compare two versions of a file, use the command `C-x v ='
  131. (`vc-diff').  Plain `C-x v =' compares the current buffer contents
  132. (saving them in the file if necessary) with the last checked-in version
  133. of the file.  `C-u C-x v =', with a numeric argument, reads a file name
  134. and two version numbers, then compares those versions of the specified
  135. file.
  136.    If you supply a directory name instead of the name of a work file,
  137. this command compares the two specified versions of all registered files
  138. in that directory and its subdirectories.  You can also specify a
  139. snapshot name (*note Snapshots::.) instead of one or both version
  140. numbers.
  141.    You can specify a checked-in version by its number; an empty input
  142. specifies the current contents of the work file (which may be different
  143. from all the checked-in versions).
  144.    This command works by running the `diff' utility, getting the
  145. options from the variable `diff-switches'.  It displays the output in a
  146. special buffer in another window.  Unlike the `M-x diff' command, `C-x
  147. v =' does not try to find the changes in the old and new versions.
  148. This is because one or both versions normally do not exist as files.
  149. They exist only in the records of the master file.  *Note Comparing
  150. Files::, for more information about `M-x diff'.
  151. File: emacs,  Node: VC Status,  Next: Renaming and VC,  Prev: Old Versions,  Up: Version Control
  152. VC Status Commands
  153. ------------------
  154.    To view the detailed version control status and history of a file,
  155. type `C-x v l' (`vc-print-log').  It displays the history of changes to
  156. the current file, including the text of the log entries.  The output
  157. appears in a separate window.
  158.    When you are working on a large program, it's often useful to find
  159. all the files that are currently locked, or all the files maintained in
  160. version control at all.  You can use `C-x v d' (`vc-directory') to show
  161. all the locked files in or beneath the current directory.  This
  162. includes all files that are locked by any user.  `C-u C-x v d' lists
  163. all files in or beneath the current directory that are maintained with
  164. version control.
  165.    The list of files is displayed as a buffer that uses an augmented
  166. Dired mode.  The names of the users locking various files are shown (in
  167. parentheses) in place of the owner and group.  All the normal Dired
  168. commands work in this buffer.  Most interactive VC commands work also,
  169. and apply to the file name on the current line.
  170.    The `C-x v v' command (`vc-next-action'), when used in the augmented
  171. Dired buffer, operates on all the marked files (or the file on the
  172. current line).  If it operates on more than one file, it handles each
  173. file according to its current state; thus, it may check out one file
  174. and check in another (because it is already checked out).  If it has to
  175. check in any files, it reads a single log entry, then uses that text
  176. for all the files being checked in.  This can be convenient for
  177. registering or checking in several files at once, as part of the same
  178. change.
  179. File: emacs,  Node: Renaming and VC,  Next: Snapshots,  Prev: VC Status,  Up: Version Control
  180. Renaming VC Work Files and Master Files
  181. ---------------------------------------
  182.    When you rename a registered file, you must also rename its master
  183. file correspondingly to get proper results.  Use `vc-rename-file' to
  184. rename the source file as you specify, and rename its master file
  185. accordingly.  It also updates any snapshots (*note Snapshots::.) that
  186. mention the file, so that they use the new name; despite this, the
  187. snapshot thus modified may not completely work (*note Snapshot
  188. Caveats::.).
  189.    You cannot use `vc-rename-file' on a file that is locked by someone
  190. else.
  191. File: emacs,  Node: Snapshots,  Next: Version Headers,  Prev: Renaming and VC,  Up: Version Control
  192. Snapshots
  193. ---------
  194.    A "snapshot" is a named set of file versions (one for each
  195. registered file) that you can treat as a unit.  One important kind of
  196. snapshot is a "release", a (theoretically) stable version of the system
  197. that is ready for distribution to users.
  198. * Menu:
  199. * Making Snapshots::        The snapshot facilities.
  200. * Snapshot Caveats::        Things to be careful of when using snapshots.
  201. File: emacs,  Node: Making Snapshots,  Next: Snapshot Caveats,  Up: Snapshots
  202. Making and Using Snapshots
  203. ..........................
  204.    There are two basic commands for snapshots; one makes a snapshot
  205. with a given name, the other retrieves a named snapshot.
  206. `C-x v s NAME RET'
  207.      Define the last saved versions of every registered file in or
  208.      under the current directory as a snapshot named NAME
  209.      (`vc-create-snapshot').
  210. `C-x v r NAME RET'
  211.      Check out all registered files at or below the current directory
  212.      level using whatever versions correspond to the snapshot NAME
  213.      (`vc-retrieve-snapshot').
  214.      This command reports an error if any files are locked at or below
  215.      the current directory, without changing anything; this is to avoid
  216.      overwriting work in progress.
  217.    A snapshot uses a very small amount of resources--just enough to
  218. record the list of file names and which version belongs to the
  219. snapshot.  Thus, you need not hesitate to create snapshots whenever
  220. they are useful.
  221.    You can give a snapshot name as an argument to `C-x v =' or `C-x v
  222. ~' (*note Old Versions::.).  Thus, you can use it to compare a snapshot
  223. against the current files, or two snapshots against each other, or a
  224. snapshot against a named version.
  225. File: emacs,  Node: Snapshot Caveats,  Prev: Making Snapshots,  Up: Snapshots
  226. Snapshot Caveats
  227. ................
  228.    VC's snapshot facilities are modeled on RCS's named-configuration
  229. support.  They use RCS's native facilities for this, so under VC
  230. snapshots made using RCS are visible even when you bypass VC.
  231.    For SCCS, VC implements snapshots itself.  The files it uses contain
  232. name/file/version-number triples.  These snapshots are visible only
  233. through VC.
  234.    A snapshot is a set of checked-in versions.  So make sure that all
  235. the files are checked in and not locked when you make a snapshot.
  236.    File renaming and deletion can create some difficulties with
  237. snapshots.  This is not a VC-specific problem, but a general design
  238. issue in version control systems that no one has solved very well yet.
  239.    If you rename a registered file, you need to rename its master along
  240. with it (the command `vc-rename-file' does this automatically).  If you
  241. are using SCCS, you must also update the records of the snapshot, to
  242. mention the file by its new name (`vc-rename-file' does this, too).  An
  243. old snapshot that refers to a master file that no longer exists under
  244. the recorded name is invalid; VC can no longer retrieve it.  It would
  245. be beyond the scope of this manual to explain enough about RCS and SCCS
  246. to explain how to update the snapshots by hand.
  247.    Using `vc-rename-file' makes the snapshot remain valid for
  248. retrieval, but it does not solve all problems.  For example, some of the
  249. files in the program probably refer to others by name.  At the very
  250. least, the makefile probably mentions the file that you renamed.  If you
  251. retrieve an old snapshot, the renamed file is retrieved under its new
  252. name, which is not the name that the makefile expects.  So the program
  253. won't really work as retrieved.
  254. File: emacs,  Node: Version Headers,  Prev: Snapshots,  Up: Version Control
  255. Inserting Version Control Headers
  256. ---------------------------------
  257.    Sometimes it is convenient to put version identification strings
  258. directly into working files.  Certain special strings called "version
  259. headers" are replaced in each successive version by the number of that
  260. version.
  261.    You can use the `C-x v h' command (`vc-insert-headers') to insert a
  262. suitable header string.
  263. `C-x v h'
  264.      Insert headers in a file for use with your version-control system.
  265.    The default header string is `$Id$' for RCS and `%W%' for SCCS.  You
  266. can specify other headers to insert by setting the variable
  267. `vc-header-alist'.  Its value is a list of elements of the form
  268. `(PROGRAM . STRING)' where PROGRAM is `RCS' or `SCCS' and STRING is the
  269. string to use.
  270.    Instead of a single string, you can specify a list of strings; then
  271. each string in the list is inserted as a separate header on a line of
  272. its own.
  273.    It is often necessary to use "superfluous" backslashes when writing
  274. the strings that you put in this variable.  This is to prevent the
  275. string in the constant from being interpreted as a header itself if the
  276. Emacs Lisp file containing it is maintained with version control.
  277.    Each header is inserted surrounded by tabs, inside comment
  278. delimiters, on a new line at the start of the buffer.  Normally the
  279. ordinary comment start and comment end strings of the current mode are
  280. used, but for certain modes, there are special comment delimiters for
  281. this purpose; the variable `vc-comment-alist' specifies them.  Each
  282. element of this list has the form `(MODE STARTER ENDER)'.
  283.    The variable `vc-static-header-alist' specifies further strings to
  284. add based on the name of the buffer.  Its value should be a list of
  285. elements of the form `(REGEXP . FORMAT)'.  Whenever REGEXP matches the
  286. buffer name, FORMAT is inserted as part of the header.  A header line
  287. is inserted for each element that matches the buffer name, and for each
  288. string specified by `vc-header-alist'.  The header line is made by
  289. processing the string from `vc-header-alist' with the format taken from
  290. the element.  The default value for `vc-static-header-alist' is as
  291. follows:
  292.      (("\\.c$" .
  293.        "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
  294.      #endif /* lint */\n"))
  295. It specifies insertion of text of this form:
  296.      #ifndef lint
  297.      static char vcid[] = "STRING";
  298.      #endif /* lint */
  299. Note that the text above starts with a blank line.
  300.    If you use more than one version header in a file, put them close
  301. together in the file.  The mechanism in `revert-buffer' that preserves
  302. markers may fail for markers positioned between two version headers.
  303. File: emacs,  Node: ListDir,  Next: Comparing Files,  Prev: Version Control,  Up: Files
  304. Listing a File Directory
  305. ========================
  306.    The file system groups files into "directories".  A "directory
  307. listing" is a list of all the files in a directory.  Emacs provides
  308. directory listings in brief format (file names only) and verbose format
  309. (sizes, dates, and authors included).  (There is also a directory
  310. browser called Dired; *Note Dired::.)
  311. `C-x C-d DIR-OR-PATTERN'
  312.      Print a brief directory listing (`list-directory').
  313. `C-u C-x C-d DIR-OR-PATTERN'
  314.      Print a verbose directory listing.
  315.    The command to display a directory listing is `C-x C-d'
  316. (`list-directory').  It reads using the minibuffer a file name which is
  317. either a directory to be listed or a wildcard-containing pattern for
  318. the files to be listed.  For example,
  319.      C-x C-d /u2/emacs/etc RET
  320. lists all the files in directory `/u2/emacs/etc'.  Here is an example
  321. of specifying a file name pattern:
  322.      C-x C-d /u2/emacs/src/*.c RET
  323.    Normally, `C-x C-d' prints a brief directory listing containing just
  324. file names.  A numeric argument (regardless of value) tells it to print
  325. a verbose listing (like `ls -l').
  326.    The text of a directory listing is obtained by running `ls' in an
  327. inferior process.  Two Emacs variables control the switches passed to
  328. `ls': `list-directory-brief-switches' is a string giving the switches
  329. to use in brief listings (`"-CF"' by default), and
  330. `list-directory-verbose-switches' is a string giving the switches to
  331. use in a verbose listing (`"-l"' by default).
  332. File: emacs,  Node: Comparing Files,  Next: Misc File Ops,  Prev: ListDir,  Up: Files
  333. Comparing Files
  334. ===============
  335.    The command `M-x diff' compares two files, displaying the
  336. differences in an Emacs buffer named `*Diff*'.  It works by running the
  337. `diff' program, using options taken from the variable `diff-switches',
  338. whose value should be a string.
  339.    The buffer `*Diff*' has Compilation mode as its major mode, so you
  340. can use `C-x `' to visit successive changed locations in the two source
  341. files.  You can also move to a particular hunk of changes and type `C-c
  342. C-c', or click `Mouse-2' on it, to move to the corresponding source
  343. location.  You can also use the other special commands of Compilation
  344. mode: SPC and DEL for scrolling, and `M-p' and `M-n' for cursor motion.
  345. *Note Compilation::.
  346.    The command `M-x diff-backup' compares a specified file with its most
  347. recent backup.  If you specify the name of a backup file, `diff-backup'
  348. compares it with the source file that it is a backup of.
  349.    The command `M-x compare-windows' compares the text in the current
  350. window with that in the next window.  Comparison starts at point in each
  351. window.  Point moves forward in each window, a character at a time in
  352. each window, until the next characters in the two windows are
  353. different.  Then the command is finished.  For more information about
  354. windows in Emacs, *Note Windows::.
  355.    With a numeric argument, `compare-windows' ignores changes in
  356. whitespace.  If the variable `compare-ignore-case' is non-`nil', it
  357. ignores differences in case as well.
  358.    See also *Note Emerge::, for convenient facilities for merging two
  359. similar files.
  360. File: emacs,  Node: Misc File Ops,  Prev: Comparing Files,  Up: Files
  361. Miscellaneous File Operations
  362. =============================
  363.    Emacs has commands for performing many other operations on files.
  364. All operate on one file; they do not accept wild card file names.
  365.    `M-x view-file' allows you to scan or read a file by sequential
  366. screenfuls.  It reads a file name argument using the minibuffer.  After
  367. reading the file into an Emacs buffer, `view-file' displays the
  368. beginning.  You can then type SPC to scroll forward one windowful, or
  369. DEL to scroll backward.  Various other commands are provided for moving
  370. around in the file, but none for changing it; type `C-h' while viewing
  371. for a list of them.  They are mostly the same as normal Emacs cursor
  372. motion commands.  To exit from viewing, type `C-c'.  The commands for
  373. viewing are defined by a special major mode called View mode.
  374.    A related command, `M-x view-buffer', views a buffer already present
  375. in Emacs.  *Note Misc Buffer::.
  376.    `M-x insert-file' inserts a copy of the contents of the specified
  377. file into the current buffer at point, leaving point unchanged before
  378. the contents and the mark after them.
  379.    `M-x write-region' is the inverse of `M-x insert-file'; it copies
  380. the contents of the region into the specified file.  `M-x
  381. append-to-file' adds the text of the region to the end of the specified
  382. file.  *Note Accumulating Text::.
  383.    `M-x delete-file' deletes the specified file, like the `rm' command
  384. in the shell.  If you are deleting many files in one directory, it may
  385. be more convenient to use Dired (*note Dired::.).
  386.    `M-x rename-file' reads two file names OLD and NEW using the
  387. minibuffer, then renames file OLD as NEW.  If a file named NEW already
  388. exists, you must confirm with `yes' or renaming is not done; this is
  389. because renaming causes the old meaning of the name NEW to be lost.  If
  390. OLD and NEW are on different file systems, the file OLD is copied and
  391. deleted.
  392.    The similar command `M-x add-name-to-file' is used to add an
  393. additional name to an existing file without removing its old name.  The
  394. new name must belong on the same file system that the file is on.
  395.    `M-x copy-file' reads the file OLD and writes a new file named NEW
  396. with the same contents.  Confirmation is required if a file named NEW
  397. already exists, because copying has the consequence of overwriting the
  398. old contents of the file NEW.
  399.    `M-x make-symbolic-link' reads two file names OLD and LINKNAME, then
  400. creates a symbolic link named LINKNAME and pointing at OLD.  The effect
  401. is that future attempts to open file LINKNAME will refer to whatever
  402. file is named OLD at the time the opening is done, or will get an error
  403. if the name OLD is not in use at that time.  This command does not
  404. expand the argument FILENAME, so that it allows you to specify a
  405. relative name as the target of the link.
  406.    Confirmation is required when creating the link if LINKNAME is in
  407. use.  Note that not all systems support symbolic links.
  408. File: emacs,  Node: Buffers,  Next: Windows,  Prev: Files,  Up: Top
  409. Using Multiple Buffers
  410. **********************
  411.    The text you are editing in Emacs resides in an object called a
  412. "buffer".  Each time you visit a file, a buffer is created to hold the
  413. file's text.  Each time you invoke Dired, a buffer is created to hold
  414. the directory listing.  If you send a message with `C-x m', a buffer
  415. named `*mail*' is used to hold the text of the message.  When you ask
  416. for a command's documentation, that appears in a buffer called `*Help*'.
  417.    At any time, one and only one buffer is "selected".  It is also
  418. called the "current buffer".  Often we say that a command operates on
  419. "the buffer" as if there were only one; but really this means that the
  420. command operates on the selected buffer (most commands do).
  421.    When Emacs has multiple windows, each window has a chosen buffer
  422. which is displayed there, but at any time only one of the windows is
  423. selected and its chosen buffer is the selected buffer.  Each window's
  424. mode line displays the name of the buffer that the window is displaying
  425. (*note Windows::.).
  426.    Each buffer has a name, which can be of any length, and you can
  427. select any buffer by giving its name.  Most buffers are made by
  428. visiting files, and their names are derived from the files' names.  But
  429. you can also create an empty buffer with any name you want.  A newly
  430. started Emacs has a buffer named `*scratch*' which can be used for
  431. evaluating Lisp expressions in Emacs.  The distinction between upper
  432. and lower case matters in buffer names.
  433.    Each buffer records individually what file it is visiting, whether
  434. it is modified, and what major mode and minor modes are in effect in it
  435. (*note Major Modes::.).  Any Emacs variable can be made "local to" a
  436. particular buffer, meaning its value in that buffer can be different
  437. from the value in other buffers.  *Note Locals::.
  438. * Menu:
  439. * Select Buffer::      Creating a new buffer or reselecting an old one.
  440. * List Buffers::       Getting a list of buffers that exist.
  441. * Misc Buffer::           Renaming; changing read-onliness; copying text.
  442. * Kill Buffer::           Killing buffers you no longer need.
  443. * Several Buffers::    How to go through the list of all buffers
  444.              and operate variously on several of them.
  445. File: emacs,  Node: Select Buffer,  Next: List Buffers,  Up: Buffers
  446. Creating and Selecting Buffers
  447. ==============================
  448. `C-x b BUFFER RET'
  449.      Select or create a buffer named BUFFER (`switch-to-buffer').
  450. `C-x 4 b BUFFER RET'
  451.      Similar, but select BUFFER in another window
  452.      (`switch-to-buffer-other-window').
  453. `C-x 5 b BUFFER RET'
  454.      Similar, but select BUFFER in a separate frame
  455.      (`switch-to-buffer-other-frame').
  456.    To select the buffer named BUFNAME, type `C-x b BUFNAME RET'.  This
  457. runs the command `switch-to-buffer' with argument BUFNAME.  You can use
  458. completion on an abbreviation for the buffer name you want (*note
  459. Completion::.).  An empty argument to `C-x b' specifies the most
  460. recently selected buffer that is not displayed in any window.
  461.    Most buffers are created by visiting files, or by Emacs commands that
  462. want to display some text, but you can also create a buffer explicitly
  463. by typing `C-x b BUFNAME RET'.  This makes a new, empty buffer which is
  464. not visiting any file, and selects it for editing.  Such buffers are
  465. used for making notes to yourself.  If you try to save one, you are
  466. asked for the file name to use.  The new buffer's major mode is
  467. determined by the value of `default-major-mode' (*note Major Modes::.).
  468.    Note that `C-x C-f', and any other command for visiting a file, can
  469. also be used to switch to an existing file-visiting buffer.  *Note
  470. Visiting::.
  471. File: emacs,  Node: List Buffers,  Next: Misc Buffer,  Prev: Select Buffer,  Up: Buffers
  472. Listing Existing Buffers
  473. ========================
  474. `C-x C-b'
  475.      List the existing buffers (`list-buffers').
  476.    To print a list of all the buffers that exist, type `C-x C-b'.  Each
  477. line in the list shows one buffer's name, major mode and visited file.
  478. The buffers are listed in the order, most recently visited first.
  479.    `*' at the beginning of a line indicates the buffer is "modified".
  480. If several buffers are modified, it may be time to save some with `C-x
  481. s' (*note Saving::.).  `%' indicates a read-only buffer.  `.' marks the
  482. selected buffer.  Here is an example of a buffer list:
  483.       MR Buffer         Size  Mode           File
  484.       -- ------         ----  ----           ----
  485.      .*  emacs.tex      383402 Texinfo       /u2/emacs/man/emacs.tex
  486.          *Help*         1287  Fundamental
  487.          files.el       23076 Emacs-Lisp     /u2/emacs/lisp/files.el
  488.        % RMAIL          64042 RMAIL          /u/rms/RMAIL
  489.       *% man            747   Dired          /u2/emacs/man/
  490.          net.emacs      343885 Fundamental   /u/rms/net.emacs
  491.          fileio.c       27691 C              /u2/emacs/src/fileio.c
  492.          NEWS           67340 Text           /u2/emacs/etc/NEWS
  493.          *scratch*       0     Lisp Interaction
  494. Note that the buffer `*Help*' was made by a help request; it is not
  495. visiting any file.  The buffer `man' was made by Dired on the directory
  496. `/u2/emacs/man/'.
  497. File: emacs,  Node: Misc Buffer,  Next: Kill Buffer,  Prev: List Buffers,  Up: Buffers
  498. Miscellaneous Buffer Operations
  499. ===============================
  500. `C-x C-q'
  501.      Toggle read-only status of buffer (`vc-toggle-read-only').
  502. `M-x rename-buffer RET NAME RET'
  503.      Change the name of the current buffer.
  504. `M-x rename-uniquely'
  505.      Rename the current buffer by adding `<NUMBER>' to the end.
  506. `M-x view-buffer RET BUFFER RET'
  507.      Scroll through buffer BUFFER.
  508.    A buffer can be "read-only", which means that commands to change its
  509. contents are not allowed.  The mode line indicates read-only buffers
  510. with `%%' or `%*' near the left margin.  Read-only buffers are usually
  511. made by subsystems such as Dired and Rmail that have special commands
  512. to operate on the text; also by visiting a file whose access control
  513. says you cannot write it.
  514.    If you wish to make changes in a read-only buffer, use the command
  515. `C-x C-q' (`vc-toggle-read-only').  It makes a read-only buffer
  516. writable, and makes a writable buffer read-only.  In most cases, this
  517. works by setting the variable `buffer-read-only', which has a local
  518. value in each buffer and makes the buffer read-only if its value is
  519. non-`nil'.  If the file is maintained with version control, `C-x C-q'
  520. works through the version control system to change the read-only status
  521. of the file as well as the buffer.
  522.    `M-x rename-buffer' changes the name of the current buffer.  Specify
  523. the new name as a minibuffer argument.  There is no default.  If you
  524. specify a name that is in use for some other buffer, an error happens
  525. and no renaming is done.
  526.    `M-x rename-uniquely' renames the current buffer to a similar name
  527. with a numeric suffix added to make it both different and unique.  This
  528. command does not need an argument.  It is useful for creating multiple
  529. shell buffers: if you rename the `*Shell*' buffer, then do `M-x shell'
  530. again, it makes a new shell buffer named `*Shell*'; meanwhile, the old
  531. shell buffer continues to exist under its new name.  This method is
  532. also good for mail buffers, compilation buffers, and most Emacs
  533. features that create special buffers with particular names.
  534.    `M-x view-buffer' is much like `M-x view-file' (*note Misc File
  535. Ops::.) except that it examines an already existing Emacs buffer.  View
  536. mode provides commands for scrolling through the buffer conveniently
  537. but not for changing it.  When you exit View mode, the value of point
  538. that resulted from your perusal remains in effect.
  539.    The commands `M-x append-to-buffer' and `M-x insert-buffer' can be
  540. used to copy text from one buffer to another.  *Note Accumulating
  541. Text::.
  542. File: emacs,  Node: Kill Buffer,  Next: Several Buffers,  Prev: Misc Buffer,  Up: Buffers
  543. Killing Buffers
  544. ===============
  545.    If you continue an Emacs session for a while, you may accumulate a
  546. large number of buffers.  You may then find it convenient to "kill" the
  547. buffers you no longer need.  On most operating systems, killing a
  548. buffer releases its space back to the operating system so that other
  549. programs can use it.  Here are some commands for killing buffers:
  550. `C-x k BUFNAME RET'
  551.      Kill buffer BUFNAME (`kill-buffer').
  552. `M-x kill-some-buffers'
  553.      Offer to kill each buffer, one by one.
  554.    `C-x k' (`kill-buffer') kills one buffer, whose name you specify in
  555. the minibuffer.  The default, used if you type just RET in the
  556. minibuffer, is to kill the current buffer.  If you kill the current
  557. buffer, another buffer is selected; one that has been selected recently
  558. but does not appear in any window now.  If you ask to kill a
  559. file-visiting buffer that is modified (has unsaved editing), then you
  560. must confirm with `yes' before the buffer is killed.
  561.    The command `M-x kill-some-buffers' asks about each buffer, one by
  562. one.  An answer of `y' means to kill the buffer.  Killing the current
  563. buffer or a buffer containing unsaved changes selects a new buffer or
  564. asks for confirmation just like `kill-buffer'.
  565.    The buffer menu feature (*note Several Buffers::.) is also convenient
  566. for killing various buffers.
  567.    If you want to do something special every time a buffer is killed,
  568. you can add hook functions to the hook `kill-buffer-hook' (*note
  569. Hooks::.).
  570. File: emacs,  Node: Several Buffers,  Prev: Kill Buffer,  Up: Buffers
  571. Operating on Several Buffers
  572. ============================
  573.    The "buffer-menu" facility is like a "Dired for buffers"; it allows
  574. you to request operations on various Emacs buffers by editing an Emacs
  575. buffer containing a list of them.  You can save buffers, kill them
  576. (here called "deleting" them, for consistency with Dired), or display
  577. them.
  578. `M-x buffer-menu'
  579.      Begin editing a buffer listing all Emacs buffers.
  580.    The command `buffer-menu' writes a list of all Emacs buffers into
  581. the buffer `*Buffer List*', and selects that buffer in Buffer Menu
  582. mode.  The buffer is read-only, and can be changed only through the
  583. special commands described in this section.  The usual Emacs cursor
  584. motion commands can be used in the `*Buffer List*' buffer.  The
  585. following commands apply to the buffer described on the current line.
  586.      Request to delete (kill) the buffer, then move down.  The request
  587.      shows as a `D' on the line, before the buffer name.  Requested
  588.      deletions take place when you type the `x' command.
  589. `C-d'
  590.      Like `d' but move up afterwards instead of down.
  591.      Request to save the buffer.  The request shows as an `S' on the
  592.      line.  Requested saves take place when you type the `x' command.
  593.      You may request both saving and deletion for the same buffer.
  594.      Perform previously requested deletions and saves.
  595.      Remove any request made for the current line, and move down.
  596. `DEL'
  597.      Move to previous line and remove any request made for that line.
  598.    The `d', `s' and `u' commands to add or remove flags also move down
  599. a line.  They accept a numeric argument as a repeat count.
  600.    These commands operate immediately on the buffer listed on the
  601. current line:
  602.      Mark the buffer "unmodified".  The command `~' does this
  603.      immediately when you type it.
  604.      Toggle the buffer's read-only flag.  The command `%' does this
  605.      immediately when you type it.
  606.      Visit the buffer as a tags table.  *Note Select Tags Table::.
  607.    There are also commands to select another buffer or buffers:
  608.      Quit the buffer menu--immediately display the most recent formerly
  609.      visible buffer in its place.
  610.      Immediately select this line's buffer in place of the `*Buffer
  611.      List*' buffer.
  612.      Immediately select this line's buffer in another window as if by
  613.      `C-x 4 b', leaving `*Buffer List*' visible.
  614. `C-o'
  615.      Immediately display this line's buffer in another window, but don't
  616.      select the window.
  617.      Immediately select this line's buffer in a full-screen window.
  618.      Immediately set up two windows, with this line's buffer in one,
  619.      and the previously selected buffer (aside from the buffer `*Buffer
  620.      List*') in the other.
  621.      Mark this line's buffer to be displayed in another window if the
  622.      `q' command is used.  The request shows as a `>' at the beginning
  623.      of the line.  (A single buffer may not have both a delete request
  624.      and a display request.)
  625.      Immediately select this line's buffer, and also display in other
  626.      windows any buffers previously marked with the `m' command.  If
  627.      you have not marked any buffers, this command is equivalent to `1'.
  628.    All that `buffer-menu' does directly is create and select a suitable
  629. buffer, and turn on Buffer Menu mode.  Everything else described above
  630. is implemented by the special commands provided in Buffer Menu mode.
  631. One consequence of this is that you can switch from the `*Buffer List*'
  632. buffer to another Emacs buffer, and edit there.  You can reselect the
  633. `buffer-menu' buffer later, to perform the operations already
  634. requested, or you can kill it, or pay no further attention to it.
  635.    The only difference between `buffer-menu' and `list-buffers' is that
  636. `buffer-menu' selects the `*Buffer List*' buffer and `list-buffers'
  637. does not.  If you run `list-buffers' (that is, type `C-x C-b') and
  638. select the buffer list manually, you can use all of the commands
  639. described here.
  640.    The buffer `*Buffer List*' is not updated automatically when buffers
  641. are created and killed; its contents are just text.  If you have
  642. created, deleted or renamed buffers, the way to update `*Buffer List*'
  643. to show what you have done is to type `g' (`revert-buffer') or repeat
  644. the `buffer-menu' command.
  645. File: emacs,  Node: Windows,  Next: Frames,  Prev: Buffers,  Up: Top
  646. Multiple Windows
  647. ****************
  648.    Emacs can split a frame into two or many windows.  Multiple windows
  649. can display parts of different buffers, or different parts of one
  650. buffer.  Multiple frames always imply multiple windows, because each
  651. frame has its own set of windows.  Each window belongs to one and only
  652. one frame.
  653. * Menu:
  654. * Basic Window::       Introduction to Emacs windows.
  655. * Split Window::       New windows are made by splitting existing windows.
  656. * Other Window::       Moving to another window or doing something to it.
  657. * Pop Up Window::      Finding a file or buffer in another window.
  658. * Change Window::      Deleting windows and changing their sizes.
  659. File: emacs,  Node: Basic Window,  Next: Split Window,  Up: Windows
  660. Concepts of Emacs Windows
  661. =========================
  662.    Each Emacs window displays one Emacs buffer at any time.  A single
  663. buffer may appear in more than one window; if it does, any changes in
  664. its text are displayed in all the windows where it appears.  But the
  665. windows showing the same buffer can show different parts of it, because
  666. each window has its own value of point.
  667.    At any time, one of the windows is the "selected window"; the buffer
  668. this window is displaying is the current buffer.  The terminal's cursor
  669. shows the location of point in this window.  Each other window has a
  670. location of point as well, but since the terminal has only one cursor
  671. there is no way to show where those locations are.  When you make
  672. multiple frames, each frame has a cursor which appears in the frame's
  673. selected window.  The cursor in the selected frame is solid; the cursor
  674. in other frames is a hollow box.
  675.    Commands to move point affect the value of point for the selected
  676. Emacs window only.  They do not change the value of point in any other
  677. Emacs window, even one showing the same buffer.  The same is true for
  678. commands such as `C-x b' to change the selected buffer in the selected
  679. window; they do not affect other windows at all.  However, there are
  680. other commands such as `C-x 4 b' that select a different window and
  681. switch buffers in it.  Also, all commands that display information in a
  682. window, including (for example) `C-h f' (`describe-function') and `C-x
  683. C-b' (`list-buffers'), work by switching buffers in a nonselected window
  684. without affecting the selected window.
  685.    When multiple windows show the same buffer, they can have different
  686. regions, because they can have different values of point.  This means
  687. that in Transient Mark mode, each window highlights a different part of
  688. the buffer.  The part that is highlighted in the selected window is the
  689. region that editing commands use.
  690.    Each window has its own mode line, which displays the buffer name,
  691. modification status and major and minor modes of the buffer that is
  692. displayed in the window.  *Note Mode Line::, for full details on the
  693. mode line.
  694. File: emacs,  Node: Split Window,  Next: Other Window,  Prev: Basic Window,  Up: Windows
  695. Splitting Windows
  696. =================
  697. `C-x 2'
  698.      Split the selected window into two windows, one above the other
  699.      (`split-window-vertically').
  700. `C-x 3'
  701.      Split the selected window into two windows positioned side by side
  702.      (`split-window-horizontally').
  703. `C-Mouse-2'
  704.      In the mode line or scroll bar of a window, split that window.
  705.    The command `C-x 2' (`split-window-vertically') breaks the selected
  706. window into two windows, one above the other.  Both windows start out
  707. displaying the same buffer, with the same value of point.  By default
  708. the two windows each get half the height of the window that was split; a
  709. numeric argument specifies how many lines to give to the top window.
  710.    `C-x 3' (`split-window-horizontally') breaks the selected window
  711. into two side-by-side windows.  A numeric argument specifies how many
  712. columns to give the one on the left.  A line of vertical bars separates
  713. the two windows.  Windows that are not the full width of the screen
  714. have mode lines, but they are truncated; also, they do not always
  715. appear in inverse video, because the Emacs display routines have not
  716. been taught how to display a region of inverse video that is only part
  717. of a line on the screen.
  718.    You can split a window horizontally or vertically by clicking
  719. `C-Mouse-2' in the mode line or the scroll bar.  The line of splitting
  720. goes through the place where you click: if you click on the mode line,
  721. the new scroll bar goes above the spot; if you click in the scroll bar,
  722. the mode line of the split window is side by side with your click.
  723.    When a window is less than the full width, text lines too long to
  724. fit are frequent.  Continuing all those lines might be confusing.  The
  725. variable `truncate-partial-width-windows' can be set non-`nil' to force
  726. truncation in all windows less than the full width of the screen,
  727. independent of the buffer being displayed and its value for
  728. `truncate-lines'.  *Note Continuation Lines::.
  729.    Horizontal scrolling is often used in side-by-side windows.  *Note
  730. Display::.
  731.    If `split-window-keep-point' is non-nil, `C-x 2' tries to avoid
  732. shifting any text on the screen by putting point in whichever window
  733. happens to contain the screen line the cursor is already on.  The
  734. default is that `split-window-keep-point' is non-nil on slow terminals.
  735. File: emacs,  Node: Other Window,  Next: Pop Up Window,  Prev: Split Window,  Up: Windows
  736. Using Other Windows
  737. ===================
  738. `C-x o'
  739.      Select another window (`other-window').  That is `o', not zero.
  740. `C-M-v'
  741.      Scroll the next window (`scroll-other-window').
  742. `M-x compare-windows'
  743.      Find next place where the text in the selected window does not
  744.      match the text in the next window.
  745. `Mouse-1'
  746.      `Mouse-1', in a window's mode line, selects that window but does
  747.      not move point in it (`mouse-select-region').
  748.    To select a different window, click with `Mouse-1' on its mode line.
  749. With the keyboard, you can switch windows by typing `C-x o'
  750. (`other-window').  That is an `o', for `other', not a zero.  When there
  751. are more than two windows, this command moves through all the windows
  752. in a cyclic order, generally top to bottom and left to right.  After
  753. the rightmost and bottommost window, it goes back to the one at the
  754. upper left corner.  A numeric argument means to move several steps in
  755. the cyclic order of windows.  A negative argument moves around the
  756. cycle in the opposite order.  When the minibuffer is active, the
  757. minibuffer is the last window in the cycle; you can switch from the
  758. minibuffer window to one of the other windows, and later switch back and
  759. finish supplying the minibuffer argument that is requested.  *Note
  760. Minibuffer Edit::.
  761.    The usual scrolling commands (*note Display::.) apply to the selected
  762. window only, but there is one command to scroll the next window.
  763. `C-M-v' (`scroll-other-window') scrolls the window that `C-x o' would
  764. select.  It takes arguments, positive and negative, like `C-v'.  (In
  765. the minibuffer, `C-M-v' scrolls the window that contains the minibuffer
  766. help display, if any, rather than the next window in the standard
  767. cyclic order.)
  768.    The command `M-x compare-windows' lets you compare two files or
  769. buffers visible in two windows, by moving through them to the next
  770. mismatch.  *Note Comparing Files::, for details.
  771. File: emacs,  Node: Pop Up Window,  Next: Change Window,  Prev: Other Window,  Up: Windows
  772. Displaying in Another Window
  773. ============================
  774.    `C-x 4' is a prefix key for commands that select another window
  775. (splitting the window if there is only one) and select a buffer in that
  776. window.  Different `C-x 4' commands have different ways of finding the
  777. buffer to select.
  778. `C-x 4 b BUFNAME RET'
  779.      Select buffer BUFNAME in another window.  This runs
  780.      `switch-to-buffer-other-window'.
  781. `C-x 4 C-o BUFNAME RET'
  782.      Display buffer BUFNAME in another window, but don't select that
  783.      buffer or that window.  This runs `display-buffer'.
  784. `C-x 4 f FILENAME RET'
  785.      Visit file FILENAME and select its buffer in another window.  This
  786.      runs `find-file-other-window'.  *Note Visiting::.
  787. `C-x 4 d DIRECTORY RET'
  788.      Select a Dired buffer for directory DIRECTORY in another window.
  789.      This runs `dired-other-window'.  *Note Dired::.
  790. `C-x 4 m'
  791.      Start composing a mail message in another window.  This runs
  792.      `mail-other-window'; its same-window analogue is `C-x m' (*note
  793.      Sending Mail::.).
  794. `C-x 4 .'
  795.      Find a tag in the current tags table, in another window.  This runs
  796.      `find-tag-other-window', the multiple-window variant of `M-.'
  797.      (*note Tags::.).
  798. `C-x 4 r FILENAME RET'
  799.      Visit file FILENAME read-only, and select its buffer in another
  800.      window.  This runs `find-file-read-only-other-window'.  *Note
  801.      Visiting::.
  802. File: emacs,  Node: Change Window,  Prev: Pop Up Window,  Up: Windows
  803. Deleting and Rearranging Windows
  804. ================================
  805. `C-x 0'
  806.      Delete the selected window (`delete-window').  That is a zero.
  807. `C-x 1'
  808.      Delete all windows in the selected frame except the selected window
  809.      (`delete-other-windows').
  810. `C-x ^'
  811.      Make selected window taller (`enlarge-window').
  812. `C-x }'
  813.      Make selected window wider (`enlarge-window-horizontally').
  814. `Mouse-2'
  815.      `Mouse-2' in a window's mode line deletes all other windows in the
  816.      frame (`mouse-delete-other-windows').
  817. `Mouse-3'
  818.      `Mouse-3' in a window's mode line deletes that window
  819.      (`mouse-delete-window').
  820.    To delete a window, type `C-x 0' (`delete-window').  (That is a
  821. zero.)  The space occupied by the deleted window is given to an
  822. adjacent window (but not the minibuffer window, even if that is active
  823. at the time).  Once a window is deleted, its attributes are forgotten;
  824. only restoring a window configuration can bring it back.  Deleting the
  825. window has no effect on the buffer it used to display; the buffer
  826. continues to exist, and you can select it in any window with `C-x b'.
  827.    `C-x 1' (`delete-other-windows') is more powerful than `C-x 0'; it
  828. deletes all the windows except the selected one (and the minibuffer);
  829. the selected window expands to use the whole frame except for the echo
  830. area.
  831.    You can also delete a window by clicking on its mode line with
  832. `Mouse-2', and expand a window to full screen by clicking on its mode
  833. line with `Mouse-3'.
  834.    To readjust the division of space among vertically adjacent windows,
  835. use `C-x ^' (`enlarge-window').  It makes the currently selected window
  836. get one line bigger, or as many lines as is specified with a numeric
  837. argument.  With a negative argument, it makes the selected window
  838. smaller.  `C-x }' (`enlarge-window-horizontally') makes the selected
  839. window wider by the specified number of columns.  The extra screen
  840. space given to a window comes from one of its neighbors, if that is
  841. possible.  If this makes any window too small, it is deleted and its
  842. space is given to an adjacent window.  The minimum size is specified by
  843. the variables `window-min-height' and `window-min-width'.
  844.    *Note Minibuffer Edit::, for information about the Resize-Minibuffer
  845. mode, which automatically changes the size of the minibuffer window to
  846. fit the text in the minibuffer.
  847.