HACK around tests that depend on directory contents.
[docutils.git] / docs / user / emacs.txt
blob072b8cdfebf19724804926119554aff6fcd0f2d6
1 .. -*- coding: utf-8 -*-
3 ========================================
4    Emacs Support for reStructuredText
5 ========================================
7 :Authors: Stefan Merten <stefan@merten-home.de>, Martin Blais
8           <blais@furius.ca>
9 :Version: ``rst.el`` V1.4.0
10 :Abstract:
12     High-level description of the existing Emacs_ support for editing
13     reStructuredText_ text documents. Suggested setup code and usage
14     instructions are provided.
16 .. contents::
18 Introduction
19 ============
21 reStructuredText_ is a syntax for simple text files that allows a
22 tool set - docutils_ - to extract generic document structure. For
23 people who use Emacs_, there is a package that adds a major mode that
24 supports editing the syntax of reStructuredText_: ``rst.el``. This
25 document describes the features it provides, and how to setup your
26 Emacs_ to use them and how to invoke them.
28 Installation
29 ============
31 Emacs_ support for reStructuredText_ is implemented as an Emacs_ major
32 mode (``rst-mode``) provided by the ``rst.el`` Emacs_ package.
34 Emacs_ distributions contain ``rst.el`` since version V23.1. However,
35 a significantly updated version of ``rst.el`` is contained in Emacs_
36 V24.3. This document describes the version of ``rst.el`` contained in
37 Emacs_ V24.3. This version of ``rst.el`` has the internal version
38 V1.4.0.
40 If you have Emacs_ V24.3 or later you do not need to install anything
41 to get reST support. If you have an Emacs_ between V23.1 and V24.2 you
42 may use the included version of ``rst.el`` or install a more recent
43 one locally_ (recommended). In other cases you need to install
44 ``rst.el`` locally_ to get reST support.
46 Checking situation
47 ------------------
49 Here are some steps to check your situation:
51 #. In Emacs_ switch to an empty buffer and try ::
53      M-x rst-mode
55    If this works you have ``rst.el`` installed somewhere. You can see
56    that it works if you find a string ``ReST`` in Emacs' modeline of
57    the current buffer. If this doesn't work you need to install
58    ``rst.el`` yourself locally_.
60 #. In the buffer you just switched to ``rst-mode`` try ::
62      C-h v rst-version
64    If this fails you have a version of ``rst.el`` older than
65    V1.1.0. Either you have an old ``rst.el`` locally or you are using
66    an Emacs_ between V23.1 and V24.2. In this case it is recommended
67    that you install a more recent version of ``rst.el`` locally_.
69    You may also try ::
71      C-h v emacs-version
73    to find out your Emacs_ version.
75 #. Check the version of ``rst.el``
77    The content of ``rst-version`` gives you the internal version of
78    ``rst.el``. The version contained in Emacs_ V24.3 and described here
79    is V1.4.0. If you have an older version you may or may not install
80    a more recent version of ``rst.el`` locally.
82 .. _locally:
84 Local installation
85 ------------------
87 If you decided to install locally please follow these steps.
89 #. Download ``rst.el``
91    Download the most recent published version of ``rst.el`` from
92    http://docutils.sourceforge.net/tools/editors/emacs/rst.el
94 #. Put ``rst.el`` to a directory in ``load-path``
96    Use ::
98      C-h v load-path
100    If in the resulting list you find a directory in your home
101    directory put ``rst.el`` in this directory.
103    Make sure the directory is one of the first entries in
104    ``load-path``. Otherwise a version of ``rst.el`` which came with
105    Emacs_ may be found before your local version.
107    In Emacs_ see the info node ``Init File Examples`` for more
108    information on how to set up your Emacs_ initialization
109    machinery. Try ::
111      C-h i
112      mEmacs<Return>
113      sInit File Examples<Return>
115 #. Enable ``rst-mode``
117    Add the following to your Emacs_ initialization setup ::
119      (require 'rst)
121    After you restarted Emacs_ ``rst.el`` is loaded and ready to be
122    used.
124 Switching ``rst-mode`` on
125 -------------------------
127 By default ``rst-mode`` is switched on for files ending in ``.rst`` or
128 ``.rest``. If in a buffer you want to switch ``rst-mode`` on manually
129 use ::
131   M-x rst-mode
133 If you want to use ``rst-mode`` in files with other extensions modify
134 ``auto-mode-alist`` to automatically turn it on whenever you visit
135 reStructuredText_ documents::
137    (setq auto-mode-alist
138          (append '(("\\.txt\\'" . rst-mode)
139                    ("\\.rst\\'" . rst-mode)
140                    ("\\.rest\\'" . rst-mode)) auto-mode-alist))
142 Put the extensions you want in the correct place in the example
143 above. Add more lines if needed.
145 If have local variables enabled (try ``C-h v enable-local-variables``
146 to find out), you can also add the following at the top of your
147 documents to trigger rst-mode::
149    .. -*- mode: rst -*-
151 Or this at the end of your documents::
153    ..
154       Local Variables:
155       mode: rst
156       End:
158 Key bindings
159 ============
161 ``rst-mode`` automatically binds several keys for invoking special
162 functions for editing reStructuredText_. Since ``rst-mode`` contains a
163 lot of functionality most key bindings consist of three
164 keystrokes.
166 Following the Emacs_ conventions for major modes the key bindings of
167 ``rst-mode`` start with ``C-c C-<letter>``. The second key stroke
168 selects a group of key bindings:
170 C-c C-a
171   Commands to adjust the section headers and work with the hierarchy
172   they build.
174 C-c C-c
175   Commands to compile the current reStructuredText_ document to
176   various output formats.
178 C-c C-l
179   Commands to work with lists of various kinds.
181 C-c C-r
182   Commands to manipulate the current region.
184 C-c C-t
185   Commands to create and manipulate a table of contents.
187 At any stage of typing you may use ``C-h`` to get help on the
188 available key bindings. I.e. ``C-c C-h`` gives you help on all key
189 bindings while ``C-c C-r C-h`` gives you help on the commands for
190 regions. This is handy if you forgot a certain key binding.
192 Additional key bindings which have a certain meaning in other Emacs_
193 modes are reused in ``rst-mode`` so you don't have to learn a
194 different set of key bindings for editing reStructuredText_.
196 In ``rst-mode`` try ::
198   C-h m
200 to list all mode specific key bindings. Most of the key bindings are
201 described in this tutorial.
203 .. note:: The key bindings have been completely revamped in ``rst.el``
204           V1.0.0. This was necessary to make room for new
205           functionality. Some of the old bindings still work but give
206           a warning to use the new binding. In the output of ``C-h m``
207           these bindings show up as ``??``. The old bindings may be
208           removed completely in a later version.
210 Section Adornments
211 ==================
213 ``rst-mode`` recognizes the section adornments building the section
214 hierarchy of the document. Section adornments are the underlines or
215 under- and overlines used to mark a section title. There are a couple
216 of commands to work with section adornments. These commands are bound
217 to key bindings starting with ``C-c C-a``.
219 Adjusting a Section Title
220 -------------------------
222 There is a function that helps a great deal to maintain these
223 adornments: ``rst-adjust`` (bound to ``C-c C-a C-a``, ``C-c C-=``, and
224 ``C-=``). This function is a Swiss army knife that can be invoked
225 repeatedly and whose behavior depends on context:
227 #. If there is an incomplete adornment, e.g. ::
229       My Section Title
230       ==
232    invocation will complete the adornment. It can also be used to
233    adjust the length of the existing adornment when you need to edit
234    the title.
236 #. If there is no section adornment at all, an adornment of the same
237    level as the last encountered section level is added. You can
238    simply enter a few characters of the title and invoke the function
239    to create the section adornment.
241 #. If there is already a section adornment, it is promoted one level
242    up. You can invoke it like this repeatedly to cycle the title
243    through the hierarchy of existing adornments.
245 Invoking the function with a negative prefix argument, e.g. ``C--
246 C-=``, will effectively reverse the direction of adornment cycling.
247 To alternate between underline-only and over-and-under styles, you can
248 use a regular prefix argument, e.g. ``C-u C-=``. See the
249 documentation of ``rst-adjust`` for more description of the prefix
250 arguments to alter the behavior of the function.
252 Promoting and Demoting Many Sections
253 ------------------------------------
255 When you are re-organizing the structure of a document, it can be
256 useful to change the level of a number of section titles. The same
257 key binding can be used to do that: if the region is active when the
258 binding is invoked, all the section titles that are within the region
259 are promoted accordingly (or demoted, with negative prefix argument).
261 Redoing All the Adornments to Your Taste
262 ----------------------------------------
264 If you open someone else's file and the adornments it contains are
265 unfamiliar, you may want to readjust them to fit your own preferred
266 hierarchy of adornments. This can be difficult to perform by hand.
267 However, you can do this easily by invoking
268 ``rst-straighten-adornments`` (``C-c C-a C-s``), which operates on the
269 entire buffer.
271 Customizations for Adornments
272 -----------------------------
274 You can customize the variable ``rst-preferred-adornments`` to a list
275 of the adornments that you like to use for documents.
276 ``rst-default-indent`` can be set to the number of indent spaces
277 preferred for the over-and-under adornment style.
279 Viewing the Hierarchy of Section Adornments
280 -------------------------------------------
282 You can visualize the hierarchy of the section adornments in the
283 current buffer by invoking ``rst-display-adornments-hierarchy``, bound
284 on ``C-c C-a C-d``. A temporary buffer will appear with fake section
285 titles rendered in the style of the current document. This can be
286 useful when editing other people's documents to find out which section
287 adornments correspond to which levels.
289 Movement and Selection
290 ======================
292 Movement and Selection for Sections
293 -----------------------------------
295 You can move the cursor between the different section titles by using
296 the ``rst-backward-section`` (``C-M-a``) and ``rst-forward-section``
297 (``C-M-e``). To mark the section that cursor lies in, use
298 ``rst-mark-section`` (``C-M-h``).
300 The key bindings are modeled after other modes with similar
301 functionality.
303 Movements and Selection for Text Blocks
304 ---------------------------------------
306 The understanding of reStructuredText_ of ``rst-mode`` is used to set
307 all the variables influencing Emacs' understanding of paragraphs. Thus
308 all operations on paragraphs work as usual. For instance
309 ``forward-paragraph`` (``M-}``) works as usual.
311 Indenting and Filling
312 =====================
314 Indentation of text plays a major role in the syntax of
315 reStructuredText_. It is tedious to maintain the indentation
316 manually. ``rst-mode`` understands most of the structure of
317 reStructuredText_ allowing for sophisticated indentation and filling
318 support described in this section.
320 Indenting Text Blocks
321 ---------------------
323 ``rst-mode`` supports indentation of text blocks by the command
324 ``rst-shift-region`` (``C-c C-r TAB``). Mark a region and use ``C-c
325 C-r TAB`` to indent all blocks one tab to the right. Use ``M-- C-c C-r
326 TAB`` to indent the region one tab to the left.
328 You may use arbitrary prefix arguments such as ``M-2`` or ``M-- 2`` to
329 determine the number of tabs you want to indent. A prefix of ``M-0``
330 removes all indentation in the active region.
332 A tab is an indentation making sense for the block at hand in
333 reStructuredText_ syntax. In some cases the exact indentation depends
334 on personal taste. You may customize a couple of variables ``M-x
335 customize-group<RET> rst-indent<RET>`` to match your taste.
337 Indenting Lines While Typing
338 ----------------------------
340 In Emacs_ the ``TAB`` key is often used for indenting the current
341 line. ``rst-mode`` implements this for the sophisticated indentation
342 rules of reStructuredText_. Pressing ``TAB`` cycles through the
343 possible tabs for the current line. In the same manner
344 ``newline-and-indent`` (``C-j``) indents the new line properly.
346 This is very handy while writing lists. Consider this
347 reStructuredText_ bullet list with the cursor at ``@``::
349   * Level 1
351     * Level 2@
353 Type ``C-j`` twice to get this::
355   * Level 1
357     * Level 2
359       @
361 Now you an enter text at this level, or start a new list item by
362 typing another ``*``. Or you may type ``TAB`` to reduce the
363 indentation once::
365   * Level 1
367     * Level 2
369     @
371 Typing another ``TAB`` gets you to the first level::
373   * Level 1
375     * Level 2
377   @
379 Filling
380 -------
382 ``rst-mode`` understanding the indentation rules of reStructuredText_
383 also supports filling paragraphs. Just use ``fill-paragraph``
384 (``M-q``) as you do in other modes.
386 Operating on Lists
387 ==================
389 Lists are supported in various flavors in reStructuredText_.
390 ``rst-mode`` understands reStructuredText_ lists and offers some
391 support for operating on lists. Key bindings for commands for
392 operating on lists start with ``C-c C-l``.
394 Bulleted and Enumerated Lists
395 -----------------------------
397 If you have a couple of plain lines you want to turn into an
398 enumerated list you can invoke ``rst-enumerate-region`` (``C-c C-l
399 C-e``). For example, the following region ::
401   Apples
403   Oranges
405   Bananas
407 becomes ::
409   1. Apples
411   2. Oranges
413   3. Bananas
415 ``rst-bullet-list-region`` (``C-c C-l C-b``) does the same, but
416 results in a bullet list ::
418   * Apples
420   * Oranges
422   * Bananas
424 By default, each paragraph starting on the leftmost line in the
425 highlighted region will be taken to be a single list or enumeration
426 item, for example, enumerating the following::
428    An apple a day
429    keeps the doctor away.
431    But oranges
432    are tastier than apples.
434    If you preferred bananas
435    you may be
436    a monkey.
438 Will result in::
440    1. An apple a day
441       keeps the doctor away.
443    2. But oranges
444       are tastier than apples.
446    3. If you preferred bananas
447       you may be
448       a monkey.
450 If you would like to enumerate each of the lines, use a prefix
451 argument on the preceding commands, e.g.::
453   Apples
454   Oranges
455   Bananas
457 becomes::
459   * Apples
460   * Oranges
461   * Bananas
463 Straightening Existing Bullet List Hierarchies
464 ----------------------------------------------
466 If you invoke ``rst-straighten-bullets-region`` (``C-c C-l C-s``), the
467 existing bullets in the active region will be replaced to reflect
468 their respective level. This does not make a difference in the
469 document structure that reStructuredText_ defines, but looks better
470 in, for example, if all of the top-level bullet items use the
471 character ``-``, and all of the 2nd level items use ``*``, etc.
473 Inserting a List Item
474 ---------------------
476 To start a new list you may invoke ``rst-insert-list`` (``C-c C-l
477 C-i``). You may choose from an item style supported by
478 reStructuredText_.
480 You may also invoke ``rst-insert-list`` at the end of a list item. In
481 this case it inserts a new line containing the markup for the a list
482 item on the same level.
484 Operating on Other Text Blocks
485 ==============================
487 Creating and Removing Line Blocks
488 ---------------------------------
490 To create line blocks, first select the region to convert and invoke
491 ``rst-line-block-region`` ``C-c C-r C-l``. For example, the following
494   Apples
495   Oranges
496   Bananas
498 becomes ::
500   | Apples
501   | Oranges
502   | Bananas
504 This works even if the region is indented. To remove line blocks,
505 select a region and invoke with a prefix argument.
507 Commenting a Region of Text
508 ---------------------------
510 ``rst-mode`` understands reStructuredText_ comments. Use
511 ``comment-dwim`` (``M-;``) to work on comments as usual::
513   Apples
514   Oranges
515   Bananas
517 becomes::
519   ..
520      Apples
521      Oranges
522      Bananas
524 To remove a comment you have to tell this to ``comment-dwim``
525 explicitly by using a prefix argument (``C-u M-;``).
527 Please note that only indented comments are supported properly by the
528 parts of ``comment-dwim`` working on regions.
530 Converting Documents from Emacs
531 ===============================
533 ``rst-mode`` provides a number of functions for running documents
534 being edited through the docutils tools. The key bindings for these
535 commands start with ``C-c C-c``.
537 The main generic function is ``rst-compile`` (``C-c C-c C-c``). It
538 invokes a compilation command with the correct output name for the
539 current buffer and then invokes Emacs' compile function. It also looks
540 for the presence of a ``docutils.conf`` configuration file in the
541 parent directories and adds it to the command line options. There is also
542 ``rst-compile-alt-toolset`` (``C-c C-c C-a``) in case you often need
543 run your document in a second toolset.
545 You can customize the commands being used by setting
546 ``rst-compile-primary-toolset`` and ``rst-compile-secondary-toolset``.
548 Other commands are available for other formats:
550 * ``rst-compile-pseudo-region`` (``C-c C-c C-x``)
552   When crafting documents, it is often convenient to view which data
553   structures docutils will parse them into. You can use to run the
554   active region through ``rst2pseudoxml.py`` and have the output
555   automatically be displayed in a new buffer.
556   
557 * ``rst-compile-pdf-preview`` (``C-c C-c C-p``)
559   Convert the current document to PDF and launch a viewer on the
560   results.
561   
562 * ``rst-compile-slides-preview`` (``C-c C-c C-s``): Convert the
563   current document to S5 slides and view in a web browser.
565 Imenu Support
566 =============
568 Using Imenu
569 -----------
571 Emacs_ has a package called ``imenu``. ``rst-mode`` supports Imenu by
572 adding a function to convert the structure of a reStructuredText_
573 buffer to an Imenu index. Thus you can use invoke ``imenu`` (``M-x
574 imenu``) to navigate through the section index or invoke
575 ``imenu-add-to-menubar`` (``M-x imenu-add-to-menubar``) to add an
576 Imenu menu entry to Emacs' menu bar.
578 Using which function
579 --------------------
581 As a side effect of Imenu support the ``which-func`` package is also
582 supported. Invoke ``which-function-mode`` (``M-x
583 which-function-mode``) to add the name of the current section to the
584 mode line. This is especially useful if you navigate through documents
585 with long sections which do not fit on a single screen.
587 Using the Table of Contents
588 ===========================
590 The sections in a reStructuredText_ document can be used to form a
591 table of contents. ``rst-mode`` can work with such a table of contents
592 in various forms. Key bindings for these commands start with ``C-c
593 C-t``.
595 Navigating Using the Table of Contents
596 --------------------------------------
598 When you are editing long documents, it can be a bit difficult to
599 orient yourself in the structure of your text. To that effect, a
600 function is provided that presents a hierarchically indented table of
601 contents of the document in a temporary buffer, in which you can
602 navigate and press ``Return`` to go to a specific section.
604 Invoke ``rst-toc`` (``C-c C-t C-t``). It presents a temporary buffer
605 that looks something like this::
607   Table of Contents:
608   Debugging Meta-Techniques
609     Introduction
610     Debugging Solution Patterns
611       Recognize That a Bug Exists
612       Subdivide and Isolate
613       Identify and Verify Assumptions
614       Use a Tool for Introspection
615       Change one thing at a time
616       Learn about the System
617     Understanding a bug
618     The Basic Steps in Debugging
619     Attitude
620       Bad Feelings
621       Good Feelings
622     References
624 When you move the cursor to a section title and press ``RET`` or
625 ``f``, the temporary buffer disappears and you are left with the
626 cursor positioned at the chosen section. Use ``q`` in this buffer to
627 just quit it without moving the cursor in the original document. Use
628 ``z`` to zap the buffer altogether.
630 Inserting a Table of Contents
631 -----------------------------
633 Oftentimes in long text documents that are meant to be read directly,
634 a table of contents is inserted at the beginning of the text. In
635 reStructuredText_ documents, since the table of contents is
636 automatically generated by the parser with the ``.. contents::``
637 directive, people generally have not been adding an explicit table of
638 contents to their source documents, and partly because it is too much
639 trouble to edit and maintain.
641 The Emacs_ support for reStructuredText_ provides a function to insert
642 such a table of contents in your document. Since it is not meant to
643 be part of the document text, you should place such a table of
644 contents within a comment, so that it is ignored by the parser. This
645 is the favored usage::
647   .. contents::
648   ..
649       1  Introduction
650       2  Debugging Solution Patterns
651         2.1  Recognize That a Bug Exists
652         2.2  Subdivide and Isolate
653         2.3  Identify and Verify Assumptions
654         2.4  Use a Tool for Introspection
655         2.5  Change one thing at a time
656         2.6  Learn about the System
657       3  Understanding a bug
658       4  The Basic Steps in Debugging
659       5  Attitude
660         5.1  Bad Feelings
661         5.2  Good Feelings
662       6  References
664 Just place the cursor at the top-left corner where you want to insert
665 the TOC and invoke the function ``rst-toc-insert`` with ``C-c C-t
666 C-i``. The table of contents will display all the section titles that
667 are under the location where the insertion occurs. This way you can
668 insert local table of contents by placing them in the appropriate
669 location.
671 You can use a numeric prefix argument to limit the depth of rendering
672 of the TOC.
674 You can customize the look of the TOC by setting the values of the
675 following variables: ``rst-toc-indent``, ``rst-toc-insert-style``,
676 ``rst-toc-insert-max-level``.
678 Maintaining the Table of Contents Up-to-date
679 --------------------------------------------
681 One issue is that you will probably want to maintain the inserted
682 table of contents up-to-date. ``rst-toc-update`` (``C-c C-t C-u``)
683 will automatically locate an inserted table of contents following a
684 ``.. contents::`` directive.
686 Syntax Highlighting via Font-Lock
687 =================================
689 ``rst-mode`` provides syntax highlighting for nearly all to
690 reStructuredText_ constructs.
692 Use ``customize-group rst-faces`` to customize the faces used for
693 font-locking.
695 Customization
696 =============
698 Some aspects of ``rst-mode`` can be configured through the
699 customization feature of Emacs_. Try ::
701   M-x customize-group<RETURN>rst
703 for all customizations or use the respective menu entry. Those
704 customizations which are useful for many people are described in this
705 section.
707 Customizing Section Title Formatting
708 ------------------------------------
710 For a couple of things the reStructuredText_ syntax offers a choice of
711 options on how to do things exactly. Some of these choices influence
712 the operation of ``rst.el`` and thus can be configured. The
713 customizations are contained in the ``rst-adjust`` group.
715 Among these things is the exact layout of section adornments. In fact
716 reStructuredText_ prescribes only the characters and how these
717 characters must be used but the exact use of concrete adornments may
718 be different in every source file. Using the customization option
719 ``rst-preferred-adornments`` you can tell ``rst-mode`` on the exact
720 sequence of adornments you prefer to markup the different levels of
721 sections headers.
723 The title text of over-and-under adornments may be indented.
724 ``rst-default-indent`` tells ``rst-mode`` how many positions a
725 over-and-under adornment should be indented.
727 Finally if you create a completely new section adornment by
728 ``rst-adjust`` the question is on what level the new section adornment
729 should be. ``rst-new-adornment-down`` can be used to create one level
730 lower adornments than the previous section title. By default the new
731 section title is on the same level as the previous one.
733 Please note, that normally the given adornments of a buffer are
734 preferred over your preferences, however. See `Redoing All the
735 Adornments to Your Taste`_ for a method to change this for the whole
736 buffer.
738 Customizing Indentation
739 -----------------------
741 reStructuredText_ uses indentation a lot to signify a certain meaning.
742 In some cases the exact amount of indentation is prescribed by the
743 syntax while in some cases the exact indentation is not fixed. The
744 customization group ``rst-indent`` allows to customize the amount of
745 indentation in these cases.
747 In field lists the content of a field needs to be indented relative to
748 the field label. ``rst-indent-field`` tells ``rst-mode`` the amount of
749 indentation to use for field content. A value of zero always indents
750 according to the content after the field label.
752 The indentation of literal blocks is controlled by
753 ``rst-indent-literal-normal`` and ``rst-indent-literal-minimized``.
754 The first is used when the leading literal tag (``::``) appears alone
755 on a line. The second is used when the minimized style is used where
756 the literal tag follows some text.
758 The indentation of comments is controlled by ``rst-indent-comment``.
759 Of course this makes only sense for the indented comments of
760 reStructuredText_.
762 Customization option ``rst-indent-width`` gives the default
763 indentation when there are no other hints on what amount of
764 indentation to use.
766 Customizing Faces
767 -----------------
769 The faces used for font-locking can be defined in the ``rst-faces``
770 customization group. The customization options ending in ``-face`` are
771 only there for backward compatibility so please leave them as they
772 are.
774 reStructuredText_ sets no limit on the nesting of sections. By default
775 there are six levels of fontification defined. Section titles deeper
776 than six level have no special fontification - only the adornments are
777 fontified. The exact mapping from a level to a face is done by by
778 ``rst-adornment-faces-alist``, however. So if you need fontification
779 deeper than six levels you may want to customize this option. You may
780 also want to customize it if you like the general idea of section
781 title fontification in ``rst-mode`` but for instance prefer a reversed
782 order.
784 Related aspects
785 ===============
787 This section covers some general aspects using Emacs_ for editing
788 reStructuredText_ source. They are not directly related to
789 ``rst-mode`` but may enhance your experience.
791 ``text-mode`` Settings
792 ----------------------
794 Consult the Emacs_ manual for more ``text-mode`` customizations. In
795 particular, you may be interested in setting the following variables,
796 functions and modes that pertain somewhat to ``text-mode``:
798 * ``indent-tabs-mode``
799 * ``colon-double-space``
800 * ``sentence-end-double-space``
801 * ``auto-fill-mode``
802 * ``auto-mode-alist``
804 Editing Tables: Emacs table mode
805 --------------------------------
807 You may want to check out `Emacs table mode`_ to create an edit
808 tables, it allows creating ASCII tables compatible with
809 reStructuredText_.
811 .. _Emacs table mode: http://table.sourceforge.net/
813 Character Processing
814 --------------------
816 Since reStructuredText punts on the issue of character processing,
817 here are some useful resources for Emacs_ users in the Unicode world:
819 * `xmlunicode.el and unichars.el from Norman Walsh
820   <http://nwalsh.com/emacs/xmlchars/index.html>`__
822 * `An essay by Tim Bray, with example code
823   <http://www.tbray.org/ongoing/When/200x/2003/09/27/UniEmacs>`__
825 * For Emacs_ users on Mac OS X, here are some useful useful additions
826   to your .emacs file.
828   - To get direct keyboard input of non-ASCII characters (like
829     "option-e e" resulting in "é" [eacute]), first enable the option
830     key by setting the command key as your meta key::
832         (setq mac-command-key-is-meta t) ;; nil for option key
834     Next, use one of these lines::
836         (set-keyboard-coding-system 'mac-roman)
837         (setq mac-keyboard-text-encoding kTextEncodingISOLatin1)
839     I prefer the first line, because it enables non-Latin-1 characters
840     as well (em-dash, curly quotes, etc.).
842   - To enable the display of all characters in the Mac-Roman charset,
843     first create a fontset listing the fonts to use for each range of
844     characters using charsets that Emacs_ understands::
846       (create-fontset-from-fontset-spec
847        "-apple-monaco-medium-r-normal--10-*-*-*-*-*-fontset-monaco,
848         ascii:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman,
849         latin-iso8859-1:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman,
850         mule-unicode-0100-24ff:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman")
852     Latin-1 doesn't cover characters like em-dash and curly quotes, so
853     "mule-unicode-0100-24ff" is needed.
855     Next, use that fontset::
857         (set-frame-font "fontset-monaco")
859   - To enable cooperation between the system clipboard and the Emacs_
860     kill ring, add this line::
862         (set-clipboard-coding-system 'mac-roman)
864   Other useful resources are in `Andrew Choi's Emacs 21 for Mac OS X
865   FAQ <http://members.shaw.ca/akochoi-emacs/stories/faq.html>`__.
867 Credits
868 =======
870 Part of the original code of ``rst.el`` has been written by Martin
871 Blais and David Goodger and Wei-Wei Guo. The font-locking came from
872 Stefan Merten.
874 Most of the code has been modified, enhanced and extended by Stefan
875 Merten who also is the current maintainer of ``rst.el``.
877 .. _Emacs: http://www.gnu.org/software/emacs/emacs.html
878 .. _reStructuredText: http://docutils.sf.net/rst.html
879 .. _Docutils: http://docutils.sf.net/
883 ..  LocalWords:  reST utf Merten Blais rst el docutils modeline emacs
886    Local Variables:
887    mode: rst
888    indent-tabs-mode: nil
889    fill-column: 70
890    End:
891 ..  LocalWords:  Init mEmacs sInit alist setq txt overlines RET nd py
892 ..  LocalWords:  dwim conf toolset pseudoxml pdf Imenu imenu menubar
893 ..  LocalWords:  func toc xmlunicode unichars eacute charset fontset
894 ..  LocalWords:  kTextEncodingISOLatin charsets monaco ascii latin
895 ..  LocalWords:  iso unicode Choi's Goodger Guo