home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / emacs.i04 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  48.2 KB  |  1,127 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.47 from the
  2. input file emacs.tex.
  3.  
  4.    This file documents the GNU Emacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  15. General Public License" are included exactly as in the original, and
  16. provided that the entire resulting derived work is distributed under the
  17. terms of a permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that the sections entitled "The GNU Manifesto",
  22. "Distribution" and "GNU General Public License" may be included in a
  23. translation approved by the author instead of in the original English.
  24.  
  25. 
  26. File: emacs,  Node: Display Vars,  Prev: Selective Display,  Up: Display
  27.  
  28. Variables Controlling Display
  29. =============================
  30.  
  31.    This section contains information for customization only.  Beginning
  32. users should skip it.
  33.  
  34.    The variable `mode-line-inverse-video' controls whether the mode
  35. line is displayed in inverse video (assuming the terminal supports it);
  36. `nil' means don't do so.  *Note Mode Line::.
  37.  
  38.    If the variable `inverse-video' is non-`nil', Emacs attempts to
  39. invert all the lines of the display from what they normally are.
  40.  
  41.    If the variable `visible-bell' is non-`nil', Emacs attempts to make
  42. the whole screen blink when it would normally make an audible bell
  43. sound.  This variable has no effect if your terminal does not have a way
  44. to make the screen blink.
  45.  
  46.    When you reenter Emacs after suspending, Emacs normally clears the
  47. screen and redraws the entire display.  On some terminals with more
  48. than one page of memory, it is possible to arrange the termcap entry so
  49. that the `ti' and `te' strings (output to the terminal when Emacs is
  50. entered and exited, respectively) switch between pages of memory so as
  51. to use one page for Emacs and another page for other output.  Then you
  52. might want to set the variable `no-redraw-on-reenter' non-`nil' so that
  53. Emacs will assume, when resumed, that the screen page it is using still
  54. contains what Emacs last wrote there.
  55.  
  56.    The variable `echo-keystrokes' controls the echoing of
  57. multi-character keys; its value is the number of seconds of pause
  58. required to cause echoing to start, or zero meaning don't echo at all. 
  59. *Note Echo Area::.
  60.  
  61.    If the variable `ctl-arrow' is `nil', control characters in the
  62. buffer are displayed with octal escape sequences, all except newline and
  63. tab.  Altering the value of `ctl-arrow' makes it local to the current
  64. buffer; until that time, the default value is in effect.  The default is
  65. initially `t'.  *Note Locals::.
  66.  
  67.    Normally, a tab character in the buffer is displayed as whitespace
  68. which extends to the next display tab stop position, and display tab
  69. stops come at intervals equal to eight spaces.  The number of spaces
  70. per tab is controlled by the variable `tab-width', which is made local
  71. by changing it, just like `ctl-arrow'.  Note that how the tab character
  72. in the buffer is displayed has nothing to do with the definition of TAB
  73. as a command.
  74.  
  75.    If you set the variable `selective-display-ellipses' to `nil', the
  76. three dots do not appear at the end of a line that precedes invisible
  77. lines.  Then there is no visible indication of the invisible lines.
  78. This variable too becomes local automatically when set.
  79.  
  80. 
  81. File: emacs,  Node: Search,  Next: Fixit,  Prev: Display,  Up: Top
  82.  
  83. Searching and Replacement
  84. *************************
  85.  
  86.    Like other editors, Emacs has commands for searching for occurrences
  87. of a string.  The principal search command is unusual in that it is
  88. "incremental"; it begins to search before you have finished typing the
  89. search string.  There are also nonincremental search commands more like
  90. those of other editors.
  91.  
  92.    Besides the usual `replace-string' command that finds all
  93. occurrences of one string and replaces them with another, Emacs has a
  94. fancy replacement command called `query-replace' which asks
  95. interactively which occurrences to replace.
  96.  
  97. * Menu:
  98.  
  99. * Incremental Search::     Search happens as you type the string.
  100. * Nonincremental Search::  Specify entire string and then search.
  101. * Word Search::            Search for sequence of words.
  102. * Regexp Search::          Search for match for a regexp.
  103. * Regexps::                Syntax of regular expressions.
  104. * Search Case::            To ignore case while searching, or not.
  105. * Replace::                Search, and replace some or all matches.
  106. * Other Repeating Search:: Operating on all matches for some regexp.
  107.  
  108. 
  109. File: emacs,  Node: Incremental Search,  Next: Nonincremental Search,  Prev: Search,  Up: Search
  110.  
  111. Incremental Search
  112. ==================
  113.  
  114.    An incremental search begins searching as soon as you type the first
  115. character of the search string.  As you type in the search string, Emacs
  116. shows you where the string (as you have typed it so far) would be found.
  117. When you have typed enough characters to identify the place you want,
  118. you can stop.  Depending on what you will do next, you may or may not
  119. need to terminate the search explicitly with an ESC first.
  120.  
  121. `C-s'
  122.      Incremental search forward (`isearch-forward').
  123.  
  124. `C-r'
  125.      Incremental search backward (`isearch-backward').
  126.  
  127.    `C-s' starts an incremental search.  `C-s' reads characters from the
  128. keyboard and positions the cursor at the first occurrence of the
  129. characters that you have typed.  If you type `C-s' and then `F', the
  130. cursor moves right after the first `F'.  Type an `O', and see the
  131. cursor move to after the first `FO'.  After another `O', the cursor is
  132. after the first `FOO' after the place where you started the search. 
  133. Meanwhile, the search string `FOO' has been echoed in the echo area.
  134.  
  135.    The echo area display ends with three dots when actual searching is
  136. going on.  When search is waiting for more input, the three dots are
  137. removed. (On slow terminals, the three dots are not displayed.)
  138.  
  139.    If you make a mistake in typing the search string, you can erase
  140. characters with DEL.  Each DEL cancels the last character of search
  141. string.  This does not happen until Emacs is ready to read another
  142. input character; first it must either find, or fail to find, the
  143. character you want to erase.  If you do not want to wait for this to
  144. happen, use `C-g' as described below.
  145.  
  146.    When you are satisfied with the place you have reached, you can type
  147. ESC, which stops searching, leaving the cursor where the search brought
  148. it.  Also, any command not specially meaningful in searches stops the
  149. searching and is then executed.  Thus, typing `C-a' would exit the
  150. search and then move to the beginning of the line.  ESC is necessary
  151. only if the next command you want to type is a printing character, DEL,
  152. ESC, or another control character that is special within searches
  153. (`C-q', `C-w', `C-r', `C-s' or `C-y').
  154.  
  155.    Sometimes you search for `FOO' and find it, but not the one you
  156. expected to find.  There was a second `FOO' that you forgot about,
  157. before the one you were looking for.  In this event, type another `C-s'
  158. to move to the next occurrence of the search string.  This can be done
  159. any number of times.  If you overshoot, you can cancel some `C-s'
  160. characters with DEL.
  161.  
  162.    After you exit a search, you can search for the same string again by
  163. typing just `C-s C-s': the first `C-s' is the key that invokes
  164. incremental search, and the second `C-s' means "search again".
  165.  
  166.    If your string is not found at all, the echo area says `Failing
  167. I-Search'.  The cursor is after the place where Emacs found as much of
  168. your string as it could.  Thus, if you search for `FOOT', and there is
  169. no `FOOT', you might see the cursor after the `FOO' in `FOOL'. At this
  170. point there are several things you can do.  If your string was
  171. mistyped, you can rub some of it out and correct it.  If you like the
  172. place you have found, you can type ESC or some other Emacs command to
  173. "accept what the search offered".  Or you can type `C-g', which removes
  174. from the search string the characters that could not be found (the `T'
  175. in `FOOT'), leaving those that were found (the `FOO' in `FOOT').  A
  176. second `C-g' at that point cancels the search entirely, returning point
  177. to where it was when the search started.
  178.  
  179.    If a search is failing and you ask to repeat it by typing another
  180. `C-s', it starts again from the beginning of the buffer.  Repeating a
  181. failing reverse search with `C-r' starts again from the end.  This is
  182. called "wrapping around".  `Wrapped' appears in the search prompt once
  183. this has happened.
  184.  
  185.    The `C-g' "quit" character does special things during searches; just
  186. what it does depends on the status of the search.  If the search has
  187. found what you specified and is waiting for input, `C-g' cancels the
  188. entire search.  The cursor moves back to where you started the search. 
  189. If `C-g' is typed when there are characters in the search string that
  190. have not been found--because Emacs is still searching for them, or
  191. because it has failed to find them--then the search string characters
  192. which have not been found are discarded from the search string.  With
  193. them gone, the search is now successful and waiting for more input, so
  194. a second `C-g' will cancel the entire search.
  195.  
  196.    To search for a control character such as `C-s' or DEL or ESC, you
  197. must quote it by typing `C-q' first.  This function of `C-q' is
  198. analogous to its meaning as an Emacs command: it causes the following
  199. character to be treated the way a graphic character would normally be
  200. treated in the same context.
  201.  
  202.    You can change to searching backwards with `C-r'.  If a search fails
  203. because the place you started was too late in the file, you should do
  204. this. Repeated `C-r' keeps looking for more occurrences backwards.  A
  205. `C-s' starts going forwards again.  `C-r' in a search can be cancelled
  206. with DEL.
  207.  
  208.    If you know initially that you want to search backwards, you can use
  209. `C-r' instead of `C-s' to start the search, because `C-r' is also a key
  210. running a command (`isearch-backward') to search backward.
  211.  
  212.    The characters `C-y' and `C-w' can be used in incremental search to
  213. grab text from the buffer into the search string.  This makes it
  214. convenient to search for another occurrence of text at point.  `C-w'
  215. copies the word after point as part of the search string, advancing
  216. point over that word.  Another `C-s' to repeat the search will then
  217. search for a string including that word.  `C-y' is similar to `C-w' but
  218. copies all the rest of the current line into the search string.
  219.  
  220.    All the characters special in incremental search can be changed by
  221. setting the following variables:
  222.  
  223. `search-delete-char'
  224.      Character to delete from incremental search string (normally DEL).
  225.  
  226. `search-exit-char'
  227.      Character to exit incremental search (normally ESC).
  228.  
  229. `search-quote-char'
  230.      Character to quote special characters for incremental search
  231.      (normally `C-q').
  232.  
  233. `search-repeat-char'
  234.      Character to repeat incremental search forwards (normally `C-s').
  235.  
  236. `search-reverse-char'
  237.      Character to repeat incremental search backwards (normally `C-r').
  238.  
  239. `search-yank-line-char'
  240.      Character to pull rest of line from buffer into search string
  241.      (normally `C-y').
  242.  
  243. `search-yank-word-char'
  244.      Character to pull next word from buffer into search string
  245.      (normally `C-w').
  246.  
  247. Slow Terminal Incremental Search
  248. --------------------------------
  249.  
  250.    Incremental search on a slow terminal uses a modified style of
  251. display that is designed to take less time.  Instead of redisplaying
  252. the buffer at each place the search gets to, it creates a new
  253. single-line window and uses that to display the line that the search
  254. has found.  The single-line window comes into play as soon as point
  255. gets outside of the text that is already on the screen.
  256.  
  257.    When the search is terminated, the single-line window is removed. 
  258. Only at this time is the window in which the search was done
  259. redisplayed to show its new value of point.
  260.  
  261.    The three dots at the end of the search string, normally used to
  262. indicate that searching is going on, are not displayed in slow style
  263. display.
  264.  
  265.    The slow terminal style of display is used when the terminal baud
  266. rate is less than or equal to the value of the variable
  267. `search-slow-speed', initially 1200.
  268.  
  269.    The number of lines to use in slow terminal search display is
  270. controlled by the variable `search-slow-window-lines'.  1 is its normal
  271. value.
  272.  
  273. 
  274. File: emacs,  Node: Nonincremental Search,  Next: Word Search,  Prev: Incremental Search,  Up: Search
  275.  
  276. Nonincremental Search
  277. =====================
  278.  
  279.    Emacs also has conventional nonincremental search commands, which
  280. require you to type the entire search string before searching begins.
  281.  
  282. `C-s ESC STRING RET'
  283.      Search for STRING.
  284.  
  285. `C-r ESC STRING RET'
  286.      Search backward for STRING.
  287.  
  288.    To do a nonincremental search, first type `C-s ESC'.  This enters
  289. the minibuffer to read the search string; terminate the string with
  290. RET, and then the search is done.  If the string is not found the
  291. search command gets an error.
  292.  
  293.    The way `C-s ESC' works is that the `C-s' invokes incremental
  294. search, which is specially programmed to invoke nonincremental search
  295. if the argument you give it is empty.  (Such an empty argument would
  296. otherwise be useless.)  `C-r ESC' also works this way.
  297.  
  298.    Forward and backward nonincremental searches are implemented by the
  299. commands `search-forward' and `search-backward'.  These commands may be
  300. bound to keys in the usual manner.  The reason that incremental search
  301. is programmed to invoke them as well is that `C-s ESC' is the
  302. traditional sequence of characters used in Emacs to invoke
  303. nonincremental search.
  304.  
  305.    However, nonincremental searches performed using `C-s ESC' do not
  306. call `search-forward' right away.  The first thing done is to see if
  307. the next character is `C-w', which requests a word search. *Note Word
  308. Search::.
  309.  
  310. 
  311. File: emacs,  Node: Word Search,  Next: Regexp Search,  Prev: Nonincremental Search,  Up: Search
  312.  
  313. Word Search
  314. ===========
  315.  
  316.    Word search searches for a sequence of words without regard to how
  317. the words are separated.  More precisely, you type a string of many
  318. words, using single spaces to separate them, and the string can be
  319. found even if there are multiple spaces, newlines or other punctuation
  320. between the words.
  321.  
  322.    Word search is useful in editing documents formatted by text
  323. formatters. If you edit while looking at the printed, formatted
  324. version, you can't tell where the line breaks are in the source file. 
  325. With word search, you can search without having to know them.
  326.  
  327. `C-s ESC C-w WORDS RET'
  328.      Search for WORDS, ignoring differences in punctuation.
  329.  
  330. `C-r ESC C-w WORDS RET'
  331.      Search backward for WORDS, ignoring differences in punctuation.
  332.  
  333.    Word search is a special case of nonincremental search and is invoked
  334. with `C-s ESC C-w'.  This is followed by the search string, which must
  335. always be terminated with RET.  Being nonincremental, this search does
  336. not start until the argument is terminated.  It works by constructing a
  337. regular expression and searching for that.  *Note Regexp Search::.
  338.  
  339.    A backward word search can be done by `C-r ESC C-w'.
  340.  
  341.    Forward and backward word searches are implemented by the commands
  342. `word-search-forward' and `word-search-backward'.  These commands may
  343. be bound to keys in the usual manner.  The reason that incremental
  344. search is programmed to invoke them as well is that `C-s ESC C-w' is
  345. the traditional Emacs sequence of keys for word search.
  346.  
  347. 
  348. File: emacs,  Node: Regexp Search,  Next: Regexps,  Prev: Word Search,  Up: Search
  349.  
  350. Regular Expression Search
  351. =========================
  352.  
  353.    A "regular expression" ("regexp", for short) is a pattern that
  354. denotes a set of strings, possibly an infinite set.  Searching for
  355. matches for a regexp is a very powerful operation that editors on Unix
  356. systems have traditionally offered.  In GNU Emacs, you can search for
  357. the next match for a regexp either incrementally or not.
  358.  
  359.    Incremental search for a regexp is done by typing `C-M-s'
  360. (`isearch-forward-regexp').  This command reads a search string
  361. incrementally just like `C-s', but it treats the search string as a
  362. regexp rather than looking for an exact match against the text in the
  363. buffer.  Each time you add text to the search string, you make the
  364. regexp longer, and the new regexp is searched for.  A reverse regexp
  365. search command `isearch-backward-regexp' also exists but no key runs it.
  366.  
  367.    All of the control characters that do special things within an
  368. ordinary incremental search have the same function in incremental
  369. regexp search. Typing `C-s' or `C-r' immediately after starting the
  370. search retrieves the last incremental search regexp used; that is to
  371. say, incremental regexp and non-regexp searches have independent
  372. defaults.
  373.  
  374.    Note that adding characters to the regexp in an incremental regexp
  375. search does not make the cursor move back and start again.  Perhaps it
  376. ought to; I am not sure.  As it stands, if you have searched for `foo'
  377. and you add `\|bar', the search will not check for a `bar' in the
  378. buffer before the `foo'.
  379.  
  380.    Nonincremental search for a regexp is done by the functions
  381. `re-search-forward' and `re-search-backward'.  You can invoke these
  382. with `M-x', or bind them to keys.  Also, you can call
  383. `re-search-forward' by way of incremental regexp search with `C-M-s
  384. ESC'.
  385.  
  386. 
  387. File: emacs,  Node: Regexps,  Next: Search Case,  Prev: Regexp Search,  Up: Search
  388.  
  389. Syntax of Regular Expressions
  390. =============================
  391.  
  392.    Regular expressions have a syntax in which a few characters are
  393. special constructs and the rest are "ordinary".  An ordinary character
  394. is a simple regular expression which matches that character and nothing
  395. else. The special characters are `$', `^', `.', `*', `+', `?', `[', `]'
  396. and `\'; no new special characters will be defined.  Any other
  397. character appearing in a regular expression is ordinary, unless a `\'
  398. precedes it.
  399.  
  400.    For example, `f' is not a special character, so it is ordinary, and
  401. therefore `f' is a regular expression that matches the string `f' and
  402. no other string.  (It does not match the string `ff'.)  Likewise, `o'
  403. is a regular expression that matches only `o'.
  404.  
  405.    Any two regular expressions A and B can be concatenated.  The result
  406. is a regular expression which matches a string if A matches some amount
  407. of the beginning of that string and B matches the rest of the string.
  408.  
  409.    As a simple example, we can concatenate the regular expressions `f'
  410. and `o' to get the regular expression `fo', which matches only the
  411. string `fo'.  Still trivial.  To do something nontrivial, you need to
  412. use one of the special characters.  Here is a list of them.
  413.  
  414. `. (Period)'
  415.      is a special character that matches any single character except a
  416.      newline. Using concatenation, we can make regular expressions like
  417.      `a.b' which matches any three-character string which begins with
  418.      `a' and ends with `b'.
  419.  
  420. `*'
  421.      is not a construct by itself; it is a suffix, which means the
  422.      preceding regular expression is to be repeated as many times as
  423.      possible.  In `fo*', the `*' applies to the `o', so `fo*' matches
  424.      one `f' followed by any number of `o's. The case of zero `o's is
  425.      allowed: `fo*' does match `f'.
  426.  
  427.      `*' always applies to the smallest possible preceding expression. 
  428.      Thus, `fo*' has a repeating `o', not a repeating `fo'.
  429.  
  430.      The matcher processes a `*' construct by matching, immediately, as
  431.      many repetitions as can be found.  Then it continues with the rest
  432.      of the pattern.  If that fails, backtracking occurs, discarding
  433.      some of the matches of the `*'-modified construct in case that
  434.      makes it possible to match the rest of the pattern.  For example,
  435.      matching `ca*ar' against the string `caaar', the `a*' first tries
  436.      to match all three `a's; but the rest of the pattern is `ar' and
  437.      there is only `r' left to match, so this try fails. The next
  438.      alternative is for `a*' to match only two `a's. With this choice,
  439.      the rest of the regexp matches successfully.
  440.  
  441. `+'
  442.      Is a suffix character similar to `*' except that it requires that
  443.      the preceding expression be matched at least once.  So, for
  444.      example, `ca+r' will match the strings `car' and `caaaar' but not
  445.      the string `cr', whereas `ca*r' would match all three strings.
  446.  
  447. `?'
  448.      Is a suffix character similar to `*' except that it can match the
  449.      preceding expression either once or not at all.  For example,
  450.      `ca?r' will match `car' or `cr'; nothing else.
  451.  
  452. `[ ... ]'
  453.      `[' begins a "character set", which is terminated by a `]'.  In
  454.      the simplest case, the characters between the two form the set. 
  455.      Thus, `[ad]' matches either one `a' or one `d', and `[ad]*'
  456.      matches any string composed of just `a's and `d's (including the
  457.      empty string), from which it follows that `c[ad]*r' matches `cr',
  458.      `car', `cdr', `caddaar', etc.
  459.  
  460.      Character ranges can also be included in a character set, by
  461.      writing two characters with a `-' between them.  Thus, `[a-z]'
  462.      matches any lower-case letter.  Ranges may be intermixed freely
  463.      with individual characters, as in `[a-z$%.]', which matches any
  464.      lower case letter or `$', `%' or period.
  465.  
  466.      Note that the usual special characters are not special any more
  467.      inside a character set.  A completely different set of special
  468.      characters exists inside character sets: `]', `-' and `^'.
  469.  
  470.      To include a `]' in a character set, you must make it the first
  471.      character.  For example, `[]a]' matches `]' or `a'.  To include a
  472.      `-', write `---', which is a range containing only `-'.  To
  473.      include `^', make it other than the first character in the set.
  474.  
  475. `[^ ... ]'
  476.      `[^' begins a "complement character set", which matches any
  477.      character except the ones specified.  Thus, `[^a-z0-9A-Z]' matches
  478.      all characters except letters and digits.
  479.  
  480.      `^' is not special in a character set unless it is the first
  481.      character.  The character following the `^' is treated as if it
  482.      were first (`-' and `]' are not special there).
  483.  
  484.      Note that a complement character set can match a newline, unless
  485.      newline is mentioned as one of the characters not to match.
  486.  
  487. `^'
  488.      is a special character that matches the empty string, but only if
  489.      at the beginning of a line in the text being matched.  Otherwise
  490.      it fails to match anything.  Thus, `^foo' matches a `foo' which
  491.      occurs at the beginning of a line.
  492.  
  493. `$'
  494.      is similar to `^' but matches only at the end of a line.  Thus,
  495.      `xx*$' matches a string of one `x' or more at the end of a line.
  496.  
  497. `\'
  498.      has two functions: it quotes the special characters (including
  499.      `\'), and it introduces additional special constructs.
  500.  
  501.      Because `\' quotes special characters, `\$' is a regular
  502.      expression which matches only `$', and `\[' is a regular
  503.      expression which matches only `[', and so on.
  504.  
  505.    Note: for historical compatibility, special characters are treated as
  506. ordinary ones if they are in contexts where their special meanings make
  507. no sense.  For example, `*foo' treats `*' as ordinary since there is no
  508. preceding expression on which the `*' can act.  It is poor practice to
  509. depend on this behavior; better to quote the special character anyway,
  510. regardless of where is appears.
  511.  
  512.    For the most part, `\' followed by any character matches only that
  513. character.  However, there are several exceptions: characters which,
  514. when preceded by `\', are special constructs.  Such characters are
  515. always ordinary when encountered on their own.  Here is a table of `\'
  516. constructs.
  517.  
  518. `\|'
  519.      specifies an alternative. Two regular expressions A and B with
  520.      `\|' in between form an expression that matches anything that
  521.      either A or B will match.
  522.  
  523.      Thus, `foo\|bar' matches either `foo' or `bar' but no other string.
  524.  
  525.      `\|' applies to the largest possible surrounding expressions. 
  526.      Only a surrounding `\( ... \)' grouping can limit the grouping
  527.      power of `\|'.
  528.  
  529.      Full backtracking capability exists to handle multiple uses of
  530.      `\|'.
  531.  
  532. `\( ... \)'
  533.      is a grouping construct that serves three purposes:
  534.  
  535.        1. To enclose a set of `\|' alternatives for other operations.
  536.           Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.
  537.  
  538.        2. To enclose a complicated expression for the postfix `*' to
  539.           operate on. Thus, `ba\(na\)*' matches `bananana', etc., with
  540.           any (zero or more) number of `na' strings.
  541.  
  542.        3. To mark a matched substring for future reference.
  543.  
  544.  
  545.      This last application is not a consequence of the idea of a
  546.      parenthetical grouping; it is a separate feature which happens to
  547.      be assigned as a second meaning to the same `\( ... \)' construct
  548.      because there is no conflict in practice between the two meanings.
  549.      Here is an explanation of this feature:
  550.  
  551. `\DIGIT'
  552.      after the end of a `\( ... \)' construct, the matcher remembers the
  553.      beginning and end of the text matched by that construct.  Then,
  554.      later on in the regular expression, you can use `\' followed by
  555.      DIGIT to mean "match the same text matched the DIGIT'th time by the
  556.      `\( ... \)' construct."
  557.  
  558.      The strings matching the first nine `\( ... \)' constructs
  559.      appearing in a regular expression are assigned numbers 1 through 9
  560.      in order that the open-parentheses appear in the regular
  561.      expression.  `\1' through `\9' may be used to refer to the text
  562.      matched by the corresponding `\( ... \)' construct.
  563.  
  564.      For example, `\(.*\)\1' matches any newline-free string that is
  565.      composed of two identical halves.  The `\(.*\)' matches the first
  566.      half, which may be anything, but the `\1' that follows must match
  567.      the same exact text.
  568.  
  569. `\`'
  570.      matches the empty string, provided it is at the beginning of the
  571.      buffer.
  572.  
  573. `\''
  574.      matches the empty string, provided it is at the end of the buffer.
  575.  
  576. `\b'
  577.      matches the empty string, provided it is at the beginning or end
  578.      of a word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
  579.      separate word.  `\bballs?\b' matches `ball' or `balls' as a
  580.      separate word.
  581.  
  582. `\B'
  583.      matches the empty string, provided it is not at the beginning or
  584.      end of a word.
  585.  
  586. `\<'
  587.      matches the empty string, provided it is at the beginning of a
  588.      word.
  589.  
  590. `\>'
  591.      matches the empty string, provided it is at the end of a word.
  592.  
  593. `\w'
  594.      matches any word-constituent character.  The editor syntax table
  595.      determines which characters these are.
  596.  
  597. `\W'
  598.      matches any character that is not a word-constituent.
  599.  
  600. `\sCODE'
  601.      matches any character whose syntax is CODE.  CODE is a character
  602.      which represents a syntax code: thus, `w' for word constituent,
  603.      `-' for whitespace, `(' for open-parenthesis, etc.  *Note Syntax::.
  604.  
  605. `\SCODE'
  606.      matches any character whose syntax is not CODE.
  607.  
  608.    Here is a complicated regexp, used by Emacs to recognize the end of a
  609. sentence together with any whitespace that follows.  It is given in Lisp
  610. syntax to enable you to distinguish the spaces from the tab characters.
  611.  In Lisp syntax, the string constant begins and ends with a
  612. double-quote. `\"' stands for a double-quote as part of the regexp,
  613. `\\' for a backslash as part of the regexp, `\t' for a tab and `\n' for
  614. a newline.
  615.  
  616.      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
  617.  
  618. This contains four parts in succession: a character set matching period,
  619. `?' or `!'; a character set matching close-brackets, quotes or
  620. parentheses, repeated any number of times; an alternative in
  621. backslash-parentheses that matches end-of-line, a tab or two spaces;
  622. and a character set matching whitespace characters, repeated any number
  623. of times.
  624.  
  625. 
  626. File: emacs,  Node: Search Case,  Next: Replace,  Prev: Regexps,  Up: Search
  627.  
  628. Searching and Case
  629. ==================
  630.  
  631.    All sorts of searches in Emacs normally ignore the case of the text
  632. they are searching through; if you specify searching for `FOO', then
  633. `Foo' and `foo' are also considered a match.  Regexps, and in
  634. particular character sets, are included: `[aB]' would match `a' or `A'
  635. or `b' or `B'.
  636.  
  637.    If you do not want this feature, set the variable `case-fold-search'
  638. to `nil'.  Then all letters must match exactly, including case.  This
  639. is a per-buffer variable; altering the variable affects only the current
  640. buffer, but there is a default value which you can change as well.
  641. *Note Locals::.
  642.  
  643. 
  644. File: emacs,  Node: Replace,  Next: Other Repeating Search,  Prev: Search Case,  Up: Search
  645.  
  646. Replacement Commands
  647. ====================
  648.  
  649.    Global search-and-replace operations are not needed as often in
  650. Emacs as they are in other editors, but they are available.  In
  651. addition to the simple `replace-string' command which is like that
  652. found in most editors, there is a `query-replace' command which asks
  653. you, for each occurrence of the pattern, whether to replace it.
  654.  
  655.    The replace commands all replace one string (or regexp) with one
  656. replacement string.  It is possible to perform several replacements in
  657. parallel using the command `expand-region-abbrevs'.  *Note Expanding
  658. Abbrevs::.
  659.  
  660. * Menu:
  661.  
  662. * Unconditional Replace::  Replacing all matches for a string.
  663. * Regexp Replace::         Replacing all matches for a regexp.
  664. * Replacement and Case::   How replacements preserve case of letters.
  665. * Query Replace::          How to use querying.
  666.  
  667. 
  668. File: emacs,  Node: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace
  669.  
  670. Unconditional Replacement
  671. -------------------------
  672.  
  673. `M-x replace-string RET STRING RET NEWSTRING RET'
  674.      Replace every occurrence of STRING with NEWSTRING.
  675.  
  676. `M-x replace-regexp RET REGEXP RET NEWSTRING RET'
  677.      Replace every match for REGEXP with NEWSTRING.
  678.  
  679.    To replace every instance of `foo' after point with `bar', use the
  680. command `M-x replace-string' with the two arguments `foo' and `bar'. 
  681. Replacement occurs only after point, so if you want to cover the whole
  682. buffer you must go to the beginning first.  All occurrences up to the
  683. end of the buffer are replaced; to limit replacement to part of the
  684. buffer, narrow to that part of the buffer before doing the replacement
  685. (*note Narrowing::.).
  686.  
  687.    When `replace-string' exits, point is left at the last occurrence
  688. replaced.  The value of point when the `replace-string' command was
  689. issued is remembered on the mark ring; `C-u C-SPC' moves back there.
  690.  
  691.    A numeric argument restricts replacement to matches that are
  692. surrounded by word boundaries.
  693.  
  694. 
  695. File: emacs,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace
  696.  
  697. Regexp Replacement
  698. ------------------
  699.  
  700.    `replace-string' replaces exact matches for a single string.  The
  701. similar command `replace-regexp' replaces any match for a specified
  702. pattern.
  703.  
  704.    In `replace-regexp', the NEWSTRING need not be constant.  It can
  705. refer to all or part of what is matched by the REGEXP.  `\&' in
  706. NEWSTRING stands for the entire text being replaced. `\D' in NEWSTRING,
  707. where D is a digit, stands for whatever matched the D'th parenthesized
  708. grouping in REGEXP. For example,
  709.  
  710.      M-x replace-regexp RET c[ad]+r RET \&-safe RET
  711.  
  712. would replace (for example) `cadr' with `cadr-safe' and `cddr' with
  713. `cddr-safe'.
  714.  
  715.      M-x replace-regexp RET \(c[ad]+r\)-safe RET \1 RET
  716.  
  717. would perform exactly the opposite replacements.  To include a `\' in
  718. the text to replace with, you must give `\\'.
  719.  
  720. 
  721. File: emacs,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace
  722.  
  723. Replace Commands and Case
  724. -------------------------
  725.  
  726.    If the arguments to a replace command are in lower case, it preserves
  727. case when it makes a replacement.  Thus, the command
  728.  
  729.      M-x replace-string RET foo RET bar RET
  730.  
  731. replaces a lower case `foo' with a lower case `bar', `FOO' with `BAR',
  732. and `Foo' with `Bar'.  If upper case letters are used in the second
  733. argument, they remain upper case every time that argument is inserted. 
  734. If upper case letters are used in the first argument, the second
  735. argument is always substituted exactly as given, with no case
  736. conversion.  Likewise, if the variable `case-replace' is set to `nil',
  737. replacement is done without case conversion.  If `case-fold-search' is
  738. set to `nil', case is significant in matching occurrences of `foo' to
  739. replace; also, case conversion of the replacement string is not done.
  740.  
  741. 
  742. File: emacs,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace
  743.  
  744. Query Replace
  745. -------------
  746.  
  747. `M-% STRING RET NEWSTRING RET'
  748. `M-x query-replace RET STRING RET NEWSTRING RET'
  749.      Replace some occurrences of STRING with NEWSTRING.
  750.  
  751. `M-x query-replace-regexp RET REGEXP RET NEWSTRING RET'
  752.      Replace some matches for REGEXP with NEWSTRING.
  753.  
  754.    If you want to change only some of the occurrences of `foo' to
  755. `bar', not all of them, then you cannot use an ordinary
  756. `replace-string'.  Instead, use `M-%' (`query-replace'). This command
  757. finds occurrences of `foo' one by one, displays each occurrence and
  758. asks you whether to replace it.  A numeric argument to `query-replace'
  759. tells it to consider only occurrences that are bounded by
  760. word-delimiter characters.
  761.  
  762.    Aside from querying, `query-replace' works just like
  763. `replace-string', and `query-replace-regexp' works just like
  764. `replace-regexp'.
  765.  
  766.    The things you can type when you are shown an occurrence of STRING
  767. or a match for REGEXP are:
  768.  
  769. `SPC'
  770.      to replace the occurrence with NEWSTRING.  This preserves case,
  771.      just like `replace-string', provided `case-replace' is non-`nil',
  772.      as it normally is.
  773.  
  774. `DEL'
  775.      to skip to the next occurrence without replacing this one.
  776.  
  777. `, (Comma)'
  778.      to replace this occurrence and display the result.  You are then
  779.      asked for another input character, except that since the
  780.      replacement has already been made, DEL and SPC are equivalent. 
  781.      You could type `C-r' at this point (see below) to alter the
  782.      replaced text.  You could also type `C-x u' to undo the
  783.      replacement; this exits the `query-replace', so if you want to do
  784.      further replacement you must use `C-x ESC' to restart (*note
  785.      Repetition::.).
  786.  
  787. `ESC'
  788.      to exit without doing any more replacements.
  789.  
  790. `. (Period)'
  791.      to replace this occurrence and then exit.
  792.  
  793. `!'
  794.      to replace all remaining occurrences without asking again.
  795.  
  796. `^'
  797.      to go back to the location of the previous occurrence (or what
  798.      used to be an occurrence), in case you changed it by mistake. 
  799.      This works by popping the mark ring.  Only one `^' in a row is
  800.      allowed, because only one previous replacement location is kept
  801.      during `query-replace'.
  802.  
  803. `C-r'
  804.      to enter a recursive editing level, in case the occurrence needs
  805.      to be edited rather than just replaced with NEWSTRING.  When you
  806.      are done, exit the recursive editing level with `C-M-c' and the
  807.      next occurrence will be displayed.  *Note Recursive Edit::.
  808.  
  809. `C-w'
  810.      to delete the occurrence, and then enter a recursive editing level
  811.      as in `C-r'.  Use the recursive edit to insert text to replace the
  812.      deleted occurrence of STRING.  When done, exit the recursive
  813.      editing level with `C-M-c' and the next occurrence will be
  814.      displayed.
  815.  
  816. `C-l'
  817.      to redisplay the screen and then give another answer.
  818.  
  819. `C-h'
  820.      to display a message summarizing these options, then give another
  821.      answer.
  822.  
  823.    If you type any other character, the `query-replace' is exited, and
  824. the character executed as a command.  To restart the `query-replace',
  825. use `C-x ESC', which repeats the `query-replace' because it used the
  826. minibuffer to read its arguments.  *Note C-x ESC: Repetition.
  827.  
  828. 
  829. File: emacs,  Node: Other Repeating Search,  Prev: Replace,  Up: Search
  830.  
  831. Other Search-and-Loop Commands
  832. ==============================
  833.  
  834.    Here are some other commands that find matches for a regular
  835. expression. They all operate from point to the end of the buffer.
  836.  
  837. `M-x occur'
  838.      Print each line that follows point and contains a match for the
  839.      specified regexp.  A numeric argument specifies the number of
  840.      context lines to print before and after each matching line; the
  841.      default is none.
  842.  
  843.      The buffer `*Occur*' containing the output serves as a menu for
  844.      finding the occurrences in their original context.  Find an
  845.      occurrence as listed in `*Occur*', position point there and type
  846.      `C-c C-c'; this switches to the buffer that was searched and moves
  847.      point to the original of the same occurrence.
  848.  
  849. `M-x list-matching-lines'
  850.      Synonym for `M-x occur'.
  851.  
  852. `M-x count-matches'
  853.      Print the number of matches following point for the specified
  854.      regexp.
  855.  
  856. `M-x delete-non-matching-lines'
  857.      Delete each line that follows point and does not contain a match
  858.      for the specified regexp.
  859.  
  860. `M-x delete-matching-lines'
  861.      Delete each line that follows point and contains a match for the
  862.      specified regexp.
  863.  
  864. 
  865. File: emacs,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top
  866.  
  867. Commands for Fixing Typos
  868. *************************
  869.  
  870.    In this chapter we describe the commands that are especially useful
  871. for the times when you catch a mistake in your text just after you have
  872. made it, or change your mind while composing text on line.
  873.  
  874. * Menu:
  875.  
  876. * Kill Errors:: Commands to kill a batch of recently entered text.
  877. * Transpose::   Exchanging two characters, words, lines, lists...
  878. * Fixing Case:: Correcting case of last word entered.
  879. * Spelling::    Apply spelling checker to a word, or a whole file.
  880.  
  881. 
  882. File: emacs,  Node: Kill Errors,  Next: Transpose,  Prev: Fixit,  Up: Fixit
  883.  
  884. Killing Your Mistakes
  885. =====================
  886.  
  887. `DEL'
  888.      Delete last character (`delete-backward-char').
  889.  
  890. `M-DEL'
  891.      Kill last word (`backward-kill-word').
  892.  
  893. `C-x DEL'
  894.      Kill to beginning of sentence (`backward-kill-sentence').
  895.  
  896.    The DEL character (`delete-backward-char') is the most important
  897. correction command.  When used among graphic (self-inserting)
  898. characters, it can be thought of as canceling the last character typed.
  899.  
  900.    When your mistake is longer than a couple of characters, it might be
  901. more convenient to use `M-DEL' or `C-x DEL'. `M-DEL' kills back to the
  902. start of the last word, and `C-x DEL' kills back to the start of the
  903. last sentence.  `C-x DEL' is particularly useful when you are thinking
  904. of what to write as you type it, in case you change your mind about
  905. phrasing. `M-DEL' and `C-x DEL' save the killed text for `C-y' and
  906. `M-y' to retrieve.  *Note Yanking::.
  907.  
  908.    `M-DEL' is often useful even when you have typed only a few
  909. characters wrong, if you know you are confused in your typing and aren't
  910. sure exactly what you typed.  At such a time, you cannot correct with
  911. DEL except by looking at the screen to see what you did.  It requires
  912. less thought to kill the whole word and start over again.
  913.  
  914. 
  915. File: emacs,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
  916.  
  917. Transposing Text
  918. ================
  919.  
  920. `C-t'
  921.      Transpose two characters (`transpose-chars').
  922.  
  923. `M-t'
  924.      Transpose two words (`transpose-words').
  925.  
  926. `C-M-t'
  927.      Transpose two balanced expressions (`transpose-sexps').
  928.  
  929. `C-x C-t'
  930.      Transpose two lines (`transpose-lines').
  931.  
  932.    The common error of transposing two characters can be fixed, when
  933. they are adjacent, with the `C-t' command (`transpose-chars'). 
  934. Normally, `C-t' transposes the two characters on either side of point. 
  935. When given at the end of a line, rather than transposing the last
  936. character of the line with the newline, which would be useless, `C-t'
  937. transposes the last two characters on the line.  So, if you catch your
  938. transposition error right away, you can fix it with just a `C-t'.  If
  939. you don't catch it so fast, you must move the cursor back to between
  940. the two transposed characters.  If you transposed a space with the last
  941. character of the word before it, the word motion commands are a good
  942. way of getting there. Otherwise, a reverse search (`C-r') is often the
  943. best way. *Note Search::.
  944.  
  945.    `Meta-t' (`transpose-words') transposes the word before point with
  946. the word after point.  It moves point forward over a word, dragging the
  947. word preceding or containing point forward as well.  The punctuation
  948. characters between the words do not move.  For example, `FOO, BAR'
  949. transposes into `BAR, FOO' rather than `BAR FOO,'.
  950.  
  951.    `C-M-t' (`transpose-sexps') is a similar command for transposing two
  952. expressions (*note Lists::.), and `C-x C-t' (`transpose-lines')
  953. exchanges lines.  They work like `M-t' except in determining the
  954. division of the text into syntactic units.
  955.  
  956.    A numeric argument to a transpose command serves as a repeat count:
  957. it tells the transpose command to move the character (word, sexp, line)
  958. before or containing point across several other characters (words,
  959. sexps, lines). For example, `C-u 3 C-t' moves the character before
  960. point forward across three other characters.  This is equivalent to
  961. repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
  962. backward across four words.  `C-u - C-M-t' would cancel the effect of
  963. plain `C-M-t'.
  964.  
  965.    A numeric argument of zero is assigned a special meaning (because
  966. otherwise a command with a repeat count of zero would do nothing): to
  967. transpose the character (word, sexp, line) ending after point with the
  968. one ending after the mark.
  969.  
  970. 
  971. File: emacs,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
  972.  
  973. Case Conversion
  974. ===============
  975.  
  976. `M-- M-l'
  977.      Convert last word to lower case.  Note `Meta--' is Meta-minus.
  978.  
  979. `M-- M-u'
  980.      Convert last word to all upper case.
  981.  
  982. `M-- M-c'
  983.      Convert last word to lower case with capital initial.
  984.  
  985.    A very common error is to type words in the wrong case.  Because of
  986. this, the word case-conversion commands `M-l', `M-u' and `M-c' have a
  987. special feature when used with a negative argument: they do not move the
  988. cursor.  As soon as you see you have mistyped the last word, you can
  989. simply case-convert it and go on typing.  *Note Case::.
  990.  
  991. 
  992. File: emacs,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
  993.  
  994. Checking and Correcting Spelling
  995. ================================
  996.  
  997. `M-$'
  998.      Check and correct spelling of word (`spell-word').
  999.  
  1000. `M-x spell-buffer'
  1001.      Check and correct spelling of each word in the buffer.
  1002.  
  1003. `M-x spell-region'
  1004.      Check and correct spelling of each word in the region.
  1005.  
  1006. `M-x spell-string'
  1007.      Check spelling of specified word.
  1008.  
  1009.    To check the spelling of the word before point, and optionally
  1010. correct it as well, use the command `M-$' (`spell-word').  This command
  1011. runs an inferior process containing the `spell' program to see whether
  1012. the word is correct English.  If it is not, it asks you to edit the
  1013. word (in the minibuffer) into a corrected spelling, and then does a
  1014. `query-replace' to substitute the corrected spelling for the old one
  1015. throughout the buffer.
  1016.  
  1017.    If you exit the minibuffer without altering the original spelling, it
  1018. means you do not want to do anything to that word.  Then the
  1019. `query-replace' is not done.
  1020.  
  1021.    `M-x spell-buffer' checks each word in the buffer the same way that
  1022. `spell-word' does, doing a `query-replace' if appropriate for every
  1023. incorrect word.
  1024.  
  1025.    `M-x spell-region' is similar but operates only on the region, not
  1026. the entire buffer.
  1027.  
  1028.    `M-x spell-string' reads a string as an argument and checks whether
  1029. that is a correctly spelled English word.  It prints in the echo area a
  1030. message giving the answer.
  1031.  
  1032. 
  1033. File: emacs,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
  1034.  
  1035. File Handling
  1036. *************
  1037.  
  1038.    The basic unit of stored data in Unix is the "file".  To edit a file,
  1039. you must tell Emacs to examine the file and prepare a buffer containing
  1040. a copy of the file's text.  This is called "visiting" the file.  Editing
  1041. commands apply directly to text in the buffer; that is, to the copy
  1042. inside Emacs.  Your changes appear in the file itself only when you
  1043. "save" the buffer back into the file.
  1044.  
  1045.    In addition to visiting and saving files, Emacs can delete, copy,
  1046. rename, and append to files, and operate on file directories.
  1047.  
  1048. * Menu:
  1049.  
  1050. * File Names::   How to type and edit file name arguments.
  1051. * Visiting::     Visiting a file prepares Emacs to edit the file.
  1052. * Saving::       Saving makes your changes permanent.
  1053. * Reverting::    Reverting cancels all the changes not saved.
  1054. * Auto Save::    Auto Save periodically protects against loss of data.
  1055. * ListDir::      Listing the contents of a file directory.
  1056. * Dired::        "Editing" a directory to delete, rename, etc.
  1057.                   the files in it.
  1058. * Misc File Ops:: Other things you can do on files.
  1059.  
  1060. 
  1061. File: emacs,  Node: File Names,  Next: Visiting,  Prev: Files,  Up: Files
  1062.  
  1063. File Names
  1064. ==========
  1065.  
  1066.    Most Emacs commands that operate on a file require you to specify the
  1067. file name.  (Saving and reverting are exceptions; the buffer knows which
  1068. file name to use for them.)  File names are specified using the
  1069. minibuffer (*note Minibuffer::.).  "Completion" is available, to make
  1070. it easier to specify long file names.  *Note Completion::.
  1071.  
  1072.    There is always a "default file name" which will be used if you type
  1073. just RET, entering an empty argument.  Normally the default file name
  1074. is the name of the file visited in the current buffer; this makes it
  1075. easy to operate on that file with any of the Emacs file commands.
  1076.  
  1077.    Each buffer has a default directory, normally the same as the
  1078. directory of the file visited in that buffer.  When Emacs reads a file
  1079. name, if you do not specify a directory, the default directory is used.
  1080.  If you specify a directory in a relative fashion, with a name that
  1081. does not start with a slash, it is interpreted with respect to the
  1082. default directory.  The default directory is kept in the variable
  1083. `default-directory', which has a separate value in every buffer.
  1084.  
  1085.    For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
  1086. the default directory is `/u/rms/gnu/'.  If you type just `foo', which
  1087. does not specify a directory, it is short for `/u/rms/gnu/foo'.
  1088. `../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
  1089. the filename `/u/rms/gnu/new/foo'.
  1090.  
  1091.    The command `M-x pwd' prints the current buffer's default directory,
  1092. and the command `M-x cd' sets it (to a value read using the
  1093. minibuffer).  A buffer's default directory changes only when the `cd'
  1094. command is used.  A file-visiting buffer's default directory is
  1095. initialized to the directory of the file that is visited there.  If a
  1096. buffer is made randomly with `C-x b', its default directory is copied
  1097. from that of the buffer that was current at the time.
  1098.  
  1099.    The default directory actually appears in the minibuffer when the
  1100. minibuffer becomes active to read a file name.  This serves two
  1101. purposes: it shows you what the default is, so that you can type a
  1102. relative file name and know with certainty what it will mean, and it
  1103. allows you to edit the default to specify a different directory.  This
  1104. insertion of the default directory is inhibited if the variable
  1105. `insert-default-directory' is set to `nil'.
  1106.  
  1107.    Note that it is legitimate to type an absolute file name after you
  1108. enter the minibuffer, ignoring the presence of the default directory
  1109. name as part of the text.  The final minibuffer contents may look
  1110. invalid, but that is not so.  *Note Minibuffer File::.
  1111.  
  1112.    `$' in a file name is used to substitute environment variables.  For
  1113. example, if you have used the shell command `setenv FOO rms/hacks' to
  1114. set up an environment variable named `FOO', then you can use
  1115. `/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
  1116. `/u/rms/hacks/test.c'.  The environment variable name consists of all
  1117. the alphanumeric characters after the `$'; alternatively, it may be
  1118. enclosed in braces after the `$'.  Note that the `setenv' command
  1119. affects Emacs only if done before Emacs is started.
  1120.  
  1121.    To access a file with `$' in its name, type `$$'.  This pair is
  1122. converted to a single `$' at the same time as variable substitution is
  1123. performed for single `$'.  The Lisp function that performs the
  1124. substitution is called `substitute-in-file-name'.  The substitution is
  1125. performed only on filenames read as such using the minibuffer.
  1126.  
  1127.