summaryrefslogtreecommitdiff
path: root/docutils/tools/editors
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-08-17 13:59:12 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-08-17 13:59:12 +0000
commita4bc0d09f3d1f633a5780976d1f913e083c9564a (patch)
tree1777475e88463b08438f0719be97cc087554eadd /docutils/tools/editors
parent60c69f8cf97125135948a3d35b7698ee80921137 (diff)
parent2818db9a234cc37008c5f2bb0e821f9b1fa92de2 (diff)
downloaddocutils-0.3.9.tar.gz
re-added docutils-0.3.9 tag one level deeper (without web/ and sandboxes/)docutils-0.3.9
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.3.9@3815 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/tools/editors')
-rw-r--r--docutils/tools/editors/README.txt19
-rw-r--r--docutils/tools/editors/emacs/README.txt91
-rw-r--r--docutils/tools/editors/emacs/docutils.conf2
-rw-r--r--docutils/tools/editors/emacs/restructuredtext.el596
-rw-r--r--docutils/tools/editors/emacs/rst-html.el129
-rw-r--r--docutils/tools/editors/emacs/rst-mode.el700
-rw-r--r--docutils/tools/editors/emacs/tests/tests-adjust-section.el240
7 files changed, 0 insertions, 1777 deletions
diff --git a/docutils/tools/editors/README.txt b/docutils/tools/editors/README.txt
deleted file mode 100644
index f3786ef2e..000000000
--- a/docutils/tools/editors/README.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-======================================
- Editor Support for reStructuredText_
-======================================
-
-:Date: $Date$
-
-The files in this directory contain support code for reStructuredText
-editing for the following editors:
-
-* `Emacs <emacs>`__
-
-External links:
-
-* `reStructuredText syntax highlighting mode for vim
- <http://www.vim.org/scripts/script.php?script_id=973>`__
-
-Additions are welcome.
-
-.. _reStructuredText: http://docutils.sf.net/rst.html
diff --git a/docutils/tools/editors/emacs/README.txt b/docutils/tools/editors/emacs/README.txt
deleted file mode 100644
index d4359213b..000000000
--- a/docutils/tools/editors/emacs/README.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-.. -*- coding: iso-8859-1 -*-
-
-=====================================
- Emacs Support for reStructuredText_
-=====================================
-
-:Date: $Date$
-
-
-Directory Contents
-==================
-
-This directory contains the following Emacs lisp package files:
-
-* restructuredtext.el by Martin Blais and David Goodger
-
- Support code for editing reStructuredText with Emacs indented-text
- mode.
-
-* rst-mode.el by Stefan Merten
-
- Provides support for documents marked up using the reStructuredText
- format, including font locking as well as some convenience functions
- for editing.
-
-* rst-html.el by Martin Blais
-
- Provides a few functions and variables that can help in automating
- the conversion of reST documents to HTML from within Emacs.
-
-Each file includes specific usage instructions. To install a package,
-put a copy of the package file in a directory on your ``load-path``
-(use ``C-h v load-path`` to check).
-
-
-Character Processing Notes
-==========================
-
-Since reStructuredText punts on the issue of character processing,
-here are some useful resources for Emacs users in the Unicode world:
-
-* `xmlunicode.el and unichars.el from Norman Walsh
- <http://nwalsh.com/emacs/xmlchars/index.html>`__
-
-* `An essay by Tim Bray, with example code
- <http://www.tbray.org/ongoing/When/200x/2003/09/27/UniEmacs>`__
-
-* For Emacs users on Mac OS X, here are some useful useful additions
- to your .emacs file.
-
- - To get direct keyboard input of non-ASCII characters (like
- "option-e e" resulting in "é" [eacute]), first enable the option
- key by setting the command key as your meta key::
-
- (setq mac-command-key-is-meta t) ;; nil for option key
-
- Next, use one of these lines::
-
- (set-keyboard-coding-system 'mac-roman)
- (setq mac-keyboard-text-encoding kTextEncodingISOLatin1)
-
- I prefer the first line, because it enables non-Latin-1 characters
- as well (em-dash, curly quotes, etc.).
-
- - To enable the display of all characters in the Mac-Roman charset,
- first create a fontset listing the fonts to use for each range of
- characters using charsets that Emacs understands::
-
- (create-fontset-from-fontset-spec
- "-apple-monaco-medium-r-normal--10-*-*-*-*-*-fontset-monaco,
- ascii:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman,
- latin-iso8859-1:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman,
- mule-unicode-0100-24ff:-apple-monaco-medium-r-normal--10-100-75-75-m-100-mac-roman")
-
- Latin-1 doesn't cover characters like em-dash and curly quotes, so
- "mule-unicode-0100-24ff" is needed.
-
- Next, use that fontset::
-
- (set-frame-font "fontset-monaco")
-
- Other useful resources are in `Andrew Choi's Emacs 21 for Mac OS X
- FAQ <http://members.shaw.ca/akochoi-emacs/stories/faq.html>`__.
-
-No matter what platform (or editor) you're using, I recommend the
-ProFont__ programmer's font. It's monospaced, small but readable,
-similar characters are visually distinctive (like "1lI|", "0O", "ao",
-and ".,"), and free.
-
-__ http://www.tobias-jung.de/seekingprofont/
-.. _reStructuredText: http://docutils.sf.net/rst.html
diff --git a/docutils/tools/editors/emacs/docutils.conf b/docutils/tools/editors/emacs/docutils.conf
deleted file mode 100644
index a74f08d4a..000000000
--- a/docutils/tools/editors/emacs/docutils.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-[general]
-input_encoding: latin-1
diff --git a/docutils/tools/editors/emacs/restructuredtext.el b/docutils/tools/editors/emacs/restructuredtext.el
deleted file mode 100644
index fe39265b2..000000000
--- a/docutils/tools/editors/emacs/restructuredtext.el
+++ /dev/null
@@ -1,596 +0,0 @@
-;; Authors: David Goodger <goodger@python.org>,
-;; Martin Blais <blais@furius.ca>
-;; Date: $Date$
-;; Copyright: This module has been placed in the public domain.
-;;
-;; Support code for editing reStructuredText with Emacs indented-text mode.
-;; The goal is to create an integrated reStructuredText editing mode.
-;;
-;; Installation instructions
-;; -------------------------
-;;
-;; Add this line to your .emacs file::
-;;
-;; (require 'restructuredtext)
-;;
-;; You should bind the versatile sectioning command to some key in the text-mode
-;; hook. Something like this::
-;;
-;; (defun user-rst-mode-hook ()
-;; (local-set-key [(control ?=)] 'rest-adjust-section-title)
-;; )
-;; (add-hook 'text-mode-hook 'user-rst-mode-hook)
-;;
-;; Other specialized and more generic functions are also available.
-;; Note that C-= is a good binding, since it allows you to specify a negative
-;; arg easily with C-- C-= (easy to type), as well as ordinary prefix arg with
-;; C-u C-=.
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Generic text functions that are more convenient than the defaults.
-;;
-
-(defun replace-lines (fromchar tochar)
- "Replace flush-left lines, consisting of multiple FROMCHAR characters,
-with equal-length lines of TOCHAR."
- (interactive "\
-cSearch for flush-left lines of char:
-cand replace with char: ")
- (save-excursion
- (let* ((fromstr (string fromchar))
- (searchre (concat "^" (regexp-quote fromstr) "+ *$"))
- (found 0))
- (condition-case err
- (while t
- (search-forward-regexp searchre)
- (setq found (1+ found))
- (search-backward fromstr) ;; point will be *before* last char
- (setq p (1+ (point)))
- (beginning-of-line)
- (setq l (- p (point)))
- (kill-line)
- (insert-char tochar l))
- (search-failed
- (message (format "%d lines replaced." found)))))))
-
-(defun join-paragraph ()
- "Join lines in current paragraph into one line, removing end-of-lines."
- (interactive)
- (let ((fill-column 65000)) ; some big number
- (call-interactively 'fill-paragraph)))
-
-(defun force-fill-paragraph ()
- "Fill paragraph at point, first joining the paragraph's lines into one.
-This is useful for filling list item paragraphs."
- (interactive)
- (join-paragraph)
- (fill-paragraph nil))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; The following functions implement a smart automatic title sectioning feature.
-;; The idea is that with the cursor sitting on a section title, we try to get as
-;; much information from context and do the best thing. This function can be
-;; invoked many time and/or with prefix argument to rotate between the various
-;; options.
-;;
-;; There are two styles of sectioning:
-;;
-;; 1. simple-underline, e.g. |Some Title
-;; |----------
-;;
-;; 2. overline-and-underline, e.g. |------------
-;; | Some Title
-;; |------------
-;;
-;; Some notes:
-;;
-;; - the underlining character that is used depends on context. The file is
-;; scanned to find other sections and an appropriate character is selected.
-;; If the function is invoked on a section that is complete, the character
-;; is rotated among the existing ones.
-;;
-;; Note that when rotating the underlining characters, if we come to the end
-;; of the hierarchy of characters, the variable rest-preferred-characters
-;; is consulted to propose a new underline char, and if continued, we cycle
-;; the underline characters all over again. Set this variable to nil if
-;; you want to limit the underlining character propositions to the existing
-;; underlines in the file.
-;;
-;; - prefix argument is used to alternate the sectioning style.
-;;
-;; Examples:
-;;
-;; |Some Title ---> |Some Title
-;; | |----------
-;;
-;; |Some Title ---> |Some Title
-;; |----- |----------
-;;
-;; | |------------
-;; | Some Title ---> | Some Title
-;; | |------------
-;;
-;; In overline-and-underline style, a variable is available to select how much
-;; space to leave before and after the title (it can be zero) when alternating
-;; the style. Note that if the title already has some whitespace in front of
-;; it, we don't adjust it to the variable setting, we use the whitespace that is
-;; already there for adjustment.
-
-(defun rest-line-single-char-p (&optional accept-special)
- "Predicate return the unique char if the current line is
- composed only of a single repeated non-whitespace
- character. This returns the char even if there is whitespace at
- the beginning of the line.
-
- If ACCEPT-SPECIAL is specified we do not ignore special sequences
- which normally we would ignore when doing a search on many lines.
- For example, normally we have cases to ignore commonly occuring
- patterns, such as :: or ...; with the flag do not ignore them."
- (save-excursion
- (back-to-indentation)
- (if (not (looking-at "\n"))
- (let ((c (thing-at-point 'char)))
- (if (and (looking-at (format "[%s]+\\s-*$" c))
- (or accept-special
- (and
- ;; common patterns
- (not (looking-at "::\\s-*$"))
- (not (looking-at "\\.\\.\\.\\s-*$"))
- ;; discard one char line
- (not (looking-at ".\\s-*$"))
- )))
- (string-to-char c))
- ))
- ))
-
-(defun rest-find-last-section-char ()
- "Looks backward for the last section char found in the file."
-
- (let (c)
- (save-excursion
- (while (and (not c) (not (bobp)))
- (forward-line -1)
- (setq c (rest-line-single-char-p))
- ))
- c))
-
-(defun rest-current-section-char (&optional point)
- "Gets the section char around the current point."
- (save-excursion
- (if point (goto-char point))
- (let ((offlist '(0 1 -2))
- loff
- rval
- c)
- (while offlist
- (forward-line (car offlist))
- (setq c (rest-line-single-char-p 1))
- (if c
- (progn (setq offlist nil
- rval c))
- (setq offlist (cdr offlist)))
- )
- rval
- )))
-
-(defun rest-initial-sectioning-style (&optional point)
- "Looks around point and attempts to determine the sectioning
- style, between simple-underline and overline-and-underline. If
- there aren't any existing over/underlines, return nil."
- (save-excursion
- (if point (goto-char point))
- (let (ou)
- (save-excursion
- (setq ou (mapcar
- (lambda (x)
- (forward-line x)
- (rest-line-single-char-p))
- '(-1 2))))
- (beginning-of-line)
- (cond
- ((equal ou '(nil nil)) nil)
- ((car ou) 'over-and-under) ;; we only need check the overline
- (t 'simple)
- )
- )))
-
-(defun rest-all-section-chars (&optional ignore-lines)
- "Finds all the section chars in the entire file and orders them
- hierarchically, removing duplicates. Basically, returns a list
- of the section underlining characters.
-
- Optional parameters IGNORE-AROUND can be a list of lines to
- ignore."
-
- (let (chars
- c
- (curline 1))
- (save-excursion
- (beginning-of-buffer)
- (while (< (point) (buffer-end 1))
- (if (not (memq curline ignore-lines))
- (progn
- (setq c (rest-line-single-char-p))
- (if c
- (progn
- (add-to-list 'chars c t)
- ))) )
- (forward-line 1) (setq curline (+ curline 1))
- ))
- chars))
-
-(defun rest-suggest-new-char (allchars)
- "Given the last char that has been seen, suggest a new,
- different character, different from all that have been seen."
- (let ((potentials (copy-sequence rest-preferred-characters)))
- (dolist (x allchars)
- (setq potentials (delq x potentials))
- )
- (car potentials)
- ))
-
-(defun rest-update-section (underlinechar style &optional indent)
- "Unconditionally updates the overline/underline of a section
- title using the given character CHAR, with STYLE 'simple or
- 'over-and-under, in which case with title whitespace separation
- on each side with INDENT whitespaces. If the style is 'simple,
- whitespace before the title is removed.
-
- If there are existing overline and/or underline, they are
- removed before adding the requested adornments."
-
- (interactive)
- (let (marker
- len
- ec
- (c ?-))
-
- (end-of-line)
- (setq marker (point-marker))
-
- ;; Fixup whitespace at the beginning and end of the line
- (if (or (null indent) (eq style 'simple))
- (setq indent 0))
- (beginning-of-line)
- (delete-horizontal-space)
- (insert (make-string indent ? ))
-
- (end-of-line)
- (delete-horizontal-space)
-
- ;; Set the current column, we're at the end of the title line
- (setq len (+ (current-column) indent))
-
- ;; Remove previous line if it consists only of a single repeated character
- (save-excursion
- (forward-line -1)
- (and (rest-line-single-char-p 1)
- (kill-line 1)))
-
- ;; Remove following line if it consists only of a single repeated character
- (save-excursion
- (forward-line +1)
- (and (rest-line-single-char-p 1)
- (kill-line 1))
- ;; Add a newline if we're at the end of the buffer, for the subsequence
- ;; inserting of the underline
- (if (= (point) (buffer-end 1))
- (newline 1)))
-
- ;; Insert overline
- (if (eq style 'over-and-under)
- (save-excursion
- (beginning-of-line)
- (open-line 1)
- (insert (make-string len underlinechar))))
-
- ;; Insert underline
- (forward-line +1)
- (open-line 1)
- (insert (make-string len underlinechar))
-
- (forward-line +1)
- (goto-char marker)
- ))
-
-(defvar rest-preferred-characters '(?= ?- ?~ ?+ ?` ?# ?@)
- "Preferred ordering of underline characters. This sequence is
- consulted to offer a new underline character when we rotate the
- underlines at the end of the existing hierarchy of characters.")
-
-(defvar rest-default-under-and-over-indent 1
- "Number of characters to indent the section title when toggling
- sectioning styles. This is used when switching from a simple
- section style to a over-and-under style.")
-
-(defun rest-adjust-section-title ()
- "Adjust/rotate the section underlining for the section around
- point.
-
- This function is the main entry point of this module and is a
- bit of a swiss knife. It is meant as the single function to
- invoke to adjust the underlines (and possibly overlines) of a
- section title in restructuredtext. The next action it takes
- depends on context around the point, and it is meant to be
- invoked possibly more than once. Basically, this function deals
- with:
-
- - underlining a title if it does not have an underline;
- - adjusting the length of the underline characters to fit a
- modified title;
- - rotating the underlines/overlines in the set of already
- existing underline chars used in the file;
- - switching between simple underline and over-and-under style
- sectioning (or box style).
-
- Here are the gory details:
-
- - If the current line has no underline character around it,
- search backwards for a previously used underlining character,
- and underline the current line as a section title (also see
- prefix argument below).
-
- If no pre-existing underlining character is found in the on
- the line, we use the last seen underline char or consult the
- first element of rest-preferred-characters if this is the
- first title in the entire file.
-
- - If the current line does have an underline or overline, and
- if
-
- - the underline do not extend to exactly the end of the
- title line, this changes the length of the under(over)lines
- to fit exactly the section title;
-
- - the underline length is already adjusted to the end of the
- title line, we search the file for the underline chars, and
- we rotate the current title's underline character with that
- list (going down the hierarchy that is present in the
- file);
-
- If there is a prefix argument, switch the style between the
- initial sectioning style and the other sectioning style. The
- two styles are overline-and-underline and simple-underline.
-
- If however, you are on a complete section title and you
- specify a negative argument, the effect of the prefix
- argument is to change the direction of rotation of the
- underline characters. Thus using a prefix argument and a
- negative prefix argument achieves a different result in the
- case of rotation.
-
- Note that the initial style of underlining (simple underline
- or box-style) depends on if there is whitespace at the start
- of the line. If there are already underlines/overlines,
- those are used to select the style, otherwise if there is
- whitespace at the front of the title overline-and-underline
- style is chosen, and otherwise simple underline.
-
- Also, note that this should work on the section title line as
- well as on a complete or incomplete underline for a
- title (first thing we check for that case and move the cursor
- up a line if needed)."
-
- (interactive)
-
- ;; check if we're on an underline under a title line, and move the cursor up
- ;; if it is so.
- (if (and (or (rest-line-single-char-p 1)
- (looking-at "^\\s-*$"))
- (save-excursion
- (forward-line -1)
- (beginning-of-line)
- (looking-at "^.+$")))
- (forward-line -1))
-
- (let (
- ;; find current sectioning character
- (curchar (rest-current-section-char))
- ;; find current sectioning style
- (init-style (rest-initial-sectioning-style))
- ;; find current indentation of title line
- (curindent (save-excursion
- (back-to-indentation)
- (current-column)))
-
- ;; ending column
- (endcol (- (line-end-position) (line-beginning-position)))
- )
-
- ;; if there is no current style found...
- (if (eq init-style nil)
- ;; select based on the whitespace at the beginning of the line
- (save-excursion
- (beginning-of-line)
- (setq init-style
- (if (looking-at "^\\s-+") 'over-and-under 'simple))))
-
- ;; if we're switching characters, we're going to simply change the
- ;; sectioning style. this branch is also taken if there is no current
- ;; sectioning around the title.
- (if (or (and current-prefix-arg
- (not (< (prefix-numeric-value current-prefix-arg) 0)))
- (eq curchar nil))
-
- ;; we're switching characters or there is currently no sectioning
- (progn
- (setq curchar
- (or curchar
- (rest-find-last-section-char)
- (car (rest-all-section-chars))
- (car rest-preferred-characters)
- ?=))
-
- ;; if there is a current indent, reuse it, otherwise use default
- (if (= curindent 0)
- (setq curindent rest-default-under-and-over-indent))
-
- (rest-update-section
- curchar
- (if (and current-prefix-arg
- (not (< (prefix-numeric-value current-prefix-arg) 0)))
- (if (eq init-style 'over-and-under) 'simple 'over-and-under)
- init-style)
- curindent)
- )
-
- ;; else we're not switching characters, and there is some sectioning
- ;; already present, so check if the current sectioning is complete and
- ;; correct.
- (let ((exps (concat "^"
- (regexp-quote (make-string
- (+ endcol curindent) curchar))
- "$")))
- (if (or
- (not (save-excursion (forward-line +1)
- (beginning-of-line)
- (looking-at exps)))
- (and (eq init-style 'over-and-under)
- (not (save-excursion (forward-line -1)
- (beginning-of-line)
- (looking-at exps)))))
-
- ;; the current sectioning needs to be fixed/updated!
- (rest-update-section curchar init-style curindent)
-
- ;; the current sectioning is complete, rotate characters
- (let* ( (curline (+ (count-lines (point-min) (point))
- (if (bolp) 1 0)))
- (allchars (rest-all-section-chars
- (list (- curline 1) curline (+ curline 1))))
-
- (rotchars
- (append allchars
- (filter 'identity
- (list
- ;; suggest a new char
- (rest-suggest-new-char allchars)
- ;; rotate to first char
- (car allchars)))))
- (nextchar
- (or (cadr (memq curchar
- (if (< (prefix-numeric-value
- current-prefix-arg) 0)
- (reverse rotchars) rotchars)))
- (car allchars)) ) )
-
-
- (if nextchar
- (rest-update-section nextchar init-style curindent))
- )))
- )))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Generic character repeater function.
-;;
-;; For sections, better to use the specialized function above, but this can
-;; be useful for creating separators.
-
-(defun repeat-last-character (&optional tofill)
- "Fills the current line up to the length of the preceding line (if not
-empty), using the last character on the current line. If the preceding line is
-empty, we use the fill-column.
-
-If a prefix argument is provided, use the next line rather than the preceding
-line.
-
-If the current line is longer than the desired length, shave the characters off
-the current line to fit the desired length.
-
-As an added convenience, if the command is repeated immediately, the alternative
-column is used (fill-column vs. end of previous/next line)."
- (interactive)
- (let* ((curcol (current-column))
- (curline (+ (count-lines (point-min) (point))
- (if (eq curcol 0) 1 0)))
- (lbp (line-beginning-position 0))
- (prevcol (if (and (= curline 1) (not current-prefix-arg))
- fill-column
- (save-excursion
- (forward-line (if current-prefix-arg 1 -1))
- (end-of-line)
- (skip-chars-backward " \t" lbp)
- (let ((cc (current-column)))
- (if (= cc 0) fill-column cc)))))
- (rightmost-column
- (cond (tofill fill-column)
- ((equal last-command 'repeat-last-character)
- (if (= curcol fill-column) prevcol fill-column))
- (t (save-excursion
- (if (= prevcol 0) fill-column prevcol)))
- )) )
- (end-of-line)
- (if (> (current-column) rightmost-column)
- ;; shave characters off the end
- (delete-region (- (point)
- (- (current-column) rightmost-column))
- (point))
- ;; fill with last characters
- (insert-char (preceding-char)
- (- rightmost-column (current-column))))
- ))
-
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Section movement commands.
-;;
-
-;; Note: this is not quite correct, the definition is any non alpha-numeric
-;; character.
-(defun rest-title-char-p (c)
- "Returns true if the given character is a valid title char."
- (and (string-match "[-=`:\\.'\"~^_*+#<>!$%&(),/;?@\\\|]"
- (char-to-string c)) t))
-
-(defun rest-forward-section ()
- "Skip to the next restructured text section title."
- (interactive)
- (let* ( (newpoint
- (save-excursion
- (forward-char) ;; in case we're right on a title
- (while
- (not
- (and (re-search-forward "^[A-Za-z0-9].*[ \t]*$" nil t)
- (reST-title-char-p (char-after (+ (point) 1)))
- (looking-at (format "\n%c\\{%d,\\}[ \t]*$"
- (char-after (+ (point) 1))
- (current-column))))))
- (beginning-of-line)
- (point))) )
- (if newpoint (goto-char newpoint)) ))
-
-(defun rest-backward-section ()
- "Skip to the previous restructured text section title."
- (interactive)
- (let* ( (newpoint
- (save-excursion
- ;;(forward-char) ;; in case we're right on a title
- (while
- (not
- (and (or (backward-char) t)
- (re-search-backward "^[A-Za-z0-9].*[ \t]*$" nil t)
- (or (end-of-line) t)
- (reST-title-char-p (char-after (+ (point) 1)))
- (looking-at (format "\n%c\\{%d,\\}[ \t]*$"
- (char-after (+ (point) 1))
- (current-column))))))
- (beginning-of-line)
- (point))) )
- (if newpoint (goto-char newpoint)) ))
-
-
-;;------------------------------------------------------------------------------
-;; For backwards compatibility. Remove at some point.
-(defalias 'reST-title-char-p 'rest-title-char-p)
-(defalias 'reST-forward-title 'rest-forward-section)
-(defalias 'reST-backward-title 'rest-backward-section)
-
-
-(provide 'restructuredtext)
diff --git a/docutils/tools/editors/emacs/rst-html.el b/docutils/tools/editors/emacs/rst-html.el
deleted file mode 100644
index c9ebf33ef..000000000
--- a/docutils/tools/editors/emacs/rst-html.el
+++ /dev/null
@@ -1,129 +0,0 @@
-;;; rst-mode.el --- Goodies to automate converting reST documents to HTML.
-
-;; Copyright 2003 Martin Blais <blais@iro.umontreal.ca>
-;;
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-;;; Commentary:
-
-;; This package provides a few functions and variables that can help in
-;; automating converting reST documents to HTML from within emacs. You could
-;; use a makefile to do this, of use the compile command that this package
-;; provides.
-
-;; You can also bind a command to automate converting to HTML:
-;; (defun user-rst-mode-hook ()
-;; (local-set-key [(control c)(?9)] 'rst-html-compile))
-;; (add-hook 'rst-mode-hook 'user-rst-mode-hook)
-
-;;; Code:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Customization:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defgroup rst-html nil
- "Settings for conversion to HTML available by \\[rst-html-compile]. Use of
-this functionality is discouraged. Get a proper `Makefile' instead."
- :group 'rst
- :version "21.1")
-
-(defcustom rst-html-command "docutils-html"
- "Command to convert an reST file to HTML."
- :group 'rst-html
- :type '(string))
-
-(defcustom rst-html-stylesheet ""
- "Stylesheet for reST to HTML conversion. Empty for no special stylesheet."
- :group 'rst-html
- :type '(string))
-
-(defcustom rst-html-options ""
- "Local file options for reST to HTML conversion.
-Stylesheets are set by an own option."
- :group 'rst-html
- :type '(string))
-
-(defcustom rst-html-extension ".html"
- "Extension for HTML output file."
- :group 'rst-html
- :type '(string))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Conversion to HTML
-
-(defun rst-html-compile ()
- "Compile command to convert reST document into HTML."
- (interactive)
- (let* ((bufname (file-name-nondirectory buffer-file-name))
- (outname (file-name-sans-extension bufname))
- (ssheet
- (or (and (not (zerop (length rst-html-stylesheet)))
- (concat "--stylesheet=\"" rst-html-stylesheet "\""))
- "")))
- (set (make-local-variable 'compile-command)
- (mapconcat 'identity
- (list rst-html-command
- ssheet rst-html-options
- bufname (concat outname rst-html-extension))
- " "))
- (if (or compilation-read-command current-prefix-arg)
- (call-interactively 'compile)
- (compile compile-command))
- ))
-
-(defun rst-html-compile-with-conf ()
- "Compile command to convert reST document into HTML. Attempts to find
-configuration file, if it can, overrides the options."
- (interactive)
- (let ((conffile (rst-html-find-conf)))
- (if conffile
- (let* ((bufname (file-name-nondirectory buffer-file-name))
- (outname (file-name-sans-extension bufname)))
- (set (make-local-variable 'compile-command)
- (mapconcat 'identity
- (list rst-html-command
- (concat "--config=\"" conffile "\"")
- bufname (concat outname rst-html-extension))
- " "))
- (if (or compilation-read-command current-prefix-arg)
- (call-interactively 'compile)
- (compile compile-command)))
- (call-interactively 'rst-html-compile)
- )))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Find the configuration file in the parents.
-
-(defun rst-html-find-conf ()
- "Look for the configuration file in the parents of the current path."
- (interactive)
- (let ((file-name "docutils.conf")
- (buffer-file (buffer-file-name)))
- ;; Move up in the dir hierarchy till we find a change log file.
- (let ((dir (file-name-directory buffer-file)))
- (while (and (or (not (string= "/" dir)) (setq dir nil) nil)
- (not (file-exists-p (concat dir file-name))))
- ;; Move up to the parent dir and try again.
- (setq dir (expand-file-name (file-name-directory
- (directory-file-name
- (file-name-directory dir))))) )
- (or (and dir (concat dir file-name)) nil)
- )))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;; rst-mode.el ends here
diff --git a/docutils/tools/editors/emacs/rst-mode.el b/docutils/tools/editors/emacs/rst-mode.el
deleted file mode 100644
index 8fc14e4a5..000000000
--- a/docutils/tools/editors/emacs/rst-mode.el
+++ /dev/null
@@ -1,700 +0,0 @@
-;;; rst-mode.el --- Mode for viewing and editing reStructuredText-documents.
-
-;; Copyright 2003 Stefan Merten <smerten@oekonux.de>
-;;
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-;;; Commentary:
-
-;; This package provides support for documents marked up using the
-;; reStructuredText format
-;; [http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html].
-;; Support includes font locking as well as some convenience functions
-;; for editing.
-
-;; The package is based on `text-mode' and inherits some things from it.
-;; Particularly `text-mode-hook' is run before `rst-mode-hook'.
-
-;; Add the following lines to your `.emacs' file:
-;;
-;; (autoload 'rst-mode "rst-mode" "mode for editing reStructuredText documents" t)
-;; (setq auto-mode-alist
-;; (append '(("\\.rst$" . rst-mode)
-;; ("\\.rest$" . rst-mode)) auto-mode-alist))
-;;
-;; If you are using `.txt' as a standard extension for reST files as
-;; http://docutils.sourceforge.net/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. However, because this is a major
-;; security breach you or your administrator may have chosen to switch that
-;; feature off. See `Local Variables in Files' in the Emacs documentation for a
-;; more complete discussion.
-
-;;; Code:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Customization:
-
-(defgroup rst nil "Support for reStructuredText documents"
- :group 'wp
- :version "21.1"
- :link '(url-link "http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html"))
-
-(defcustom rst-mode-hook nil
- "Hook run when Rst Mode is turned on. The hook for Text Mode is run before
- this one."
- :group 'rst
- :type '(hook))
-
-(defcustom rst-mode-lazy t
- "*If non-nil Rst Mode font-locks comment, literal blocks, and section titles
-correctly. Because this is really slow it switches on Lazy Lock Mode
-automatically. You may increase Lazy Lock Defer Time for reasonable results.
-
-If nil comments and literal blocks are font-locked only on the line they start.
-
-The value of this variable is used when Rst Mode is turned on."
- :group 'rst
- :type '(boolean))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defgroup rst-faces nil "Faces used in Rst Mode"
- :group 'rst
- :group 'faces
- :version "21.1")
-
-(defcustom rst-block-face 'font-lock-keyword-face
- "All syntax marking up a special block"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-external-face 'font-lock-type-face
- "Field names and interpreted text"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-definition-face 'font-lock-function-name-face
- "All other defining constructs"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-directive-face
- ;; XEmacs compatibility
- (if (boundp 'font-lock-builtin-face)
- 'font-lock-builtin-face
- 'font-lock-preprocessor-face)
- "Directives and roles"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-comment-face 'font-lock-comment-face
- "Comments"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-emphasis1-face
- ;; XEmacs compatibility
- (if (facep 'italic)
- ''italic
- 'italic)
- "Simple emphasis"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-emphasis2-face
- ;; XEmacs compatibility
- (if (facep 'bold)
- ''bold
- 'bold)
- "Double emphasis"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-literal-face 'font-lock-string-face
- "Literal text"
- :group 'rst-faces
- :type '(face))
-
-(defcustom rst-reference-face 'font-lock-variable-name-face
- "References to a definition"
- :group 'rst-faces
- :type '(face))
-
-;; Faces for displaying items on several levels; these definitions define
-;; different shades of grey where the lightest one is used for level 1
-(defconst rst-level-face-max 6
- "Maximum depth of level faces defined")
-(defconst rst-level-face-base-color "grey"
- "The base color to be used for creating level faces")
-(defconst rst-level-face-base-light 85
- "The lightness factor for the base color")
-(defconst rst-level-face-format-light "%2d"
- "The format for the lightness factor for the base color")
-(defconst rst-level-face-step-light -7
- "The step width to use for next color")
-
-;; Define the faces
-(let ((i 1))
- (while (<= i rst-level-face-max)
- (let ((sym (intern (format "rst-level-%d-face" i)))
- (doc (format "Face for showing section title text at level %d" i))
- (col (format (concat "%s" rst-level-face-format-light)
- rst-level-face-base-color
- (+ (* (1- i) rst-level-face-step-light)
- rst-level-face-base-light))))
- (make-empty-face sym)
- (set-face-doc-string sym doc)
- (set-face-background sym col)
- (set sym sym)
- (setq i (1+ i)))))
-
-(defcustom rst-adornment-faces-alist
- '((1 . rst-level-1-face)
- (2 . rst-level-2-face)
- (3 . rst-level-3-face)
- (4 . rst-level-4-face)
- (5 . rst-level-5-face)
- (6 . rst-level-6-face)
- (t . font-lock-keyword-face)
- (nil . font-lock-keyword-face))
- "Provides faces for the various adornment types. Key is a number (for the
-section title text of that level), t (for transitions) or nil (for section
-title adornment)."
- :group 'rst-faces
- :type '(alist :key-type (choice (integer :tag "Section level")
- (boolean :tag "transitions (on) / section title adornment (off)"))
- :value-type (face)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; FIXME: Code from `restructuredtext.el' should be integrated
-
-(defvar rst-mode-syntax-table nil
- "Syntax table used while in rst mode.")
-
-(unless rst-mode-syntax-table
- (setq rst-mode-syntax-table (make-syntax-table text-mode-syntax-table))
- (modify-syntax-entry ?$ "." rst-mode-syntax-table)
- (modify-syntax-entry ?% "." rst-mode-syntax-table)
- (modify-syntax-entry ?& "." rst-mode-syntax-table)
- (modify-syntax-entry ?' "." rst-mode-syntax-table)
- (modify-syntax-entry ?* "." rst-mode-syntax-table)
- (modify-syntax-entry ?+ "." rst-mode-syntax-table)
- (modify-syntax-entry ?. "_" rst-mode-syntax-table)
- (modify-syntax-entry ?/ "." rst-mode-syntax-table)
- (modify-syntax-entry ?< "." rst-mode-syntax-table)
- (modify-syntax-entry ?= "." rst-mode-syntax-table)
- (modify-syntax-entry ?> "." rst-mode-syntax-table)
- (modify-syntax-entry ?\\ "\\" rst-mode-syntax-table)
- (modify-syntax-entry ?| "." rst-mode-syntax-table)
- (modify-syntax-entry ?_ "." rst-mode-syntax-table)
- )
-
-(defvar rst-mode-abbrev-table nil
- "Abbrev table used while in rst mode.")
-(define-abbrev-table 'rst-mode-abbrev-table ())
-
-;; FIXME: Movement keys to skip forward / backward over or mark an indented
-;; block could be defined; keys to markup section titles based on
-;; `rst-adornment-level-alist' would be useful
-(defvar rst-mode-map nil
- "Keymap for rst mode. This inherits from Text mode.")
-
-(unless rst-mode-map
- (setq rst-mode-map (copy-keymap text-mode-map)))
-
-(defun rst-mode ()
- "Major mode for editing reStructuredText documents.
-
-You may customize `rst-mode-lazy' to switch font-locking of blocks.
-
-\\{rst-mode-map}
-Turning on `rst-mode' calls the normal hooks `text-mode-hook' and
-`rst-mode-hook'."
- (interactive)
- (kill-all-local-variables)
-
- ;; Maps and tables
- (use-local-map rst-mode-map)
- (setq local-abbrev-table rst-mode-abbrev-table)
- (set-syntax-table rst-mode-syntax-table)
-
- ;; For editing text
- ;;
- ;; FIXME: It would be better if this matches more exactly the start of a reST
- ;; paragraph; however, this not always possible with a simple regex because
- ;; paragraphs are determined by indentation of the following line
- (set (make-local-variable 'paragraph-start)
- (concat page-delimiter "\\|[ \t]*$"))
- (if (eq ?^ (aref paragraph-start 0))
- (setq paragraph-start (substring paragraph-start 1)))
- (set (make-local-variable 'paragraph-separate) paragraph-start)
- (set (make-local-variable 'indent-line-function) 'indent-relative-maybe)
- (set (make-local-variable 'adaptive-fill-mode) t)
- (set (make-local-variable 'comment-start) ".. ")
-
- ;; Special variables
- (make-local-variable 'rst-adornment-level-alist)
-
- ;; Font lock
- (set (make-local-variable 'font-lock-defaults)
- '(rst-font-lock-keywords-function
- t nil nil nil
- (font-lock-multiline . t)
- (font-lock-mark-block-function . mark-paragraph)))
- (when (boundp 'font-lock-support-mode)
- ;; rst-mode has its own mind about font-lock-support-mode
- (make-local-variable 'font-lock-support-mode)
- (cond
- ((and (not rst-mode-lazy) (not font-lock-support-mode)))
- ;; No support mode set and none required - leave it alone
- ((or (not font-lock-support-mode) ;; No support mode set (but required)
- (symbolp font-lock-support-mode)) ;; or a fixed mode for all
- (setq font-lock-support-mode
- (list (cons 'rst-mode (and rst-mode-lazy 'lazy-lock-mode))
- (cons t font-lock-support-mode))))
- ((and (listp font-lock-support-mode)
- (not (assoc 'rst-mode font-lock-support-mode)))
- ;; A list of modes missing rst-mode
- (setq font-lock-support-mode
- (append '((cons 'rst-mode (and rst-mode-lazy 'lazy-lock-mode)))
- font-lock-support-mode)))))
-
- ;; Names and hooks
- (setq mode-name "reST")
- (setq major-mode 'rst-mode)
- (run-hooks 'text-mode-hook)
- (run-hooks 'rst-mode-hook))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Font lock
-
-(defun rst-font-lock-keywords-function ()
- "Returns keywords to highlight in rst mode according to current settings."
- ;; The reST-links in the comments below all relate to sections in
- ;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html
- (let* ( ;; This gets big - so let's define some abbreviations
- ;; horizontal white space
- (re-hws "[\t ]")
- ;; beginning of line with possible indentation
- (re-bol (concat "^" re-hws "*"))
- ;; Separates block lead-ins from their content
- (re-blksep1 (concat "\\(" re-hws "+\\|$\\)"))
- ;; explicit markup tag
- (re-emt "\\.\\.")
- ;; explicit markup start
- (re-ems (concat re-emt re-hws "+"))
- ;; inline markup prefix
- (re-imp1 (concat "\\(^\\|" re-hws "\\|[-'\"([{</:]\\)"))
- ;; inline markup suffix
- (re-ims1 (concat "\\(" re-hws "\\|[]-'\")}>/:.,;!?\\]\\|$\\)"))
- ;; symbol character
- (re-sym1 "\\(\\sw\\|\\s_\\)")
- ;; inline markup content begin
- (re-imbeg2 "\\(\\S \\|\\S \\([^")
-
- ;; There seems to be a bug leading to error "Stack overflow in regexp
- ;; matcher" when "|" or "\\*" are the characters searched for
- (re-imendbeg
- (if (< emacs-major-version 21)
- "]"
- "\\]\\|\\\\."))
- ;; inline markup content end
- (re-imend (concat re-imendbeg "\\)*[^\t \\\\]\\)"))
- ;; inline markup content without asterisk
- (re-ima2 (concat re-imbeg2 "*" re-imend))
- ;; inline markup content without backquote
- (re-imb2 (concat re-imbeg2 "`" re-imend))
- ;; inline markup content without vertical bar
- (re-imv2 (concat re-imbeg2 "|" re-imend))
- ;; Supported URI schemes
- (re-uris1 "\\(acap\\|cid\\|data\\|dav\\|fax\\|file\\|ftp\\|gopher\\|http\\|https\\|imap\\|ldap\\|mailto\\|mid\\|modem\\|news\\|nfs\\|nntp\\|pop\\|prospero\\|rtsp\\|service\\|sip\\|tel\\|telnet\\|tip\\|urn\\|vemmi\\|wais\\)")
- ;; Line starting with adornment and optional whitespace; complete
- ;; adornment is in (match-string 1); there must be at least 3
- ;; characters because otherwise explicit markup start would be
- ;; recognized
- (re-ado2 (concat "^\\(\\(["
- (if (or
- (< emacs-major-version 21)
- (save-match-data
- (string-match "XEmacs\\|Lucid" emacs-version)))
- "^a-zA-Z0-9 \t\x00-\x1F"
- "^[:word:][:space:][:cntrl:]")
- "]\\)\\2\\2+\\)" re-hws "*$"))
- )
- (list
- ;; FIXME: Block markup is not recognized in blocks after explicit markup
- ;; start
-
- ;; Simple `Body Elements`_
- ;; `Bullet Lists`_
- (list
- (concat re-bol "\\([-*+]" re-blksep1 "\\)")
- 1 rst-block-face)
- ;; `Enumerated Lists`_
- (list
- (concat re-bol "\\((?\\([0-9]+\\|[A-Za-z]\\|[IVXLCMivxlcm]+\\)[.)]" re-blksep1 "\\)")
- 1 rst-block-face)
- ;; `Definition Lists`_ FIXME: missing
- ;; `Field Lists`_
- (list
- (concat re-bol "\\(:[^:]+:\\)" re-blksep1)
- 1 rst-external-face)
- ;; `Option Lists`_
- (list
- (concat re-bol "\\(\\(\\(\\([-+/]\\|--\\)\\sw\\(-\\|\\sw\\)*\\([ =]\\S +\\)?\\)\\(,[\t ]\\)?\\)+\\)\\($\\|[\t ]\\{2\\}\\)")
- 1 rst-block-face)
-
- ;; `Tables`_ FIXME: missing
-
- ;; All the `Explicit Markup Blocks`_
- ;; `Footnotes`_ / `Citations`_
- (list
- (concat re-bol "\\(" re-ems "\\[[^[]+\\]\\)" re-blksep1)
- 1 rst-definition-face)
- ;; `Directives`_ / `Substitution Definitions`_
- (list
- (concat re-bol "\\(" re-ems "\\)\\(\\(|[^|]+|[\t ]+\\)?\\)\\(" re-sym1 "+::\\)" re-blksep1)
- (list 1 rst-directive-face)
- (list 2 rst-definition-face)
- (list 4 rst-directive-face))
- ;; `Hyperlink Targets`_
- (list
- (concat re-bol "\\(" re-ems "_\\([^:\\`]\\|\\\\.\\|`[^`]+`\\)+:\\)" re-blksep1)
- 1 rst-definition-face)
- (list
- (concat re-bol "\\(__\\)" re-blksep1)
- 1 rst-definition-face)
-
- ;; All `Inline Markup`_
- ;; FIXME: Condition 5 preventing fontification of e.g. "*" not implemented
- ;; `Strong Emphasis`_
- (list
- (concat re-imp1 "\\(\\*\\*" re-ima2 "\\*\\*\\)" re-ims1)
- 2 rst-emphasis2-face)
- ;; `Emphasis`_
- (list
- (concat re-imp1 "\\(\\*" re-ima2 "\\*\\)" re-ims1)
- 2 rst-emphasis1-face)
- ;; `Inline Literals`_
- (list
- (concat re-imp1 "\\(``" re-imb2 "``\\)" re-ims1)
- 2 rst-literal-face)
- ;; `Inline Internal Targets`_
- (list
- (concat re-imp1 "\\(_`" re-imb2 "`\\)" re-ims1)
- 2 rst-definition-face)
- ;; `Hyperlink References`_
- ;; FIXME: `Embedded URIs`_ not considered
- (list
- (concat re-imp1 "\\(\\(`" re-imb2 "`\\|\\sw+\\)__?\\)" re-ims1)
- 2 rst-reference-face)
- ;; `Interpreted Text`_
- (list
- (concat re-imp1 "\\(\\(:" re-sym1 "+:\\)?\\)\\(`" re-imb2 "`\\)\\(\\(:" re-sym1 "+:\\)?\\)" re-ims1)
- (list 2 rst-directive-face)
- (list 5 rst-external-face)
- (list 8 rst-directive-face))
- ;; `Footnote References`_ / `Citation References`_
- (list
- (concat re-imp1 "\\(\\[[^]]+\\]_\\)" re-ims1)
- 2 rst-reference-face)
- ;; `Substitution References`_
- (list
- (concat re-imp1 "\\(|" re-imv2 "|\\)" re-ims1)
- 2 rst-reference-face)
- ;; `Standalone Hyperlinks`_
- (list
- ;; FIXME: This takes it easy by using a whitespace as delimiter
- (concat re-imp1 "\\(" re-uris1 ":\\S +\\)" re-ims1)
- 2 rst-definition-face)
- (list
- (concat re-imp1 "\\(" re-sym1 "+@" re-sym1 "+\\)" re-ims1)
- 2 rst-definition-face)
-
- ;; Do all block fontification as late as possible so 'append works
-
- ;; Sections_ / Transitions_
- (append
- (list
- re-ado2)
- (if (not rst-mode-lazy)
- (list 1 rst-block-face)
- (list
- (list 'rst-font-lock-handle-adornment
- '(progn
- (setq rst-font-lock-adornment-point (match-end 1))
- (point-max))
- nil
- (list 1 '(cdr (assoc nil rst-adornment-faces-alist))
- 'append t)
- (list 2 '(cdr (assoc rst-font-lock-level rst-adornment-faces-alist))
- 'append t)
- (list 3 '(cdr (assoc nil rst-adornment-faces-alist))
- 'append t)))))
-
- ;; `Comments`_
- (append
- (list
- (concat re-bol "\\(" re-ems "\\)\[^[|_]\\([^:]\\|:\\([^:]\\|$\\)\\)*$")
- (list 1 rst-comment-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point (match-end 1))
- (point-max))
- nil
- (list 0 rst-comment-face 'append)))))
- (append
- (list
- (concat re-bol "\\(" re-emt "\\)\\(\\s *\\)$")
- (list 1 rst-comment-face)
- (list 2 rst-comment-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point 'next)
- (point-max))
- nil
- (list 0 rst-comment-face 'append)))))
-
- ;; `Literal Blocks`_
- (append
- (list
- (concat re-bol "\\(\\([^.\n]\\|\\.[^.\n]\\).*\\)?\\(::\\)$")
- (list 3 rst-block-face))
- (if rst-mode-lazy
- (list
- (list 'rst-font-lock-find-unindented-line
- '(progn
- (setq rst-font-lock-indentation-point t)
- (point-max))
- nil
- (list 0 rst-literal-face 'append)))))
- )))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Indented blocks
-
-(defun rst-forward-indented-block (&optional column limit)
- "Move forward across one indented block.
-Find the next non-empty line which is not indented at least to COLUMN (defaults
-to the column of the point). Moves point to first character of this line or the
-first empty line immediately before it and returns that position. If there is
-no such line before LIMIT (defaults to the end of the buffer) returns nil and
-point is not moved."
- (interactive)
- (let ((clm (or column (current-column)))
- (start (point))
- fnd beg cand)
- (if (not limit)
- (setq limit (point-max)))
- (save-match-data
- (while (and (not fnd) (< (point) limit))
- (forward-line 1)
- (when (< (point) limit)
- (setq beg (point))
- (if (looking-at "\\s *$")
- (setq cand (or cand beg)) ; An empty line is a candidate
- (move-to-column clm)
- ;; FIXME: No indentation [(zerop clm)] must be handled in some
- ;; useful way - though it is not clear what this should mean at all
- (if (string-match
- "^\\s *$" (buffer-substring-no-properties beg (point)))
- (setq cand nil) ; An indented line resets a candidate
- (setq fnd (or cand beg)))))))
- (goto-char (or fnd start))
- fnd))
-
-;; Stores the point where the current indentation ends if a number. If `next'
-;; indicates `rst-font-lock-find-unindented-line' shall take the indentation
-;; from the next line if this is not empty. If non-nil indicates
-;; `rst-font-lock-find-unindented-line' shall take the indentation from the
-;; next non-empty line. Also used as a trigger for
-;; `rst-font-lock-find-unindented-line'.
-(defvar rst-font-lock-indentation-point nil)
-
-(defun rst-font-lock-find-unindented-line (limit)
- (let* ((ind-pnt rst-font-lock-indentation-point)
- (beg-pnt ind-pnt))
- ;; May run only once - enforce this
- (setq rst-font-lock-indentation-point nil)
- (when (and ind-pnt (not (numberp ind-pnt)))
- ;; Find indentation point in next line if any
- (setq ind-pnt
- (save-excursion
- (save-match-data
- (if (eq ind-pnt 'next)
- (when (and (zerop (forward-line 1)) (< (point) limit))
- (setq beg-pnt (point))
- (when (not (looking-at "\\s *$"))
- (looking-at "\\s *")
- (match-end 0)))
- (while (and (zerop (forward-line 1)) (< (point) limit)
- (looking-at "\\s *$")))
- (when (< (point) limit)
- (setq beg-pnt (point))
- (looking-at "\\s *")
- (match-end 0)))))))
- (when ind-pnt
- (goto-char ind-pnt)
- ;; Always succeeds because the limit set by PRE-MATCH-FORM is the
- ;; ultimate point to find
- (goto-char (or (rst-forward-indented-block nil limit) limit))
- (set-match-data (list beg-pnt (point)))
- t)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Adornments
-
-;; Stores the point where the current adornment ends. Also used as a trigger
-;; for `rst-font-lock-handle-adornment'.
-(defvar rst-font-lock-adornment-point nil)
-
-;; Here `rst-font-lock-handle-adornment' stores the section level of the
-;; current adornment or t for a transition.
-(defvar rst-font-lock-level nil)
-
-;; FIXME: It would be good if this could be used to markup section titles of
-;; given level with a special key; it would be even better to be able to
-;; customize this so it can be used for a generally available personal style
-;;
-;; FIXME: There should be some way to reset and reload this variable - probably
-;; a special key
-;;
-;; FIXME: Some support for `outline-mode' would be nice which should be based
-;; on this information
-(defvar rst-adornment-level-alist nil
- "Associates adornments with section levels.
-The key is a two character string. The first character is the adornment
-character. The second character distinguishes underline section titles (`u')
-from overline/underline section titles (`o'). The value is the section level.
-
-This is made buffer local on start and adornments found during font lock are
-entered.")
-
-;; Returns section level for adornment key KEY. Adds new section level if KEY
-;; is not found and ADD. If KEY is not a string it is simply returned.
-(defun rst-adornment-level (key &optional add)
- (let ((fnd (assoc key rst-adornment-level-alist))
- (new 1))
- (cond
- ((not (stringp key))
- key)
- (fnd
- (cdr fnd))
- (add
- (while (rassoc new rst-adornment-level-alist)
- (setq new (1+ new)))
- (setq rst-adornment-level-alist
- (append rst-adornment-level-alist (list (cons key new))))
- new))))
-
-;; Classifies adornment for section titles and transitions. ADORNMENT is the
-;; complete adornment string as found in the buffer. END is the point after the
-;; last character of ADORNMENT. For overline section adornment LIMIT limits the
-;; search for the matching underline. Returns a list. The first entry is t for
-;; a transition, or a key string for `rst-adornment-level' for a section title.
-;; The following eight values forming four match groups as can be used for
-;; `set-match-data'. First match group contains the maximum points of the whole
-;; construct. Second and last match group matched pure section title adornment
-;; while third match group matched the section title text or the transition.
-;; Each group but the first may or may not exist.
-(defun rst-classify-adornment (adornment end limit)
- (save-excursion
- (save-match-data
- (goto-char end)
- (let ((ado-ch (aref adornment 0))
- (ado-re (regexp-quote adornment))
- (end-pnt (point))
- (beg-pnt (progn
- (forward-line 0)
- (point)))
- (nxt-emp
- (save-excursion
- (or (not (zerop (forward-line 1)))
- (looking-at "\\s *$"))))
- (prv-emp
- (save-excursion
- (or (not (zerop (forward-line -1)))
- (looking-at "\\s *$"))))
- key beg-ovr end-ovr beg-txt end-txt beg-und end-und)
- (cond
- ((and nxt-emp prv-emp)
- ;; A transition
- (setq key t)
- (setq beg-txt beg-pnt)
- (setq end-txt end-pnt))
- (prv-emp
- ;; An overline
- (setq key (concat (list ado-ch) "o"))
- (setq beg-ovr beg-pnt)
- (setq end-ovr end-pnt)
- (forward-line 1)
- (setq beg-txt (point))
- (while (and (< (point) limit) (not end-txt))
- (if (looking-at "\\s *$")
- ;; No underline found
- (setq end-txt (1- (point)))
- (when (looking-at (concat "\\(" ado-re "\\)\\s *$"))
- (setq end-und (match-end 1))
- (setq beg-und (point))
- (setq end-txt (1- beg-und))))
- (forward-line 1)))
- (t
- ;; An underline
- (setq key (concat (list ado-ch) "u"))
- (setq beg-und beg-pnt)
- (setq end-und end-pnt)
- (setq end-txt (1- beg-und))
- (setq beg-txt (progn
- (if (re-search-backward "^\\s *$" 1 'move)
- (forward-line 1))
- (point)))))
- (list key
- (or beg-ovr beg-txt beg-und)
- (or end-und end-txt end-und)
- beg-ovr end-ovr beg-txt end-txt beg-und end-und)))))
-
-;; Handles adornments for font-locking section titles and transitions. Returns
-;; three match groups. First and last match group matched pure overline /
-;; underline adornment while second group matched section title text. Each
-;; group may not exist.
-(defun rst-font-lock-handle-adornment (limit)
- (let ((ado-pnt rst-font-lock-adornment-point))
- ;; May run only once - enforce this
- (setq rst-font-lock-adornment-point nil)
- (if ado-pnt
- (let* ((ado (rst-classify-adornment (match-string-no-properties 1)
- ado-pnt limit))
- (key (car ado))
- (mtc (cdr ado)))
- (setq rst-font-lock-level (rst-adornment-level key t))
- (goto-char (nth 1 mtc))
- (set-match-data mtc)
- t))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(provide 'rst-mode)
-
-;;; rst-mode.el ends here
diff --git a/docutils/tools/editors/emacs/tests/tests-adjust-section.el b/docutils/tools/editors/emacs/tests/tests-adjust-section.el
deleted file mode 100644
index 43215fb98..000000000
--- a/docutils/tools/editors/emacs/tests/tests-adjust-section.el
+++ /dev/null
@@ -1,240 +0,0 @@
-;; Authors: Martin Blais <blais@furius.ca>
-;; Date: $Date: 2005/04/01 23:19:41 $
-;; Copyright: This module has been placed in the public domain.
-;;
-;; Regression tests for rest-adjust-section-title.
-;;
-
-(setq rest-adjust-section-tests
- '(
- (simple
-"
-Some Title@
-
-"
-"
-Some Title
-==========
-
-")
-
- (simple-cursor-in-line
-"
-Some Tit@le
-
-"
-"
-Some Title
-==========
-
-")
-
- (simple-cursor-beginning
-"
-@Some Title
-
-"
-"
-Some Title
-==========
-
-")
-
- (simple-at-end-of-buffer
-"
-Some Title@"
-"
-Some Title
-==========
-")
-
- (cursor-on-empty-line-under
-"
-Some Title
-@
-"
-"
-Some Title
-==========
-
-")
-
-
-
- (partial
-"
-Some Title@
----
-"
-"
-Some Title
-----------
-
-")
-
- (cursor-on-underline
-"
-Some Title
----@
-"
-"
-Some Title
-----------
-
-")
-
- (cursor-on-underline-one-char
-"
-Some Title
-~@
-"
-"
-Some Title
-~~~~~~~~~~
-
-")
-
- (with-previous-text
-"
-Some Title
-**********
-
-Subtitle@
-
-"
-"
-Some Title
-**********
-
-Subtitle
-********
-
-")
-
- (with-suggested-new-text
-"
-Some Title
-==========
-
-Subtitle
---------
-
-Subtitle2@
-
-"
-"
-Some Title
-==========
-
-Subtitle
---------
-
-Subtitle2
-~~~~~~~~~
-
-"
-(nil nil))
-
- (with-previous-text-rotating
-"
-Some Title
-==========
-
-Subtitle
---------
-
-Subtitle2@
-
-"
-"
-Some Title
-==========
-
-Subtitle
---------
-
-Subtitle2
-=========
-
-"
-(nil nil nil))
-
- (start-indented
-"
- Some Title@
-
-"
-"
-================
- Some Title
-================
-
-")
-
- (switch-from-nothing
-"
-Some Title@
-
-"
-"
-============
- Some Title
-============
-
-" (t))
-
- (switch-from-over-and-under
-"
-============
- Some Title@
-============
-"
-"
-Some Title
-==========
-
-" (t))
-
-))
-
- "A list of regression tests for the section update method.")
-
-
-
-(defun regression-test-compare-expect-buffer (testlist fun)
- "Run the regression tests for the section adjusting method."
-
- (let ((buf (get-buffer-create "restructuredtext-regression-tests"))
- (specchar "@")
- )
- (dolist (curtest testlist)
- ;; print current text
- (message (format "========= %s" (prin1-to-string (car curtest))))
-
- ;; prepare a buffer with the starting text, and move the cursor where
- ;; the special character is located
- (switch-to-buffer buf)
- (erase-buffer)
- (insert (cadr curtest))
- (search-backward specchar)
- (delete-char 1)
-
- ;; run the section title update command n times
- (dolist (x (or (cadddr curtest) (list nil)))
- (let ((current-prefix-arg x))
- (funcall fun)))
-
- ;; compare the buffer output with the expected text
- (or (string=
- (buffer-string)
- (caddr curtest))
- (progn
- (error "Test %s failed." (car curtest))))
- )
- ))
-
-;; evaluate this to run the tests, either interactively or in batch
-(regression-test-compare-expect-buffer
- rest-adjust-section-tests
- (lambda ()
- (call-interactively 'rest-adjust-section-title)))