File: rst.el.html

This package provides major mode rst-mode, which supports documents marked up using the reStructuredText format. Support includes font locking as well as a lot of convenience functions for editing. It does this by defining a Emacs major mode: rst-mode (ReST). This mode is derived from text-mode. This package also contains:

- Functions to automatically adjust and cycle the section underline
  adornments;
- A mode that displays the table of contents and allows you to jump anywhere
  from it;
- Functions to insert and automatically update a TOC in your source
  document;
- Function to insert list, processing item bullets and enumerations
  automatically;
- Font-lock highlighting of most reStructuredText structures;
- Indentation and filling according to reStructuredText syntax;
- Cursor movement according to reStructuredText syntax;
- Some other convenience functions.

See the accompanying document in the docutils documentation about the contents of this package and how to use it.

For more information about reStructuredText, see https://docutils.sourceforge.io/rst.html

For full details on how to use the contents of this file, see https://docutils.sourceforge.io/docs/user/emacs.html

There are a number of convenient key bindings provided by rst-mode. For the bindings, try C-c C-h when in rst-mode. There are also many variables that can be customized, look for defcustom in this file or look for the "rst" customization group contained in the "text" group.

If you use the table-of-contents feature, you may want to add a hook to update the TOC automatically every time you adjust a section title::

  (add-hook 'rst-adjust-hook 'rst-toc-update)

