Mercurial > emacs
comparison doc/misc/faq.texi @ 103418:1df3381b5a57
(Setting up a customization file): Grammar fix.
Customize is no longer "new".
(Displaying the current line or column): Line-number mode is on by
default. Don't mention `column' package. Mention linum.el.
(Turning on abbrevs by default): Explain how to do it for buffers,
modes, and everywhere.
(Associating modes with files): Use add-to-list. Don't mention Emacs 19.
(Highlighting a region): On by default since 23.1.
(Replacing highlighted text): Update doc quote.
(Working with unprintable characters): Don't mention search-quote-char.
(Using an already running Emacs process): Gnuclient is probably not an
enhancement these days.
(Indenting switch statements): Remove mention of pre-Emacs 20.
(Horizontal scrolling): Abbreviate Emacs 20 description.
(Replacing text across multiple files): Fix name of dired command.
(Disabling backups): Use require not load.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 13 Jun 2009 20:32:36 +0000 |
parents | 2a3d145eef1e |
children | 00d812968c6c |
comparison
equal
deleted
inserted
replaced
103417:5cf7afafabf1 | 103418:1df3381b5a57 |
---|---|
933 @c ------------------------------------------------------------ | 933 @c ------------------------------------------------------------ |
934 @node Status of Emacs | 934 @node Status of Emacs |
935 @chapter Status of Emacs | 935 @chapter Status of Emacs |
936 @cindex Status of Emacs | 936 @cindex Status of Emacs |
937 | 937 |
938 This chapter gives you basic information about Emacs, including its | 938 This chapter gives you basic information about Emacs, including the |
939 latest version status. | 939 status of its latest version. |
940 | 940 |
941 @menu | 941 @menu |
942 * Origin of the term Emacs:: | 942 * Origin of the term Emacs:: |
943 * Latest version of Emacs:: | 943 * Latest version of Emacs:: |
944 * New in Emacs 20:: | 944 * New in Emacs 20:: |
1197 @cindex Init file, setting up | 1197 @cindex Init file, setting up |
1198 @cindex Customization file, setting up | 1198 @cindex Customization file, setting up |
1199 | 1199 |
1200 @inforef{Init File, Init File, emacs}. | 1200 @inforef{Init File, Init File, emacs}. |
1201 | 1201 |
1202 In general, new Emacs users should not have @file{.emacs} files, because | 1202 In general, new Emacs users should not be provided with @file{.emacs} |
1203 it causes confusing non-standard behavior. Then they send questions to | 1203 files, because this can cause confusing non-standard behavior. Then |
1204 @email{help-gnu-emacs@@gnu.org} asking why Emacs isn't behaving as | 1204 they send questions to @email{help-gnu-emacs@@gnu.org} asking why Emacs |
1205 documented. | 1205 isn't behaving as documented. |
1206 | 1206 |
1207 Beginning with version 20.1, Emacs includes the new Customize facility | 1207 Emacs includes the Customize facility (@pxref{Using Customize}). This |
1208 (@pxref{Using Customize}). This allows users who are unfamiliar with | 1208 allows users who are unfamiliar with Emacs Lisp to modify their |
1209 Emacs Lisp to modify their @file{.emacs} files in a relatively | 1209 @file{.emacs} files in a relatively straightforward way, using menus |
1210 straightforward way, using menus rather than Lisp code. Most packages | 1210 rather than Lisp code. |
1211 support Customize as of this writing. | |
1212 | 1211 |
1213 While Customize might indeed make it easier to configure Emacs, | 1212 While Customize might indeed make it easier to configure Emacs, |
1214 consider taking a bit of time to learn Emacs Lisp and modifying your | 1213 consider taking a bit of time to learn Emacs Lisp and modifying your |
1215 @file{.emacs} directly. Simple configuration options are described | 1214 @file{.emacs} directly. Simple configuration options are described |
1216 rather completely in @inforef{Init File, Init File, emacs}, for users | 1215 rather completely in @inforef{Init File, Init File, emacs}, for users |
1287 @cindex Displaying the current line or column | 1286 @cindex Displaying the current line or column |
1288 @cindex Line number, displaying the current | 1287 @cindex Line number, displaying the current |
1289 @cindex Column, displaying the current | 1288 @cindex Column, displaying the current |
1290 @cindex @code{mode-line-format} | 1289 @cindex @code{mode-line-format} |
1291 | 1290 |
1292 To have Emacs automatically display the current line number of the point | 1291 By default, Emacs displays the current line number of the point in the |
1293 in the mode line, do @kbd{M-x line-number-mode}. You can also put the | 1292 mode line. You can toggle this feature off or on with the command |
1294 form | 1293 @kbd{M-x line-number-mode}, or by setting the variable |
1295 | 1294 @code{line-number-mode}. Note that Emacs will not display the line |
1296 @lisp | |
1297 (setq line-number-mode t) | |
1298 @end lisp | |
1299 | |
1300 @noindent | |
1301 in your @file{.emacs} file to achieve this whenever you start Emacs. | |
1302 (Line number display is on by default, unless your site-specific | |
1303 initialization disables it.) Note that Emacs will not display the line | |
1304 number if the buffer's size in bytes is larger than the value of the | 1295 number if the buffer's size in bytes is larger than the value of the |
1305 variable @code{line-number-display-limit}. | 1296 variable @code{line-number-display-limit}. |
1306 | 1297 |
1307 You can similarly display the current column with | 1298 You can similarly display the current column with |
1308 @kbd{M-x column-number-mode}, or by putting the form | 1299 @kbd{M-x column-number-mode}, or by putting the form |
1310 @lisp | 1301 @lisp |
1311 (setq column-number-mode t) | 1302 (setq column-number-mode t) |
1312 @end lisp | 1303 @end lisp |
1313 | 1304 |
1314 @noindent | 1305 @noindent |
1315 in your @file{.emacs} file. | 1306 in your @file{.emacs} file. This feature is off by default. |
1316 | 1307 |
1317 The @code{"%c"} format specifier in the variable @code{mode-line-format} | 1308 The @code{"%c"} format specifier in the variable @code{mode-line-format} |
1318 will insert the current column's value into the mode line. See the | 1309 will insert the current column's value into the mode line. See the |
1319 documentation for @code{mode-line-format} (using @kbd{C-h v | 1310 documentation for @code{mode-line-format} (using @kbd{C-h v |
1320 mode-line-format @key{RET}}) for more information on how to set and use | 1311 mode-line-format @key{RET}}) for more information on how to set and use |
1321 this variable. | 1312 this variable. |
1322 | 1313 |
1323 Users of all Emacs versions can display the current column using the | |
1324 @samp{column} package written by @email{abraham@@dina.kvl.dk, Per | |
1325 Abrahamsen}. @xref{Packages that do not come with Emacs}, for | |
1326 instructions on how to get it. | |
1327 | |
1328 @cindex Set number capability in @code{vi} emulators | 1314 @cindex Set number capability in @code{vi} emulators |
1329 None of the @code{vi} emulation modes provide the ``set number'' | 1315 The @samp{linum} package (distributed with Emacs since version 23.1) |
1330 capability of @code{vi} (as far as we know). The @samp{setnu} package | 1316 displays line numbers in the left margin, like the ``set number'' |
1331 written by @email{kyle@@wonderworks.com, Kyle Jones} provides this | 1317 capability of @code{vi}. The packages @samp{setnu} and |
1332 feature. So too does @samp{wb-line-number}, written by | 1318 @samp{wb-line-number} (not distributed with Emacs) also implement this |
1333 @email{naoki.y.nakamura@@nifty.com, Naoki Nakamura}. | 1319 feature. |
1334 | 1320 |
1335 @node Displaying the current file name in the titlebar | 1321 @node Displaying the current file name in the titlebar |
1336 @section How can I modify the titlebar to contain the current file name? | 1322 @section How can I modify the titlebar to contain the current file name? |
1337 @cindex Titlebar, displaying the current file name in | 1323 @cindex Titlebar, displaying the current file name in |
1338 @cindex File name, displaying in the titlebar | 1324 @cindex File name, displaying in the titlebar |
1364 | 1350 |
1365 @node Turning on abbrevs by default | 1351 @node Turning on abbrevs by default |
1366 @section How do I turn on abbrevs by default just in mode @var{mymode}? | 1352 @section How do I turn on abbrevs by default just in mode @var{mymode}? |
1367 @cindex Abbrevs, turning on by default | 1353 @cindex Abbrevs, turning on by default |
1368 | 1354 |
1369 Put this in your @file{.emacs} file: | 1355 Abbrev mode expands abbreviations as you type them. To turn it on in a |
1356 specific buffer, use @kbd{M-x abbrev-mode}. To turn it on in every | |
1357 buffer by default, put this in your @file{.emacs} file: | |
1358 | |
1359 @lisp | |
1360 (setq-default abbrev-mode t) | |
1361 @end lisp | |
1362 | |
1363 @noindent To turn it on in a specific mode, use: | |
1364 | |
1365 @lisp | |
1366 (add-hook '@var{mymode}-mode-hook | |
1367 (lambda () | |
1368 (setq abbrev-mode t))) | |
1369 @end lisp | |
1370 | |
1371 @noindent If your Emacs version is older then 22.1, you will also need to use: | |
1370 | 1372 |
1371 @lisp | 1373 @lisp |
1372 (condition-case () | 1374 (condition-case () |
1373 (quietly-read-abbrev-file) | 1375 (quietly-read-abbrev-file) |
1374 (file-error nil)) | 1376 (file-error nil)) |
1375 | 1377 @end lisp |
1376 (add-hook '@var{mymode}-mode-hook | |
1377 (lambda () | |
1378 (setq abbrev-mode t))) | |
1379 @end lisp | |
1380 | |
1381 Starting with Emacs 22, the standard abbrevs file is read automatically | |
1382 at startup, so the first of these two forms becomes unnecessary. | |
1383 | 1378 |
1384 @node Associating modes with files | 1379 @node Associating modes with files |
1385 @section How do I make Emacs use a certain major mode for certain files? | 1380 @section How do I make Emacs use a certain major mode for certain files? |
1386 @cindex Associating modes with files | 1381 @cindex Associating modes with files |
1387 @cindex File extensions and modes | 1382 @cindex File extensions and modes |
1390 | 1385 |
1391 If you want to use a certain mode @var{foo} for all files whose names end | 1386 If you want to use a certain mode @var{foo} for all files whose names end |
1392 with the extension @file{.@var{bar}}, this will do it for you: | 1387 with the extension @file{.@var{bar}}, this will do it for you: |
1393 | 1388 |
1394 @lisp | 1389 @lisp |
1395 (setq auto-mode-alist (cons '("\\.@var{bar}\\'" . @var{foo}-mode) auto-mode-alist)) | 1390 (add-to-list 'auto-mode-alist '("\\.@var{bar}\\'" . @var{foo}-mode)) |
1396 @end lisp | 1391 @end lisp |
1397 | 1392 |
1398 Otherwise put this somewhere in the first line of any file you want to | 1393 Alternatively, put this somewhere in the first line of any file you want to |
1399 edit in the mode @var{foo} (in the second line, if the first line begins | 1394 edit in the mode @var{foo} (in the second line, if the first line begins |
1400 with @samp{#!}): | 1395 with @samp{#!}): |
1401 | 1396 |
1402 @example | 1397 @example |
1403 -*- @var{foo} -*- | 1398 -*- @var{foo} -*- |
1404 @end example | 1399 @end example |
1405 | 1400 |
1406 @cindex Major mode for shell scripts | 1401 @cindex Major mode for shell scripts |
1407 Beginning with Emacs 19, the variable @code{interpreter-mode-alist} | 1402 The variable @code{interpreter-mode-alist} specifies which mode to use |
1408 specifies which mode to use when loading a shell script. (Emacs | 1403 when loading an interpreted script (e.g. shell, python, etc.). Emacs |
1409 determines which interpreter you're using by examining the first line of | 1404 determines which interpreter you're using by examining the first line of |
1410 the script.) Use @kbd{C-h v} (or @kbd{M-x describe-variable}) | 1405 the script. Use @kbd{C-h v} (or @kbd{M-x describe-variable}) on |
1411 on @code{interpreter-mode-alist} to learn more. | 1406 @code{interpreter-mode-alist} to learn more. |
1412 | 1407 |
1413 @node Highlighting a region | 1408 @node Highlighting a region |
1414 @section How can I highlight a region of text in Emacs? | 1409 @section How can I highlight a region of text in Emacs? |
1415 @cindex Highlighting text | 1410 @cindex Highlighting text |
1416 @cindex Text, highlighting | 1411 @cindex Text, highlighting |
1419 | 1414 |
1420 You can cause the region to be highlighted when the mark is active by | 1415 You can cause the region to be highlighted when the mark is active by |
1421 including | 1416 including |
1422 | 1417 |
1423 @lisp | 1418 @lisp |
1424 (transient-mark-mode t) | 1419 (transient-mark-mode 1) |
1425 @end lisp | 1420 @end lisp |
1426 | 1421 |
1427 @noindent | 1422 @noindent |
1428 in your @file{.emacs} file. | 1423 in your @file{.emacs} file. Since Emacs 23.1, this feature is on by default. |
1429 | 1424 |
1430 @node Replacing highlighted text | 1425 @node Replacing highlighted text |
1431 @section How can I replace highlighted text with what I type? | 1426 @section How can I replace highlighted text with what I type? |
1432 @cindex @code{delete-selection-mode} | 1427 @cindex @code{delete-selection-mode} |
1433 @cindex Replacing highlighted text | 1428 @cindex Replacing highlighted text |
1443 According to the documentation string for @code{delete-selection-mode} | 1438 According to the documentation string for @code{delete-selection-mode} |
1444 (which you can read using @kbd{M-x describe-function @key{RET} | 1439 (which you can read using @kbd{M-x describe-function @key{RET} |
1445 delete-selection-mode @key{RET}}): | 1440 delete-selection-mode @key{RET}}): |
1446 | 1441 |
1447 @quotation | 1442 @quotation |
1448 When ON, typed text replaces the selection if the selection is active. | 1443 When Delete Selection mode is enabled, Transient Mark mode is also |
1449 When OFF, typed text is just inserted at point. | 1444 enabled and typed text replaces the selection if the selection is |
1445 active. Otherwise, typed text is just inserted at point regardless of | |
1446 any selection. | |
1450 @end quotation | 1447 @end quotation |
1451 | 1448 |
1452 This mode also allows you to delete (not kill) the highlighted region by | 1449 This mode also allows you to delete (not kill) the highlighted region by |
1453 pressing @key{DEL}. | 1450 pressing @key{DEL}. |
1454 | 1451 |
1457 @cindex @code{case-fold-search} | 1454 @cindex @code{case-fold-search} |
1458 @cindex Case sensitivity of searches | 1455 @cindex Case sensitivity of searches |
1459 @cindex Searching without case sensitivity | 1456 @cindex Searching without case sensitivity |
1460 @cindex Ignoring case in searches | 1457 @cindex Ignoring case in searches |
1461 | 1458 |
1462 For searching, the value of the variable @code{case-fold-search} | 1459 @c FIXME |
1463 determines whether they are case sensitive: | 1460 The value of the variable @code{case-fold-search} determines whether |
1461 searches are case sensitive: | |
1464 | 1462 |
1465 @lisp | 1463 @lisp |
1466 (setq case-fold-search nil) ; make searches case sensitive | 1464 (setq case-fold-search nil) ; make searches case sensitive |
1467 (setq case-fold-search t) ; make searches case insensitive | 1465 (setq case-fold-search t) ; make searches case insensitive |
1468 @end lisp | 1466 @end lisp |
1492 @cindex Eight-bit characters, working with | 1490 @cindex Eight-bit characters, working with |
1493 @cindex Searching for unprintable characters | 1491 @cindex Searching for unprintable characters |
1494 @cindex Regexps and unprintable characters | 1492 @cindex Regexps and unprintable characters |
1495 | 1493 |
1496 To search for a single character that appears in the buffer as, for | 1494 To search for a single character that appears in the buffer as, for |
1497 example, @samp{\237}, you can type @kbd{C-s C-q 2 3 7}. (This assumes | 1495 example, @samp{\237}, you can type @kbd{C-s C-q 2 3 7}. |
1498 the value of @code{search-quote-char} is 17 (i.e., @kbd{C-q}).) | |
1499 Searching for @strong{all} unprintable characters is best done with a | 1496 Searching for @strong{all} unprintable characters is best done with a |
1500 regular expression (@dfn{regexp}) search. The easiest regexp to use for | 1497 regular expression (@dfn{regexp}) search. The easiest regexp to use for |
1501 the unprintable chars is the complement of the regexp for the printable | 1498 the unprintable chars is the complement of the regexp for the printable |
1502 chars. | 1499 chars. |
1503 | 1500 |
1666 @kbd{M-x server-edit}) to indicate this. If there is another buffer | 1663 @kbd{M-x server-edit}) to indicate this. If there is another buffer |
1667 requested by @code{emacsclient}, Emacs will switch to it; otherwise | 1664 requested by @code{emacsclient}, Emacs will switch to it; otherwise |
1668 @code{emacsclient} will exit, signaling the calling program to continue. | 1665 @code{emacsclient} will exit, signaling the calling program to continue. |
1669 | 1666 |
1670 @cindex @code{gnuserv} | 1667 @cindex @code{gnuserv} |
1671 There is an enhanced version of @samp{emacsclient} called | 1668 There is an alternative version of @samp{emacsclient} called |
1672 @samp{gnuserv}, written by @email{ange@@hplb.hpl.hp.com, Andy Norman} | 1669 @samp{gnuserv}, written by @email{ange@@hplb.hpl.hp.com, Andy Norman} |
1673 (@pxref{Packages that do not come with Emacs}). @samp{gnuserv} uses | 1670 (@pxref{Packages that do not come with Emacs}). @samp{gnuserv} uses |
1674 Internet domain sockets, so it can work across most network connections. | 1671 Internet domain sockets, so it can work across most network connections. |
1675 | 1672 |
1676 The most recent @samp{gnuserv} package is available at | 1673 The most recent @samp{gnuserv} package is available at |
1709 x3; | 1706 x3; |
1710 @} | 1707 @} |
1711 @} | 1708 @} |
1712 @end example | 1709 @end example |
1713 | 1710 |
1714 The solution at first appears to be: set @code{c-indent-level} to 4 and | 1711 @noindent To achieve this, add the following line to your @file{.emacs}: |
1715 @code{c-label-offset} to -2. However, this will give you an indentation | |
1716 spacing of four instead of two. | |
1717 | |
1718 The @emph{real} solution is to use @code{cc-mode} (the default mode for | |
1719 C programming in Emacs 20 and later) and add the following line to your | |
1720 @file{.emacs}: | |
1721 | 1712 |
1722 @lisp | 1713 @lisp |
1723 (c-set-offset 'case-label '+) | 1714 (c-set-offset 'case-label '+) |
1724 @end lisp | 1715 @end lisp |
1725 | |
1726 There appears to be no way to do this with the old @code{c-mode}. | |
1727 | 1716 |
1728 @node Customizing C and C++ indentation | 1717 @node Customizing C and C++ indentation |
1729 @section How to customize indentation in C, C@t{++}, and Java buffers? | 1718 @section How to customize indentation in C, C@t{++}, and Java buffers? |
1730 @cindex Indentation, how to customize | 1719 @cindex Indentation, how to customize |
1731 @cindex Customize indentation | 1720 @cindex Customize indentation |
1822 | 1811 |
1823 Note that this is overridden by the variable | 1812 Note that this is overridden by the variable |
1824 @code{truncate-partial-width-windows} if that variable is non-nil | 1813 @code{truncate-partial-width-windows} if that variable is non-nil |
1825 and the current buffer is not full-frame width. | 1814 and the current buffer is not full-frame width. |
1826 | 1815 |
1827 In Emacs 20, use the @code{hscroll-mode}. Here is some information from | 1816 In Emacs 20, use @code{hscroll-mode}. |
1828 the documentation, available by typing @kbd{C-h f hscroll-mode @key{RET}}: | |
1829 | |
1830 Automatically scroll horizontally when the point moves off the | |
1831 left or right edge of the window. | |
1832 | |
1833 @itemize @minus | |
1834 @item | |
1835 Type @kbd{M-x hscroll-mode} to enable it in the current buffer. | |
1836 | |
1837 @item | |
1838 Type @kbd{M-x hscroll-global-mode} to enable it in every buffer. | |
1839 | |
1840 @item | |
1841 @code{turn-on-hscroll} is useful in mode hooks as in: | |
1842 | |
1843 @lisp | |
1844 (add-hook 'text-mode-hook 'turn-on-hscroll) | |
1845 @end lisp | |
1846 | |
1847 @item | |
1848 @code{hscroll-margin} controls how close the cursor can get to the | |
1849 edge of the window. | |
1850 | |
1851 @item | |
1852 @code{hscroll-step-percent} controls how far to jump once we decide to do so. | |
1853 @end itemize | |
1854 | 1817 |
1855 @node Overwrite mode | 1818 @node Overwrite mode |
1856 @section How do I make Emacs ``typeover'' or ``overwrite'' instead of inserting? | 1819 @section How do I make Emacs ``typeover'' or ``overwrite'' instead of inserting? |
1857 @cindex @key{Insert} | 1820 @cindex @key{Insert} |
1858 @cindex @code{overwrite-mode} | 1821 @cindex @code{overwrite-mode} |
2202 @cindex Replacing strings across files | 2165 @cindex Replacing strings across files |
2203 @cindex Multiple files, replacing across | 2166 @cindex Multiple files, replacing across |
2204 @cindex Files, replacing strings across multiple | 2167 @cindex Files, replacing strings across multiple |
2205 @cindex Recursive search/replace operations | 2168 @cindex Recursive search/replace operations |
2206 | 2169 |
2207 As of Emacs 19.29, Dired mode (@kbd{M-x dired @key{RET}}, or @kbd{C-x | 2170 Dired mode (@kbd{M-x dired @key{RET}}, or @kbd{C-x d}) supports the |
2208 d}) supports the command @code{dired-do-query-replace} (@kbd{Q}), which | 2171 command @code{dired-do-query-replace-regexp} (@kbd{Q}), which allows |
2209 allows users to replace regular expressions in multiple files. | 2172 users to replace regular expressions in multiple files. |
2210 | 2173 |
2211 You can use this command to perform search/replace operations on | 2174 You can use this command to perform search/replace operations on |
2212 multiple files by following the following steps: | 2175 multiple files by following the following steps: |
2213 | 2176 |
2214 @itemize @bullet | 2177 @itemize @bullet |
2255 load @code{dired-x} by adding the following to your @file{.emacs} file: | 2218 load @code{dired-x} by adding the following to your @file{.emacs} file: |
2256 | 2219 |
2257 @lisp | 2220 @lisp |
2258 (add-hook 'dired-load-hook | 2221 (add-hook 'dired-load-hook |
2259 (lambda () | 2222 (lambda () |
2260 (load "dired-x"))) | 2223 (require 'dired-x))) |
2261 @end lisp | 2224 @end lisp |
2262 | 2225 |
2263 With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer. | 2226 With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer. |
2264 You can make omitting the default for new dired buffers by putting the | 2227 You can make omitting the default for new dired buffers by putting the |
2265 following in your @file{.emacs}: | 2228 following in your @file{.emacs}: |