Syntax highlighting: font-lock is enabled by default. If you want to turn off syntax highlighting to rst-mode, you can use the following::

  (setq font-lock-global-modes '(not rst-mode ...))


; DOWNLOAD

The latest release of this file lies in the docutils source code repository:
  https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/tools/editors/emacs/rst.el

; INSTALLATION

Add the following lines to your init file:

  (require 'rst)

If you are using .txt as a standard extension for reST files as https://docutils.sourceforge.io/FAQ.html#what-s-the-standard-filename-extension-for-a-restructuredtext-file suggests you may use one of the Local Variables in Files mechanism Emacs provides to set the major mode automatically. For instance you may use::

   .. -*- mode: rst -*-

in the very first line of your file. The following code is useful if you want automatically enter rst-mode from any file with compatible extensions:

(setq auto-mode-alist (append '(("\\\\.txt\\\\'" . rst-mode) ("\\\\.rst\\\\'" . rst-mode) ("\\\\.rest\\\\'" . rst-mode)) auto-mode-alist))

Defined variables (57)

rst-adjust-hookHooks to be run after running ‘rst-adjust’.
rst-adornment-charsCharacters which may be used in adornments for sections and transitions.
rst-adornment-faces-alistFaces for the various adornment types.
rst-all-ttls-cacheAll section adornments in the buffer as found by ‘rst-all-ttls’.
rst-arabic-to-romanList of maps between Arabic numbers and their Roman numeral equivalents.
rst-bulletsList of all possible bullet characters for bulleted lists.
rst-compile-primary-toolsetThe default tool-set for ‘rst-compile’.
rst-compile-secondary-toolsetThe default tool-set for ‘rst-compile’ with a prefix argument.
rst-compile-toolsetsTable describing the command to use for each tool-set.
rst-cvs-revThe CVS revision of this file. CVS revision is the development revision.
rst-cvs-timestampThe CVS time stamp of this file.
rst-default-indentNumber of characters to indent the section title.
rst-font-lock-adornment-levelStorage for ‘rst-font-lock-handle-adornment-matcher’.
rst-font-lock-adornment-matchStorage for match for current adornment.
rst-font-lock-find-unindented-line-beginBeginning of the match if ‘rst-font-lock-find-unindented-line-end’.
rst-font-lock-find-unindented-line-endEnd of the match as determined by ‘rst-font-lock-find-unindented-line-limit’.
rst-font-lock-keywordsKeywords to highlight in rst mode.
rst-hdr-hierarchy-cacheSection hierarchy in the buffer as determined by ‘rst-hdr-hierarchy’.
rst-indent-commentDefault indentation for first line of a comment.
rst-indent-fieldIndentation for first line after a field or 0 to always indent for content.
rst-indent-literal-minimizedDefault indentation for literal block after a minimized markup.
rst-indent-literal-normalDefault indentation for literal block after a markup on an own line.
rst-indent-widthIndentation when there is no more indentation point given.
rst-initial-itemsList of initial items. It’s a collection of bullets and enumerations.
rst-max-inline-lengthMaximum length of inline markup to recognize.
rst-minor-modeNon-nil if Rst minor mode is enabled.
rst-minor-mode-hookHook run after entering or leaving ‘rst-minor-mode’.
rst-mode-abbrev-tableAbbrev table used while in ‘rst-mode’.
rst-mode-hookHook run when ‘rst-mode’ is turned on.
rst-mode-mapKeymap for reStructuredText mode commands.
rst-mode-syntax-tableSyntax table used while in ‘rst-mode’.
rst-new-adornment-downControls level of new adornment for section headers.
rst-official-cvs-revCVS revision of this file in the official version.
rst-official-versionOfficial version of the package.
rst-pdf-programProgram used to preview PDF files.
rst-preferred-adornmentsPreferred hierarchy of section title adornments.
rst-preferred-bulletsList of favorite bullets.
rst-preferred-decorationsPreferred hierarchy of section title adornments.
rst-re-alistAlist mapping symbols from ‘rst-re-alist-def’ to regex strings.
rst-re-alist-defDefinition alist of relevant regexes.
rst-shift-basic-offsetIndentation when there is no more indentation point given.
rst-slides-programProgram used to preview S5 slides.
rst-svn-revThe SVN revision of this file.
rst-svn-timestampThe SVN time stamp of this file.
rst-toc-buffer-nameName of the Table of Contents buffer.
rst-toc-indentIndentation for table-of-contents display.
rst-toc-insert-max-levelIf non-nil, maximum depth of the inserted TOC.
rst-toc-insert-number-separatorSeparator that goes between the TOC number and the title.
rst-toc-insert-styleInsertion style for table-of-contents.
rst-toc-link-keymapKeymap used for links in TOC.
rst-toc-mode-abbrev-tableAbbrev table for ‘rst-toc-mode’.
rst-toc-mode-hookHook run after entering ‘rst-toc-mode’.
rst-toc-mode-mapKeymap for ‘rst-toc-mode’.
rst-toc-mode-return-wincfgWindow configuration to which to return when leaving the TOC.
rst-toc-mode-syntax-tableSyntax table for ‘rst-toc-mode’.
rst-uri-schemesSupported URI schemes.
rst-versionThe version string.

Defined functions (201)

copy-rst-Ado(ARG)
copy-rst-Stn(ARG)
rst-Ado--style(rst-Ado--style X)
rst-Ado--style--inliner(INLINE--FORM X)
rst-Ado--validate-char(CHAR)
rst-Ado-char(rst-Ado-char X)
rst-Ado-char--inliner(INLINE--FORM X)
rst-Ado-equal(SELF OTHER)
rst-Ado-is-over-and-under(SELF)
rst-Ado-is-section(SELF)
rst-Ado-is-simple(SELF)
rst-Ado-is-transition(SELF)
rst-Ado-new-invert(ADO-ARG)
rst-Ado-new-over-and-under(CHAR-ARG)
rst-Ado-new-simple(CHAR-ARG)
rst-Ado-new-transition()
rst-Ado-new-transition--cmacro(CL-WHOLE-ARG)
rst-Ado-p(X)
rst-Ado-p--inliner(INLINE--FORM X)
rst-Ado-position(SELF ADOS)
rst-Hdr--validate-ado(ADO)
rst-Hdr--validate-indent(INDENT ADO LAX)
rst-Hdr-ado(rst-Hdr-ado X)
rst-Hdr-ado--inliner(INLINE--FORM X)
rst-Hdr-ado-map(SELVES)
rst-Hdr-get-char(SELF)
rst-Hdr-indent(rst-Hdr-indent X)
rst-Hdr-indent--inliner(INLINE--FORM X)
rst-Hdr-is-over-and-under(SELF)
rst-Hdr-member-ado(SELF HDRS)
rst-Hdr-new(ADO-ARG INDENT-ARG)
rst-Hdr-new-invert(ADO-ARG INDENT-ARG)
rst-Hdr-new-lax(ADO-ARG INDENT-ARG)
rst-Hdr-p(X)
rst-Hdr-p--inliner(INLINE--FORM X)
rst-Hdr-preferred-adornments()
rst-Stn--validate-children(CHILDREN TTL)
rst-Stn--validate-level(LEVEL TTL)
rst-Stn--validate-ttl(TTL)
rst-Stn-children(rst-Stn-children X)
rst-Stn-children--inliner(INLINE--FORM X)
rst-Stn-get-text(SELF &optional DEFAULT)
rst-Stn-get-title-beginning(SELF)
rst-Stn-is-top(SELF)
rst-Stn-level(rst-Stn-level X)
rst-Stn-level--inliner(INLINE--FORM X)
rst-Stn-new(TTL-ARG LEVEL-ARG CHILDREN-ARG)
rst-Stn-p(X)
rst-Stn-p--inliner(INLINE--FORM X)
rst-Stn-ttl(rst-Stn-ttl X)
rst-Stn-ttl--inliner(INLINE--FORM X)
rst-Ttl--new(ADO-ARG MATCH-ARG INDENT-ARG TEXT-ARG)
rst-Ttl--validate-ado(ADO)
rst-Ttl--validate-indent(INDENT ADO)
rst-Ttl--validate-match(MATCH ADO)
rst-Ttl--validate-text(TEXT ADO)
rst-Ttl-ado(rst-Ttl-ado X)
rst-Ttl-ado--inliner(INLINE--FORM X)
rst-Ttl-contains(SELF POSITION)
rst-Ttl-from-buffer(ADO BEG-OVR BEG-TXT BEG-UND TXT)
rst-Ttl-get-beginning(SELF)
rst-Ttl-get-end(SELF)
rst-Ttl-get-title-beginning(SELF)
rst-Ttl-hdr(rst-Ttl-hdr X)
rst-Ttl-hdr--inliner(INLINE--FORM X)
rst-Ttl-indent(rst-Ttl-indent X)
rst-Ttl-indent--inliner(INLINE--FORM X)
rst-Ttl-is-candidate(SELF)
rst-Ttl-is-section(SELF)
rst-Ttl-match(rst-Ttl-match X)
rst-Ttl-match--inliner(INLINE--FORM X)
rst-Ttl-p(X)
rst-Ttl-p--inliner(INLINE--FORM X)
rst-Ttl-text(rst-Ttl-text X)
rst-Ttl-text--inliner(INLINE--FORM X)
rst-adaptive-fill()
rst-adjust(PFXARG)
rst-adjust-adornment(PFXARG)
rst-adjust-new-hdr(TOGGLE-STYLE REVERSE TTL)
rst-adjust-region(DEMOTE)
rst-adjust-section(TOGGLE-STYLE REVERSE)
rst-adjust-section-title(PFXARG)
rst-adornment-complete-p(ADO INDENT)
rst-adornment-level(ADO)
rst-all-stn()
rst-all-ttls()
rst-all-ttls-compute()
rst-all-ttls-with-level()
rst-apply-indented-blocks(BEG END IND FUN)
rst-arabic-to-roman(NUM)
rst-backward-section(OFFSET)
rst-bullet-list-region(BEG END ALL)
rst-classify-adornment(ADORNMENT END &optional ACCEPT-OVER-ONLY)
rst-comment-indent()
rst-comment-insert-comment()
rst-comment-line-break(&optional SOFT)
rst-comment-region(BEG END &optional ARG)
rst-compile(&optional USE-ALT)
rst-compile-alt-toolset()
rst-compile-find-conf()
rst-compile-pdf-preview()
rst-compile-pseudo-region()
rst-compile-slides-preview()
rst-compute-tabs(PT)
rst-convert-bullets-to-enumeration(BEG END)
rst-define-key(KEYMAP KEY DEF &rest DEPRECATED)
rst-delete-entire-line(N)
rst-deprecated-adjust()
rst-deprecated-backward-section()
rst-deprecated-bullet-list-region()
rst-deprecated-compile()
rst-deprecated-compile-alt-toolset()
rst-deprecated-compile-pdf-preview()
rst-deprecated-compile-pseudo-region()
rst-deprecated-compile-slides-preview()
rst-deprecated-convert-bullets-to-enumeration()
rst-deprecated-enumerate-region()
rst-deprecated-forward-section()
rst-deprecated-line-block-region()
rst-deprecated-mark-section()
rst-deprecated-shift-region()
rst-deprecated-straighten-bullets-region()
rst-deprecated-straighten-sections()
rst-deprecated-toc-follow-link()
rst-deprecated-toc-insert()
rst-deprecated-toc-update()
rst-destructuring-dolist((ARGLIST LIST &optional RESULT) &rest BODY)
rst-display-adornments-hierarchy()
rst-display-hdr-hierarchy()
rst-enumerate-region(BEG END ALL)
rst-extract-version(DELIM-RE HEAD-RE RE TAIL-RE VAR &optional DEFAULT)
rst-find-begs(BEG END RST-RE-BEG)
rst-find-leftmost-column(BEG END)
rst-font-lock-extend-region()
rst-font-lock-extend-region-extend(PT DIR)
rst-font-lock-extend-region-internal(BEG END)
rst-font-lock-find-unindented-line-limit(IND-PNT)
rst-font-lock-find-unindented-line-match(LIMIT)
rst-font-lock-handle-adornment-matcher(LIMIT)
rst-font-lock-handle-adornment-pre-match-form(ADO ADO-END)
rst-force-fill-paragraph()
rst-forward-indented-block(&optional COLUMN LIMIT)
rst-forward-line(&optional N)
rst-forward-line-looking-at(N RST-RE-ARGS &optional FUN)
rst-forward-line-strict(N &optional LIMIT)
rst-forward-section(OFFSET)
rst-get-previous-hdr()
rst-goto-section(LINK-BUF LINK-PNT KILL)
rst-hdr-hierarchy(&optional IGNORE-POSITION)
rst-imenu-convert-cell(STN)
rst-imenu-create-index()
rst-indent-line(&optional DFLT)
rst-infer-hdr-hierarchy(HDRS)
rst-insert-list(&optional PREFER-ROMAN)
rst-insert-list-continue(IND TAG TAB PREFER-ROMAN)
rst-insert-list-new-item()
rst-insert-list-new-tag(TAG)
rst-join-paragraph()
rst-line-block-region(BEG END &optional WITH-EMPTY)
rst-line-tabs()
rst-mark-section(&optional COUNT ALLOW-EXTEND)
rst-minor-mode(&optional ARG)
rst-mode()
rst-new-preferred-hdr(SEEN PREV)
rst-next-hdr(HDR HIER PREV DOWN)
rst-re(&rest ARGS)
rst-remaining-stn(UNPROCESSED EXPECTED)
rst-repeat-last-character(USE-NEXT)
rst-replace-lines(FROMCHAR TOCHAR)
rst-reset-section-caches()
rst-roman-to-arabic(STRING)
rst-shift-region(BEG END CNT)
rst-stn-containing-point(STN &optional POINT)
rst-straighten-adornments()
rst-straighten-bullets-region(BEG END)
rst-straighten-sections()
rst-testcover-add-1value(FUN)
rst-testcover-add-compose(FUN)
rst-toc()
rst-toc-follow-link(LINK-BUF LINK-PNT KILL)
rst-toc-get-link(LINK-BUF LINK-PNT)
rst-toc-insert(&optional MAX-LEVEL)
rst-toc-insert-children(CHILDREN BUF STYLE DEPTH INDENT NUMBERING KEYMAP TGT-STN)
rst-toc-insert-link(PFX STN BUF KEYMAP)
rst-toc-insert-stn(STN BUF STYLE DEPTH INDENT NUMBERING KEYMAP TGT-STN)
rst-toc-insert-tree(STN BUF STYLE DEPTH KEYMAP TGT-STN)
rst-toc-insert-update()
rst-toc-mode()
rst-toc-mode-follow-link-kill()
rst-toc-mode-goto-section()
rst-toc-mode-mouse-follow-link-kill(EVENT)
rst-toc-mode-mouse-goto(EVENT KILL)
rst-toc-mode-mouse-goto-kill(EVENT)
rst-toc-mode-return(KILL)
rst-toc-mode-return-kill()
rst-toc-mouse-follow-link(EVENT KILL)
rst-toc-quit-window(KILL)
rst-toc-update()
rst-ttl-at-point()
rst-uncomment-region(BEG END &optional ARG)
rst-update-section(HDR)

Defined faces (17)

rst-adornmentFace used for the adornment of a section header.
rst-blockFace used for all syntax marking up a special block.
rst-commentFace used for comments.
rst-definitionFace used for all other defining constructs.
rst-directiveFace used for directives and roles.
rst-emphasis1Face used for simple emphasis.
rst-emphasis2Face used for double emphasis.
rst-externalFace used for field names and interpreted text.
rst-level-1Default face for section title text at level 1.
rst-level-2Default face for section title text at level 2.
rst-level-3Default face for section title text at level 3.
rst-level-4Default face for section title text at level 4.
rst-level-5Default face for section title text at level 5.
rst-level-6Default face for section title text at level 6.
rst-literalFace used for literal text.
rst-referenceFace used for references to a definition.
rst-transitionFace used for a transition.