summaryrefslogtreecommitdiff
path: root/lisp/textmodes
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/.gitignore1
-rw-r--r--lisp/textmodes/artist.el128
-rw-r--r--lisp/textmodes/bib-mode.el8
-rw-r--r--lisp/textmodes/bibtex-style.el2
-rw-r--r--lisp/textmodes/bibtex.el78
-rw-r--r--lisp/textmodes/conf-mode.el19
-rw-r--r--lisp/textmodes/css-mode.el594
-rw-r--r--lisp/textmodes/dns-mode.el2
-rw-r--r--lisp/textmodes/enriched.el9
-rw-r--r--lisp/textmodes/fill.el19
-rw-r--r--lisp/textmodes/flyspell.el163
-rw-r--r--lisp/textmodes/ispell.el533
-rw-r--r--lisp/textmodes/makeinfo.el19
-rw-r--r--lisp/textmodes/nroff-mode.el4
-rw-r--r--lisp/textmodes/page-ext.el37
-rw-r--r--lisp/textmodes/page.el4
-rw-r--r--lisp/textmodes/paragraphs.el14
-rw-r--r--lisp/textmodes/picture.el22
-rw-r--r--lisp/textmodes/po.el4
-rw-r--r--lisp/textmodes/refbib.el4
-rw-r--r--lisp/textmodes/refer.el12
-rw-r--r--lisp/textmodes/refill.el2
-rw-r--r--lisp/textmodes/reftex-auc.el16
-rw-r--r--lisp/textmodes/reftex-cite.el100
-rw-r--r--lisp/textmodes/reftex-dcr.el10
-rw-r--r--lisp/textmodes/reftex-global.el15
-rw-r--r--lisp/textmodes/reftex-index.el47
-rw-r--r--lisp/textmodes/reftex-parse.el88
-rw-r--r--lisp/textmodes/reftex-ref.el26
-rw-r--r--lisp/textmodes/reftex-sel.el28
-rw-r--r--lisp/textmodes/reftex-toc.el187
-rw-r--r--lisp/textmodes/reftex-vars.el59
-rw-r--r--lisp/textmodes/reftex.el897
-rw-r--r--lisp/textmodes/remember.el132
-rw-r--r--lisp/textmodes/rst.el261
-rw-r--r--lisp/textmodes/sgml-mode.el268
-rw-r--r--lisp/textmodes/table.el95
-rw-r--r--lisp/textmodes/tex-mode.el633
-rw-r--r--lisp/textmodes/texinfmt.el52
-rw-r--r--lisp/textmodes/texinfo.el27
-rw-r--r--lisp/textmodes/texnfo-upd.el74
-rw-r--r--lisp/textmodes/text-mode.el58
-rw-r--r--lisp/textmodes/tildify.el522
-rw-r--r--lisp/textmodes/two-column.el10
-rw-r--r--lisp/textmodes/underline.el4
45 files changed, 3547 insertions, 1740 deletions
diff --git a/lisp/textmodes/.gitignore b/lisp/textmodes/.gitignore
deleted file mode 100644
index c531d9867f6..00000000000
--- a/lisp/textmodes/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.elc
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index 0d9c8eb7c64..a29418e6f84 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -1,6 +1,6 @@
;;; artist.el --- draw ascii graphics with your mouse
-;; Copyright (C) 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
;; Author: Tomas Abrahamsson <tab@lysator.liu.se>
;; Maintainer: Tomas Abrahamsson <tab@lysator.liu.se>
@@ -298,7 +298,7 @@ during the flood-fill."
(defcustom artist-ellipse-right-char ?\)
"Character to use at the rightmost position when drawing narrow ellipses.
-In this figure, it is the right parenthesis (the ``)'' character):
+In this figure, it is the right parenthesis (the \")\" character):
-----
( )
-----"
@@ -309,7 +309,7 @@ In this figure, it is the right parenthesis (the ``)'' character):
(defcustom artist-ellipse-left-char ?\(
"Character to use at the leftmost position when drawing narrow ellipses.
-In this figure, it is the left parenthesis (the ``('' character):
+In this figure, it is the left parenthesis (the \"(\" character):
-----
( )
-----"
@@ -331,7 +331,7 @@ Accept this many characters cutting off a line and still treat
it as one line.
Example:
If `artist-vaporize-fuzziness' is 2, then those will be recognized as
- lines from A to B (provided you start vaporizing them at the ``*''):
+ lines from A to B (provided you start vaporizing them at the \"*\"):
/
A----*------/-----------B
\\/
@@ -342,7 +342,7 @@ Example:
\\/ /
A----*----/\\/----------B
/ /\\
- (in fact, only the left part [between the A and the leftmost ``/''
+ (in fact, only the left part [between the A and the leftmost \"/\"
crossing the line] will be vaporized)."
:group 'artist
:type 'integer)
@@ -397,8 +397,8 @@ Example:
;; This is a defvar, not a defcustom, since the custom
;; package shows lists of characters as a lists of integers,
;; which is confusing
- "Characters (``color'') to use when spraying.
-They should be ordered from the ``lightest'' to the ``heaviest''
+ "Characters (\"color\") to use when spraying.
+They should be ordered from the \"lightest\" to the \"heaviest\"
since spraying replaces a light character with the next heavier one.")
@@ -1275,7 +1275,7 @@ Drawing with the mouse:
* Cut copies, then clears the rectangle/square.
* When drawing lines or poly-lines, you can set arrows.
- See below under ``Arrows'' for more info.
+ See below under \"Arrows\" for more info.
* The mode line shows the currently selected drawing operation.
In addition, if it has an asterisk (*) at the end, you
@@ -1383,8 +1383,8 @@ Variables
artist-vaporize-fuzziness Tolerance when recognizing lines
artist-spray-interval Seconds between repeated sprayings
artist-spray-radius Size of the spray-area
- artist-spray-chars The spray-``color''
- artist-spray-new-chars Initial spray-``color''
+ artist-spray-chars The spray-\"color\"
+ artist-spray-new-chars Initial spray-\"color\"
Hooks
@@ -2020,7 +2020,7 @@ The replacement is used to convert tabs and new-lines to spaces."
(defsubst artist-replace-string (string &optional see-thru)
"Replace contents at point with STRING.
With optional argument SEE-THRU set to non-nil, text in the buffer
-``shines thru'' blanks in the STRING."
+\"shines thru\" blanks in the STRING."
(let ((char-list (append string nil)) ; convert the string to a list
(overwrite-mode 'overwrite-mode-textual)
(fill-column 32765) ; Large :-)
@@ -2385,7 +2385,7 @@ in the coord."
;; Pretend we are plotting a pixel. Instead we just list it
;;
(defmacro artist-put-pixel (point-list x y)
- "In POINT-LIST, store a ``pixel'' at coord X,Y."
+ "In POINT-LIST, store a \"pixel\" at coord X,Y."
`(setq ,point-list
(append ,point-list (list (artist-new-coord ,x ,y)))))
@@ -2928,7 +2928,7 @@ This is done by calling the function specified by
`artist-text-renderer-function', which must return a list of strings,
to be inserted in the buffer.
-Text already in the buffer ``shines thru'' blanks in the rendered text."
+Text already in the buffer \"shines thru\" blanks in the rendered text."
(let* ((input-text (read-string "Type text to render: "))
(rendered-text (artist-funcall artist-text-renderer-function input-text)))
(artist-text-insert-see-thru x y rendered-text)))
@@ -2958,7 +2958,7 @@ Blanks in the rendered text overwrite any text in the buffer."
Returns a list of points. Each point is on the form (X1 . Y1)."
(let ((points))
(while (> n 0)
- (let* ((angle (* (random 359) (/ float-pi 180)))
+ (let* ((angle (degrees-to-radians (random 359)))
(dist (random radius))
(point (cons (round (* dist (cos angle)))
(round (* dist (sin angle))))))
@@ -3372,7 +3372,7 @@ The POINT-LIST is expected to cover the first quadrant."
;; Create the other half by mirroring the first half.
(setq both-halves
(append first-half
- (mapc
+ (mapcar
(lambda (i)
(artist-new-fill-item (artist-fill-item-get-x i)
(- (artist-fill-item-get-y i))
@@ -4963,52 +4963,58 @@ The event, EV, is the mouse event."
(artist-funcall init-fn x1 y1)
(if (not artist-rubber-banding)
(artist-no-rb-set-point1 x1 y1))
- (track-mouse
- (while (or (mouse-movement-p ev)
- (member 'down (event-modifiers ev)))
- (setq ev-start-pos (artist-coord-win-to-buf
- (posn-col-row (event-start ev))))
- (setq x1 (car ev-start-pos))
- (setq y1 (cdr ev-start-pos))
-
- ;; Cancel previous timer
- (if timer
- (cancel-timer timer))
-
- (if (not (eq initial-win (posn-window (event-start ev))))
- ;; If we moved outside the window, do nothing
- nil
-
- ;; Still in same window:
- ;;
- ;; Check if user presses or releases shift key
- (if (artist-shift-has-changed shift-state ev)
-
- ;; First check that the draw-how is the same as we
- ;; already have. Otherwise, ignore the changed shift-state.
- (if (not (eq draw-how
- (artist-go-get-draw-how-from-symbol
- (if (not shift-state) shifted unshifted))))
- (message "Cannot switch to shifted operation")
-
- ;; progn is "implicit" since this is the else-part
- (setq shift-state (not shift-state))
- (setq op (if shift-state shifted unshifted))
- (setq draw-how (artist-go-get-draw-how-from-symbol op))
- (setq draw-fn (artist-go-get-draw-fn-from-symbol op))))
-
- ;; Draw the new shape
- (setq shape (artist-funcall draw-fn x1 y1))
- (artist-move-to-xy x1 y1)
-
- ;; Start the timer to call `draw-fn' repeatedly every
- ;; `interval' second
- (if (and interval draw-fn)
- (setq timer (run-at-time interval interval draw-fn x1 y1))))
-
- ;; Read next event
- (setq ev (read-event))))
-
+ (unwind-protect
+ (track-mouse
+ ;; We don't want flickering of mouse pointer shape while we
+ ;; drag the mouse.
+ (setq track-mouse 'dragging)
+ (while (or (mouse-movement-p ev)
+ (member 'down (event-modifiers ev)))
+ (setq ev-start-pos (artist-coord-win-to-buf
+ (posn-col-row (event-start ev))))
+ (setq x1 (car ev-start-pos))
+ (setq y1 (cdr ev-start-pos))
+
+ ;; Cancel previous timer
+ (if timer
+ (cancel-timer timer))
+
+ (if (not (eq initial-win (posn-window (event-start ev))))
+ ;; If we moved outside the window, do nothing
+ nil
+
+ ;; Still in same window:
+ ;;
+ ;; Check if user presses or releases shift key
+ (if (artist-shift-has-changed shift-state ev)
+
+ ;; First check that the draw-how is the same as we
+ ;; already have. Otherwise, ignore the changed shift-state.
+ (if (not (eq draw-how
+ (artist-go-get-draw-how-from-symbol
+ (if (not shift-state) shifted unshifted))))
+ (message "Cannot switch to shifted operation")
+
+ ;; progn is "implicit" since this is the else-part
+ (setq shift-state (not shift-state))
+ (setq op (if shift-state shifted unshifted))
+ (setq draw-how (artist-go-get-draw-how-from-symbol op))
+ (setq draw-fn (artist-go-get-draw-fn-from-symbol op))))
+
+ ;; Draw the new shape
+ (setq shape (artist-funcall draw-fn x1 y1))
+ (artist-move-to-xy x1 y1)
+
+ ;; Start the timer to call `draw-fn' repeatedly every
+ ;; `interval' second
+ (if (and interval draw-fn)
+ (setq timer (run-at-time interval interval draw-fn x1 y1))))
+
+ ;; Read next event
+ (setq ev (read-event))))
+ ;; Cleanup: get rid of any active timer.
+ (if timer
+ (cancel-timer timer)))
;; Cancel any timers
(if timer
(cancel-timer timer))
diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el
index 5ef263542fe..2ed5ad89eab 100644
--- a/lisp/textmodes/bib-mode.el
+++ b/lisp/textmodes/bib-mode.el
@@ -1,10 +1,10 @@
;;; bib-mode.el --- major mode for editing bib files
-;; Copyright (C) 1989, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2015 Free Software Foundation, Inc.
;; Author: Henry Kautz
;; (according to authors.el)
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: bib
;; This file is part of GNU Emacs.
@@ -82,8 +82,8 @@ A uthor T itle D ate J ournal
V olume N umber P age K eywords
B in book or proceedings E ditor C ity & state
I nstitution, school, or publisher
-R eport number or 'phd thesis' or 'masters thesis' or 'draft' or
- 'unnumbered' or 'unpublished'
+R eport number or `phd thesis' or `masters thesis' or `draft' or
+ `unnumbered' or `unpublished'
W here can be found locally (login name, or ailib, etc.)
X comments (not used in indexing)
diff --git a/lisp/textmodes/bibtex-style.el b/lisp/textmodes/bibtex-style.el
index 77b135de009..8ee011744df 100644
--- a/lisp/textmodes/bibtex-style.el
+++ b/lisp/textmodes/bibtex-style.el
@@ -1,6 +1,6 @@
;;; bibtex-style.el --- Major mode for BibTeX Style files -*- lexical-binding: t -*-
-;; Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2015 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: tex
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 171f373317a..df8066ee2fc 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1,6 +1,6 @@
;;; bibtex.el --- BibTeX mode for GNU Emacs -*- lexical-binding: t -*-
-;; Copyright (C) 1992, 1994-1999, 2001-2013 Free Software Foundation,
+;; Copyright (C) 1992, 1994-1999, 2001-2015 Free Software Foundation,
;; Inc.
;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
@@ -433,7 +433,7 @@ is present; but these fields are required otherwise.
OPTIONAL is a list of optional fields.
Each element of these lists is a list of the form
- \(FIELD COMMENT INIT ALTERNATIVE).
+ (FIELD COMMENT INIT ALTERNATIVE).
COMMENT, INIT, and ALTERNATIVE are optional.
FIELD is the name of the field.
@@ -468,7 +468,7 @@ alternatives, starting from zero."
nil
(("editor") ("editora") ("editorb") ("editorc")
("translator") ("annotator") ("commentator")
- ("introduction") ("foreword") ("afterword") ("titleaddon")
+ ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon")
("maintitle") ("mainsubtitle") ("maintitleaddon")
("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
("series") ("number") ("note") ("publisher") ("location") ("isbn")
@@ -546,9 +546,9 @@ alternatives, starting from zero."
("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
("InCollection" "Article in a Collection"
- (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
+ (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
(("booktitle"))
- (("editora") ("editorb") ("editorc") ("translator") ("annotator")
+ (("editor") ("editora") ("editorb") ("editorc") ("translator") ("annotator")
("commentator") ("introduction") ("foreword") ("afterword")
("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
("maintitleaddon") ("booksubtitle") ("booktitleaddon")
@@ -616,10 +616,11 @@ alternatives, starting from zero."
("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
("eprinttype") ("url") ("urldate")))
("Proceedings" "Single-Volume Conference Proceedings"
- (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
+ (("title") ("year" nil nil 0) ("date" nil nil 0))
nil
(("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
("maintitleaddon") ("eventtitle") ("eventdate") ("venue") ("language")
+ ("editor")
("volume") ("part") ("volumes") ("series") ("number") ("note")
("organization") ("publisher") ("location") ("month")
("isbn") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate")
@@ -633,9 +634,9 @@ alternatives, starting from zero."
("isbn") ("pagetotal") ("addendum") ("pubstate")
("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
("InProceedings" "Article in Conference Proceedings"
- (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
+ (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
(("booktitle"))
- (("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
+ (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
("maintitleaddon") ("booksubtitle") ("booktitleaddon")
("eventtitle") ("eventdate") ("venue") ("language")
("volume") ("part") ("volumes") ("series") ("number") ("note")
@@ -2098,7 +2099,7 @@ If FLAG is nil, a message is echoed if point was incremented at least
(let* ((size (- (point-max) (point-min)))
(perc (if (= size 0)
100
- (/ (* 100 (- (point) (point-min))) size))))
+ (floor (* 100.0 (- (point) (point-min))) size))))
(when (>= perc (+ bibtex-progress-lastperc
bibtex-progress-interval))
(setq bibtex-progress-lastperc perc)
@@ -2228,7 +2229,7 @@ Optional arg COMMA is as in `bibtex-enclosing-field'."
bibtex-entry-kill-ring))
;; If we copied an entry from a buffer containing only this one entry,
;; it can be missing the second "\n".
- (unless (looking-back "\n\n") (insert "\n"))
+ (unless (looking-back "\n\n" (- (point) 2)) (insert "\n"))
(unless (functionp bibtex-reference-keys)
;; update `bibtex-reference-keys'
(save-excursion
@@ -2619,7 +2620,7 @@ is returned unchanged."
"Get content of BibTeX field FIELD. Return empty string if not found.
Optional arg CHANGE-LIST is a list of substitution patterns that is
applied to the content of FIELD. It is an alist with pairs
-\(OLD-REGEXP . NEW-STRING\)."
+\(OLD-REGEXP . NEW-STRING)."
(let* ((bibtex-expand-strings bibtex-autokey-expand-strings)
(content (bibtex-text-in-field field bibtex-autokey-use-crossref))
case-fold-search)
@@ -3646,7 +3647,7 @@ If optional arg CONTENT is non-nil extract content of text fields."
(defun bibtex-autofill-entry ()
"Try to fill fields of current BibTeX entry based on neighboring entries.
The current entry must have a key. Determine the neighboring entry
-\(previous or next\) whose key is more similar to the key of the current
+\(previous or next) whose key is more similar to the key of the current
entry. For all empty fields of the current entry insert the corresponding
field contents of the neighboring entry. Finally try to update the text
based on the difference between the keys of the neighboring and the current
@@ -4231,7 +4232,7 @@ Return t if test was successful, nil otherwise."
(cond ((not previous))
((member key key-list)
(push (cons (bibtex-current-line)
- (format "Duplicate key `%s'" key))
+ (format-message "Duplicate key `%s'" key))
error-list))
((and bibtex-maintain-sorted-entries
(not (bibtex-lessp previous current)))
@@ -4254,8 +4255,9 @@ Return t if test was successful, nil otherwise."
(cdr (assoc-string (car key) bibtex-reference-keys)))
(bibtex-search-entry (car key))
(push (cons (bibtex-current-line)
- (format "Duplicate key `%s' in %s" (car key)
- (abbreviate-file-name (buffer-file-name buffer))))
+ (format-message
+ "Duplicate key `%s' in %s" (car key)
+ (abbreviate-file-name (buffer-file-name buffer))))
error-list))))
(when test-thoroughly
@@ -4305,14 +4307,16 @@ Return t if test was successful, nil otherwise."
(if (setq idx (nth 3 field))
(bibtex-vec-push alt-expect idx (car field))
(push (cons beg-line
- (format "Required field `%s' missing"
- (car field)))
+ (format-message
+ "Required field `%s' missing"
+ (car field)))
error-list)))
(dotimes (idx num-alt)
(unless (aref alt-fields idx)
(push (cons beg-line
- (format "Alternative fields `%s' missing"
- (aref alt-expect idx)))
+ (format-message
+ "Alternative fields `%s' missing"
+ (aref alt-expect idx)))
error-list))))))))
(bibtex-progress-message 'done)))))
@@ -4326,7 +4330,8 @@ Return t if test was successful, nil otherwise."
(unless (eq major-mode 'compilation-mode) (compilation-mode))
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
- (insert "BibTeX mode command `bibtex-validate'\n"
+ (insert (substitute-command-keys
+ "BibTeX mode command `bibtex-validate'\n")
(if syntax-error
"Maybe undetected errors due to syntax errors. \
Correct and validate again.\n"
@@ -4337,10 +4342,10 @@ Correct and validate again.\n"
(goto-char (point-min))
(forward-line 2)) ; first error message
(display-buffer err-buf)
- nil) ; return `nil' (i.e., buffer is invalid)
+ nil) ; return nil (i.e., buffer is invalid)
(message "%s is syntactically correct"
(if mark-active "Region" "Buffer"))
- t))) ; return `t' (i.e., buffer is valid)
+ t))) ; return t (i.e., buffer is valid)
(defun bibtex-validate-globally (&optional strings)
"Check for duplicate keys in `bibtex-files'.
@@ -4361,9 +4366,10 @@ Return t if test was successful, nil otherwise."
(if (or (and strings (bibtex-string= entry-type "string"))
(assoc-string entry-type bibtex-entry-alist t))
(if (member key key-list)
- (push (format "%s:%d: Duplicate key `%s'\n"
- (buffer-file-name)
- (bibtex-current-line) key)
+ (push (format-message
+ "%s:%d: Duplicate key `%s'\n"
+ (buffer-file-name)
+ (bibtex-current-line) key)
error-list)
(push key key-list))))
(push (cons buffer key-list) buffer-key-list)))))
@@ -4376,9 +4382,10 @@ Return t if test was successful, nil otherwise."
(dolist (key (cdr (assq buffer buffer-key-list)))
(when (assoc-string key current-keys)
(bibtex-search-entry key)
- (push (format "%s:%d: Duplicate key `%s' in %s\n"
- (buffer-file-name) (bibtex-current-line) key
- (abbreviate-file-name (buffer-file-name buffer)))
+ (push (format-message
+ "%s:%d: Duplicate key `%s' in %s\n"
+ (buffer-file-name) (bibtex-current-line) key
+ (abbreviate-file-name (buffer-file-name buffer)))
error-list))))))
;; Process error list
@@ -4388,15 +4395,16 @@ Return t if test was successful, nil otherwise."
(unless (eq major-mode 'compilation-mode) (compilation-mode))
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
- (insert "BibTeX mode command `bibtex-validate-globally'\n\n")
+ (insert (substitute-command-keys
+ "BibTeX mode command `bibtex-validate-globally'\n\n"))
(dolist (err (sort error-list 'string-lessp)) (insert err))
(set-buffer-modified-p nil))
(goto-char (point-min))
(forward-line 2)) ; first error message
(display-buffer err-buf)
- nil) ; return `nil' (i.e., buffer is invalid)
+ nil) ; return nil (i.e., buffer is invalid)
(message "No duplicate keys.")
- t))) ; return `t' (i.e., buffer is valid)
+ t))) ; return t (i.e., buffer is valid)
(defun bibtex-next-field (begin &optional comma)
"Move point to end of text of next BibTeX field or entry head.
@@ -4839,7 +4847,7 @@ If optional arg MOVE is non-nil move point to end of field."
If optional prefix JUSTIFY is non-nil justify as well.
In BibTeX mode this function is bound to `fill-paragraph-function'."
(interactive "*P")
- (let ((pnt (copy-marker (point)))
+ (let ((pnt (point-marker))
(bounds (bibtex-enclosing-field t)))
(bibtex-fill-field-bounds bounds justify)
(goto-char pnt)))
@@ -4851,7 +4859,7 @@ names appear in column `bibtex-field-indentation', field text starts in
column `bibtex-text-indentation' and continuation lines start here, too.
If `bibtex-align-at-equal-sign' is non-nil, align equal signs, too."
(interactive "*")
- (let ((pnt (copy-marker (point)))
+ (let ((pnt (point-marker))
(beg (bibtex-beginning-of-entry)) ; move point
bounds)
(bibtex-delete-whitespace)
@@ -5103,7 +5111,7 @@ entries from minibuffer."
"Browse a URL for the BibTeX entry at point.
Optional POS is the location of the BibTeX entry.
The URL is generated using the schemes defined in `bibtex-generate-url-list'
-\(see there\). If multiple schemes match for this entry, or the same scheme
+\(see there). If multiple schemes match for this entry, or the same scheme
matches more than once, use the one for which the first step's match is the
closest to POS. The URL is passed to `browse-url' unless NO-BROWSE is t.
Return the URL or nil if none can be generated."
@@ -5279,7 +5287,7 @@ where FILE is the BibTeX file of ENTRY."
(bibtex-display-entries entries)
(message "No BibTeX entries %smatching `%s'"
(if (string= "" field) ""
- (format "with field `%s' " field))
+ (format-message "with field `%s' " field))
regexp)))
entries))
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 67f2d96d003..7d81bbca7d5 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -1,6 +1,6 @@
-;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files -*- coding: utf-8 -*-
+;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Keywords: conf ini windows java
@@ -122,7 +122,7 @@ not align (only setting space according to `conf-assignment-space')."
(define-key menu-map [c-s0] '("--"))
(define-key menu-map [conf-quote-normal]
'(menu-item "Set quote syntax normal" conf-quote-normal
- :help "Set the syntax of \' and \" to punctuation"))
+ :help "Set the syntax of \\=' and \" to punctuation"))
(define-key menu-map [conf-align-assignments]
'(menu-item "Align assignments" conf-align-assignments
:help "Align assignments"))
@@ -296,8 +296,8 @@ contents of the region. Otherwise, operate on the whole buffer."
(defun conf-quote-normal (arg)
- "Set the syntax of ' and \" to punctuation.
-With prefix arg, only do it for ' if 1, or only for \" if 2.
+ "Set the syntax of \\=' and \" to punctuation.
+With prefix arg, only do it for \\=' if 1, or only for \" if 2.
This only affects the current buffer. Some conf files use quotes
to delimit strings, while others allow quotes as simple parts of
the assigned value. In those files font locking will be wrong,
@@ -311,8 +311,7 @@ unbalanced, but hey...)"
(when (or (not arg) (= (prefix-numeric-value arg) 2))
(modify-syntax-entry ?\" "." table))
(set-syntax-table table)
- (when font-lock-mode
- (font-lock-fontify-buffer))))
+ (font-lock-flush)))
(defun conf-outline-level ()
@@ -435,7 +434,7 @@ For details see `conf-mode'. Example:
# Conf mode font-locks this right on Unix and with \\[conf-unix-mode]
-\[Desktop Entry]
+[Desktop Entry]
Encoding=UTF-8
Name=The GIMP
Name[ca]=El GIMP
@@ -450,11 +449,11 @@ For details see `conf-mode'. Example:
; Conf mode font-locks this right on Windows and with \\[conf-windows-mode]
-\[ExtShellFolderViews]
+[ExtShellFolderViews]
Default={5984FFE0-28D4-11CF-AE66-08002B2E1262}
{5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262}
-\[{5984FFE0-28D4-11CF-AE66-08002B2E1262}]
+[{5984FFE0-28D4-11CF-AE66-08002B2E1262}]
PersistMoniker=file://Folder.htt"
(conf-mode-initialize ";"))
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index cb19c018839..3e84b43bcb4 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1,8 +1,9 @@
-;;; css-mode.el --- Major mode to edit CSS files -*- lexical-binding: t -*-
+;;; css-mode.el --- Major mode to edit CSS files -*- lexical-binding: t -*-
-;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
+;; Maintainer: Simen Heggestøyl <simenheg@gmail.com>
;; Keywords: hypermedia
;; This file is part of GNU Emacs.
@@ -28,7 +29,7 @@
;; - electric ; and }
;; - filling code with auto-fill-mode
-;; - completion
+;; - attribute value completion
;; - fix font-lock errors with multi-line selectors
;;; Code:
@@ -37,96 +38,20 @@
"Cascading Style Sheets (CSS) editing mode."
:group 'languages)
+(defconst css-pseudo-class-ids
+ '("active" "checked" "disabled" "empty" "enabled" "first"
+ "first-child" "first-of-type" "focus" "hover" "indeterminate" "lang"
+ "last-child" "last-of-type" "left" "link" "not" "nth-child"
+ "nth-last-child" "nth-last-of-type" "nth-of-type" "only-child"
+ "only-of-type" "right" "root" "target" "visited")
+ "Identifiers for pseudo-classes.")
-(defun css-extract-keyword-list (res)
- (with-temp-buffer
- (url-insert-file-contents "http://www.w3.org/TR/REC-CSS2/css2.txt")
- (goto-char (point-max))
- (search-backward "Appendix H. Index")
- (forward-line)
- (delete-region (point-min) (point))
- (let ((result nil)
- keys)
- (dolist (re res)
- (goto-char (point-min))
- (setq keys nil)
- (while (re-search-forward (cdr re) nil t)
- (push (match-string 1) keys))
- (push (cons (car re) (sort keys 'string-lessp)) result))
- (nreverse result))))
-
-(defun css-extract-parse-val-grammar (string env)
- (let ((start 0)
- (elems ())
- name)
- (while (string-match
- (concat "\\(?:"
- (concat "<a [^>]+><span [^>]+>\\(?:"
- "&lt;\\([^&]+\\)&gt;\\|'\\([^']+\\)'"
- "\\)</span></a>")
- "\\|" "\\(\\[\\)"
- "\\|" "\\(]\\)"
- "\\|" "\\(||\\)"
- "\\|" "\\(|\\)"
- "\\|" "\\([*+?]\\)"
- "\\|" "\\({[^}]+}\\)"
- "\\|" "\\(\\w+\\(?:-\\w+\\)*\\)"
- "\\)[ \t\n]*")
- string start)
- ;; (assert (eq start (match-beginning 0)))
- (setq start (match-end 0))
- (cond
- ;; Reference to a type of value.
- ((setq name (match-string-no-properties 1 string))
- (push (intern name) elems))
- ;; Reference to another property's values.
- ((setq name (match-string-no-properties 2 string))
- (setq elems (delete-dups (append (cdr (assoc name env)) elems))))
- ;; A literal
- ((setq name (match-string-no-properties 9 string))
- (push name elems))
- ;; We just ignore the rest. I.e. we ignore the structure because
- ;; it's too difficult to exploit anyway (it would allow us to only
- ;; complete top/center/bottom after one of left/center/right and
- ;; vice-versa).
- (t nil)))
- elems))
-
-
-(defun css-extract-props-and-vals ()
- (with-temp-buffer
- (url-insert-file-contents "http://www.w3.org/TR/CSS21/propidx.html")
- (goto-char (point-min))
- (let ((props ()))
- (while (re-search-forward "#propdef-\\([^\"]+\\)\"><span class=\"propinst-\\1 xref\">'\\1'</span></a>" nil t)
- (let ((prop (match-string-no-properties 1)))
- (save-excursion
- (goto-char (match-end 0))
- (search-forward "<td>")
- (let ((vals-string (buffer-substring (point)
- (progn
- (re-search-forward "[ \t\n]+|[ \t\n]+<a href=\"cascade.html#value-def-inherit\" class=\"noxref\"><span class=\"value-inst-inherit\">inherit</span></a>")
- (match-beginning 0)))))
- ;;
- (push (cons prop (css-extract-parse-val-grammar vals-string props))
- props)))))
- props)))
-
-;; Extraction was done with:
-;; (css-extract-keyword-list
-;; '((pseudo . "^ +\\* :\\([^ \n,]+\\)")
-;; (at . "^ +\\* @\\([^ \n,]+\\)")
-;; (descriptor . "^ +\\* '\\([^ '\n]+\\)' (descriptor)")
-;; (media . "^ +\\* '\\([^ '\n]+\\)' media group")
-;; (property . "^ +\\* '\\([^ '\n]+\\)',")))
-
-(defconst css-pseudo-ids
- '("active" "after" "before" "first" "first-child" "first-letter" "first-line"
- "focus" "hover" "lang" "left" "link" "right" "visited")
- "Identifiers for pseudo-elements and pseudo-classes.")
+(defconst css-pseudo-element-ids
+ '("after" "before" "first-letter" "first-line")
+ "Identifiers for pseudo-elements.")
(defconst css-at-ids
- '("charset" "font-face" "import" "media" "page")
+ '("charset" "font-face" "import" "media" "namespace" "page")
"Identifiers that appear in the form @foo.")
(defconst css-descriptor-ids
@@ -142,36 +67,107 @@
"Identifiers for types of media.")
(defconst css-property-ids
- '("azimuth" "background" "background-attachment" "background-color"
- "background-image" "background-position" "background-repeat" "block"
- "border" "border-bottom" "border-bottom-color" "border-bottom-style"
- "border-bottom-width" "border-collapse" "border-color" "border-left"
- "border-left-color" "border-left-style" "border-left-width" "border-right"
+ '(;; CSS 2.1 properties (http://www.w3.org/TR/CSS21/propidx.html).
+ ;;
+ ;; Properties duplicated by any of the CSS3 modules below have
+ ;; been removed.
+ "azimuth" "border-collapse" "border-spacing" "bottom"
+ "caption-side" "clear" "clip" "content" "counter-increment"
+ "counter-reset" "cue" "cue-after" "cue-before" "direction" "display"
+ "elevation" "empty-cells" "float" "height" "left" "line-height"
+ "list-style" "list-style-image" "list-style-position"
+ "list-style-type" "margin" "margin-bottom" "margin-left"
+ "margin-right" "margin-top" "max-height" "max-width" "min-height"
+ "min-width" "orphans" "padding" "padding-bottom" "padding-left"
+ "padding-right" "padding-top" "page-break-after"
+ "page-break-before" "page-break-inside" "pause" "pause-after"
+ "pause-before" "pitch" "pitch-range" "play-during" "position"
+ "quotes" "richness" "right" "speak" "speak-header" "speak-numeral"
+ "speak-punctuation" "speech-rate" "stress" "table-layout" "top"
+ "unicode-bidi" "vertical-align" "visibility" "voice-family" "volume"
+ "widows" "width" "z-index"
+
+ ;; CSS Animations
+ ;; (http://www.w3.org/TR/css3-animations/#property-index)
+ "animation" "animation-delay" "animation-direction"
+ "animation-duration" "animation-fill-mode"
+ "animation-iteration-count" "animation-name"
+ "animation-play-state" "animation-timing-function"
+
+ ;; CSS Backgrounds and Borders Module Level 3
+ ;; (http://www.w3.org/TR/css3-background/#property-index)
+ "background" "background-attachment" "background-clip"
+ "background-color" "background-image" "background-origin"
+ "background-position" "background-repeat" "background-size"
+ "border" "border-bottom" "border-bottom-color"
+ "border-bottom-left-radius" "border-bottom-right-radius"
+ "border-bottom-style" "border-bottom-width" "border-color"
+ "border-image" "border-image-outset" "border-image-repeat"
+ "border-image-slice" "border-image-source" "border-image-width"
+ "border-left" "border-left-color" "border-left-style"
+ "border-left-width" "border-radius" "border-right"
"border-right-color" "border-right-style" "border-right-width"
- "border-spacing" "border-style" "border-top" "border-top-color"
- "border-top-style" "border-top-width" "border-width" "bottom"
- "caption-side" "clear" "clip" "color" "compact" "content"
- "counter-increment" "counter-reset" "cue" "cue-after" "cue-before"
- "cursor" "dashed" "direction" "display" "dotted" "double" "elevation"
- "empty-cells" "float" "font" "font-family" "font-size" "font-size-adjust"
- "font-stretch" "font-style" "font-variant" "font-weight" "groove" "height"
- "hidden" "inline" "inline-table" "inset" "left" "letter-spacing"
- "line-height" "list-item" "list-style" "list-style-image"
- "list-style-position" "list-style-type" "margin" "margin-bottom"
- "margin-left" "margin-right" "margin-top" "marker-offset" "marks"
- "max-height" "max-width" "min-height" "min-width" "orphans" "outline"
- "outline-color" "outline-style" "outline-width" "outset" "overflow"
- "padding" "padding-bottom" "padding-left" "padding-right" "padding-top"
- "page" "page-break-after" "page-break-before" "page-break-inside" "pause"
- "pause-after" "pause-before" "pitch" "pitch-range" "play-during" "position"
- "quotes" "richness" "ridge" "right" "run-in" "size" "solid" "speak"
- "speak-header" "speak-numeral" "speak-punctuation" "speech-rate" "stress"
- "table" "table-caption" "table-cell" "table-column" "table-column-group"
- "table-footer-group" "table-header-group" "table-layout" "table-row"
- "table-row-group" "text-align" "text-decoration" "text-indent"
- "text-shadow" "text-transform" "top" "unicode-bidi" "vertical-align"
- "visibility" "voice-family" "volume" "white-space" "widows" "width"
- "word-spacing" "z-index")
+ "border-style" "border-top" "border-top-color"
+ "border-top-left-radius" "border-top-right-radius"
+ "border-top-style" "border-top-width" "border-width" "box-shadow"
+
+ ;; CSS Basic User Interface Module Level 3 (CSS3 UI)
+ ;; (http://www.w3.org/TR/css3-ui/#property-index)
+ "box-sizing" "caret-color" "cursor" "nav-down" "nav-left"
+ "nav-right" "nav-up" "outline" "outline-color" "outline-offset"
+ "outline-style" "outline-width" "resize" "text-overflow"
+
+ ;; CSS Color Module Level 3
+ ;; (http://www.w3.org/TR/css3-color/#property)
+ "color" "opacity"
+
+ ;; CSS Flexible Box Layout Module Level 1
+ ;; (http://www.w3.org/TR/css-flexbox-1/#property-index)
+ "align-content" "align-items" "align-self" "flex" "flex-basis"
+ "flex-direction" "flex-flow" "flex-grow" "flex-shrink" "flex-wrap"
+ "justify-content" "order"
+
+ ;; CSS Fonts Module Level 3
+ ;; (http://www.w3.org/TR/css3-fonts/#property-index)
+ "font" "font-family" "font-feature-settings" "font-kerning"
+ "font-language-override" "font-size" "font-size-adjust"
+ "font-stretch" "font-style" "font-synthesis" "font-variant"
+ "font-variant-alternates" "font-variant-caps"
+ "font-variant-east-asian" "font-variant-ligatures"
+ "font-variant-numeric" "font-variant-position" "font-weight"
+
+ ;; CSS Overflow Module Level 3
+ ;; (http://www.w3.org/TR/css-overflow-3/#property-index)
+ "max-lines" "overflow" "overflow-x" "overflow-y"
+
+ ;; CSS Text Decoration Module Level 3
+ ;; (http://dev.w3.org/csswg/css-text-decor-3/#property-index)
+ "text-decoration" "text-decoration-color" "text-decoration-line"
+ "text-decoration-skip" "text-decoration-style" "text-emphasis"
+ "text-emphasis-color" "text-emphasis-position" "text-emphasis-style"
+ "text-shadow" "text-underline-position"
+
+ ;; CSS Text Module Level 3
+ ;; (http://www.w3.org/TR/css3-text/#property-index)
+ "hanging-punctuation" "hyphens" "letter-spacing" "line-break"
+ "overflow-wrap" "tab-size" "text-align" "text-align-last"
+ "text-indent" "text-justify" "text-transform" "white-space"
+ "word-break" "word-spacing" "word-wrap"
+
+ ;; CSS Transforms Module Level 1
+ ;; (http://www.w3.org/TR/css3-2d-transforms/#property-index)
+ "backface-visibility" "perspective" "perspective-origin"
+ "transform" "transform-origin" "transform-style"
+
+ ;; CSS Transitions
+ ;; (http://www.w3.org/TR/css3-transitions/#property-index)
+ "transition" "transition-delay" "transition-duration"
+ "transition-property" "transition-timing-function"
+
+ ;; Filter Effects Module Level 1
+ ;; (http://www.w3.org/TR/filter-effects/#property-index)
+ "color-interpolation-filters" "filter" "flood-color"
+ "flood-opacity" "lighting-color")
"Identifiers for properties.")
(defcustom css-electric-keys '(?\} ?\;) ;; '()
@@ -185,7 +181,7 @@
(let ((st (make-syntax-table)))
;; C-style comments.
(modify-syntax-entry ?/ ". 14" st)
- (modify-syntax-entry ?* ". 23" st)
+ (modify-syntax-entry ?* ". 23b" st)
;; Strings.
(modify-syntax-entry ?\" "\"" st)
(modify-syntax-entry ?\' "\"" st)
@@ -206,15 +202,29 @@
(modify-syntax-entry ?- "_" st)
st))
+(eval-and-compile
+ (defconst css--uri-re
+ (concat
+ "url\\((\\)[[:space:]]*\\(?:\\\\.\\|[^()[:space:]\n'\"]\\)+"
+ "[[:space:]]*\\()\\)")))
+
+(defconst css-syntax-propertize-function
+ (syntax-propertize-rules
+ (css--uri-re (1 "|") (2 "|"))))
+
(defconst css-escapes-re
"\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)")
(defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
-(defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
-(defconst css-ident-re (concat css-nmstart-re css-nmchar-re "*"))
+(defconst css-nmstart-re (concat "\\(?:--\\)?\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
+(defconst css-ident-re ;; (concat css-nmstart-re css-nmchar-re "*")
+ ;; Apparently, "at rules" names can start with a dash, e.g. @-moz-keyframes.
+ (concat css-nmchar-re "+"))
(defconst css-proprietary-nmstart-re ;; Vendor-specific properties.
(concat "[-_]" (regexp-opt '("ms" "moz" "o" "khtml" "webkit")) "-"))
(defconst css-name-re (concat css-nmchar-re "+"))
+(defconst scss--hash-re "#\\(?:{[$-_[:alnum:]]+}\\|[[:alnum:]]+\\)")
+
(defface css-selector '((t :inherit font-lock-function-name-face))
"Face to use for selectors."
:group 'css)
@@ -224,24 +234,48 @@
(defface css-proprietary-property '((t :inherit (css-property italic)))
"Face to use for vendor-specific properties.")
-(defvar css-font-lock-keywords
- `(("!\\s-*important" . font-lock-builtin-face)
+(defun css--font-lock-keywords (&optional sassy)
+ `((,(concat "!\\s-*"
+ (regexp-opt (append (if sassy '("global"))
+ '("important"))))
+ (0 font-lock-builtin-face))
;; Atrules keywords. IDs not in css-at-ids are valid (ignored).
;; In fact the regexp should probably be
;; (,(concat "\\(@" css-ident-re "\\)\\([ \t\n][^;{]*\\)[;{]")
;; (1 font-lock-builtin-face))
;; Since "An at-rule consists of everything up to and including the next
;; semicolon (;) or the next block, whichever comes first."
- (,(concat "@" css-ident-re) . font-lock-builtin-face)
+ (,(concat "@" css-ident-re) (0 font-lock-builtin-face))
;; Selectors.
;; FIXME: attribute selectors don't work well because they may contain
;; strings which have already been highlighted as f-l-string-face and
;; thus prevent this highlighting from being applied (actually now that
- ;; I use `append' this should work better). But really the part of hte
+ ;; I use `keep' this should work better). But really the part of the
;; selector between [...] should simply not be highlighted.
- (,(concat "^\\([ \t]*[^@:{}\n][^:{}]+\\(?::" (regexp-opt css-pseudo-ids t)
- "\\(?:([^)]+)\\)?[^:{\n]*\\)*\\)\\(?:\n[ \t]*\\)*{")
- (1 'css-selector append))
+ (,(concat
+ "^[ \t]*\\("
+ (if (not sassy)
+ ;; We don't allow / as first char, so as not to
+ ;; take a comment as the beginning of a selector.
+ "[^@/:{} \t\n][^:{}]+"
+ ;; Same as for non-sassy except we do want to allow { and }
+ ;; chars in selectors in the case of #{$foo}
+ ;; variable interpolation!
+ (concat "\\(?:" scss--hash-re
+ "\\|[^@/:{} \t\n#]\\)"
+ "[^:{}#]*\\(?:" scss--hash-re "[^:{}#]*\\)*"))
+ ;; Even though pseudo-elements should be prefixed by ::, a
+ ;; single colon is accepted for backward compatibility.
+ "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
+ css-pseudo-element-ids) t)
+ "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
+ "\\(?:([^)]+)\\)?"
+ (if (not sassy)
+ "[^:{}\n]*"
+ (concat "[^:{}\n#]*\\(?:" scss--hash-re "[^:{}\n#]*\\)*"))
+ "\\)*"
+ "\\)\\(?:\n[ \t]*\\)*{")
+ (1 'css-selector keep))
;; In the above rule, we allow the open-brace to be on some subsequent
;; line. This will only work if we properly mark the intervening text
;; as being part of a multiline element (and even then, this only
@@ -258,35 +292,138 @@
"\\(?:\\(" css-proprietary-nmstart-re "\\)\\|"
css-nmstart-re "\\)" css-nmchar-re "*"
"\\)\\s-*:")
- (1 (if (match-end 2) 'css-proprietary-property 'css-property)))))
+ (1 (if (match-end 2) 'css-proprietary-property 'css-property)))
+ ;; Make sure the parens in a url(...) expression receive the
+ ;; default face. This is done because the parens may sometimes
+ ;; receive generic string delimiter syntax (see
+ ;; `css-syntax-propertize-function').
+ (,css--uri-re
+ (1 'default t) (2 'default t))))
+
+(defvar css-font-lock-keywords (css--font-lock-keywords))
(defvar css-font-lock-defaults
'(css-font-lock-keywords nil t))
+(defcustom css-indent-offset 4
+ "Basic size of one indentation step."
+ :version "22.2"
+ :type 'integer)
+
+(require 'smie)
+
+(defconst css-smie-grammar
+ (smie-prec2->grammar
+ (smie-precs->prec2 '((assoc ";") (assoc ",") (left ":")))))
+
+(defun css-smie--forward-token ()
+ (cond
+ ((and (eq (char-before) ?\})
+ (scss-smie--not-interpolation-p)
+ ;; FIXME: If the next char is not whitespace, what should we do?
+ (or (memq (char-after) '(?\s ?\t ?\n))
+ (looking-at comment-start-skip)))
+ (if (memq (char-after) '(?\s ?\t ?\n))
+ (forward-char 1) (forward-comment 1))
+ ";")
+ ((progn (forward-comment (point-max))
+ (looking-at "[;,:]"))
+ (forward-char 1) (match-string 0))
+ (t (smie-default-forward-token))))
+
+(defun css-smie--backward-token ()
+ (let ((pos (point)))
+ (forward-comment (- (point)))
+ (cond
+ ;; FIXME: If the next char is not whitespace, what should we do?
+ ((and (eq (char-before) ?\}) (scss-smie--not-interpolation-p)
+ (> pos (point))) ";")
+ ((memq (char-before) '(?\; ?\, ?\:))
+ (forward-char -1) (string (char-after)))
+ (t (smie-default-backward-token)))))
+
+(defun css-smie-rules (kind token)
+ (pcase (cons kind token)
+ (`(:elem . basic) css-indent-offset)
+ (`(:elem . arg) 0)
+ (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467).
+ (`(:before . "{")
+ (when (or (smie-rule-hanging-p) (smie-rule-bolp))
+ (smie-backward-sexp ";")
+ (smie-indent-virtual)))
+ (`(:before . ,(or "{" "("))
+ (if (smie-rule-hanging-p) (smie-rule-parent 0)))))
+
+;;; Completion
+
+(defun css--complete-property ()
+ "Complete property at point."
+ (save-excursion
+ (let ((pos (point)))
+ (skip-chars-backward "-[:alnum:]")
+ (let ((start (point)))
+ (skip-chars-backward " \t\r\n")
+ (when (memq (char-before) '(?\{ ?\;))
+ (list start pos css-property-ids))))))
+
+(defun css--complete-pseudo-element-or-class ()
+ "Complete pseudo-element or pseudo-class at point."
+ (save-excursion
+ (let ((pos (point)))
+ (skip-chars-backward "-[:alnum:]")
+ (when (eq (char-before) ?\:)
+ (list (point) pos
+ (if (eq (char-before (- (point) 1)) ?\:)
+ css-pseudo-element-ids
+ css-pseudo-class-ids))))))
+
+(defun css--complete-at-rule ()
+ "Complete at-rule (statement beginning with `@') at point."
+ (save-excursion
+ (let ((pos (point)))
+ (skip-chars-backward "-[:alnum:]")
+ (when (eq (char-before) ?\@)
+ (list (point) pos css-at-ids)))))
+
+(defun css-completion-at-point ()
+ "Complete current symbol at point.
+Currently supports completion of CSS properties, pseudo-elements,
+pseudo-classes, and at-rules."
+ (or (css--complete-property)
+ (css--complete-pseudo-element-or-class)
+ (css--complete-at-rule)))
+
;;;###autoload
-(define-derived-mode css-mode fundamental-mode "CSS"
+(define-derived-mode css-mode prog-mode "CSS"
"Major mode to edit Cascading Style Sheets."
(setq-local font-lock-defaults css-font-lock-defaults)
(setq-local comment-start "/*")
(setq-local comment-start-skip "/\\*+[ \t]*")
(setq-local comment-end "*/")
(setq-local comment-end-skip "[ \t]*\\*+/")
- (setq-local forward-sexp-function 'css-forward-sexp)
- (setq-local parse-sexp-ignore-comments t)
- (setq-local indent-line-function 'css-indent-line)
- (setq-local fill-paragraph-function 'css-fill-paragraph)
+ (setq-local syntax-propertize-function
+ css-syntax-propertize-function)
+ (setq-local fill-paragraph-function #'css-fill-paragraph)
+ (setq-local adaptive-fill-function #'css-adaptive-fill)
(setq-local add-log-current-defun-function #'css-current-defun-name)
- (when css-electric-keys
- (let ((fc (make-char-table 'auto-fill-chars)))
- (set-char-table-parent fc auto-fill-chars)
- (dolist (c css-electric-keys)
- (aset fc c 'indent-according-to-mode))
- (setq-local auto-fill-chars fc))))
+ (smie-setup css-smie-grammar #'css-smie-rules
+ :forward-token #'css-smie--forward-token
+ :backward-token #'css-smie--backward-token)
+ (setq-local electric-indent-chars
+ (append css-electric-keys electric-indent-chars))
+ (add-hook 'completion-at-point-functions
+ #'css-completion-at-point nil 'local))
(defvar comment-continue)
(defun css-fill-paragraph (&optional justify)
(save-excursion
+ ;; Fill succeeding comment when invoked right before a multi-line
+ ;; comment.
+ (when (save-excursion
+ (beginning-of-line)
+ (comment-search-forward (point-at-eol) t))
+ (goto-char (match-end 0)))
(let ((ppss (syntax-ppss))
(eol (line-end-position)))
(cond
@@ -306,8 +443,11 @@
(paragraph-separate
(if (and comment-continue
(string-match "[^ \t]" comment-continue))
- (concat "\\(?:[ \t]*" (regexp-quote comment-continue)
- "\\)?\\(?:" paragraph-separate "\\)")
+ (concat "\\(?:[ \t]*\\(?:"
+ (regexp-quote comment-continue) "\\|"
+ comment-start-skip "\\|"
+ comment-end-skip "\\)\\)?"
+ "\\(?:" paragraph-separate "\\)")
paragraph-separate))
(paragraph-start
(if (and comment-continue
@@ -333,11 +473,16 @@
(cond
;; This is a false positive inside a string or comment.
((nth 8 (syntax-ppss)) nil)
+ ;; This is a false positive when encountering an
+ ;; interpolated variable (bug#19751).
+ ((eq (char-before (- (point) 1)) ?#) nil)
((eq (char-before) ?\})
(save-excursion
(forward-char -1)
(skip-chars-backward " \t")
- (unless (bolp) (newline))))
+ (when (and (not (bolp))
+ (scss-smie--not-interpolation-p))
+ (newline))))
(t
(while
(progn
@@ -355,131 +500,11 @@
;; Don't use the default filling code.
t)))))))
-;;; Navigation and indentation.
-
-(defconst css-navigation-syntax-table
- (let ((st (make-syntax-table css-mode-syntax-table)))
- (map-char-table (lambda (c v)
- ;; Turn punctuation (code = 1) into symbol (code = 1).
- (if (eq (car-safe v) 1)
- (set-char-table-range st c (cons 3 (cdr v)))))
- st)
- st))
-
-(defun css-backward-sexp (n)
- (let ((forward-sexp-function nil))
- (if (< n 0) (css-forward-sexp (- n))
- (while (> n 0)
- (setq n (1- n))
- (forward-comment (- (point-max)))
- (if (not (eq (char-before) ?\;))
- (backward-sexp 1)
- (while (progn (backward-sexp 1)
- (save-excursion
- (forward-comment (- (point-max)))
- ;; FIXME: We should also skip punctuation.
- (not (or (bobp) (memq (char-before) '(?\; ?\{))))))))))))
-
-(defun css-forward-sexp (n)
- (let ((forward-sexp-function nil))
- (if (< n 0) (css-backward-sexp (- n))
- (while (> n 0)
- (setq n (1- n))
- (forward-comment (point-max))
- (if (not (eq (char-after) ?\;))
- (forward-sexp 1)
- (while (progn (forward-sexp 1)
- (save-excursion
- (forward-comment (point-max))
- ;; FIXME: We should also skip punctuation.
- (not (memq (char-after) '(?\; ?\})))))))))))
-
-(defun css-indent-calculate-virtual ()
- (if (or (save-excursion (skip-chars-backward " \t") (bolp))
- (if (looking-at "\\s(")
- (save-excursion
- (forward-char 1) (skip-chars-forward " \t")
- (not (or (eolp) (looking-at comment-start-skip))))))
- (current-column)
- (css-indent-calculate)))
-
-(defcustom css-indent-offset 4
- "Basic size of one indentation step."
- :version "22.2"
- :type 'integer
- :group 'css)
-
-(defun css-indent-calculate ()
- (let ((ppss (syntax-ppss))
- pos)
- (with-syntax-table css-navigation-syntax-table
- (save-excursion
- (cond
- ;; Inside a string.
- ((nth 3 ppss) 'noindent)
- ;; Inside a comment.
- ((nth 4 ppss)
- (setq pos (point))
- (forward-line -1)
- (skip-chars-forward " \t")
- (if (>= (nth 8 ppss) (point))
- (progn
- (goto-char (nth 8 ppss))
- (if (eq (char-after pos) ?*)
- (forward-char 1)
- (if (not (looking-at comment-start-skip))
- (error "Internal css-mode error")
- (goto-char (match-end 0))))
- (current-column))
- (if (and (eq (char-after pos) ?*) (eq (char-after) ?*))
- (current-column)
- ;; 'noindent
- (current-column)
- )))
- ;; In normal code.
- (t
- (or
- (when (looking-at "\\s)")
- (forward-char 1)
- (backward-sexp 1)
- (css-indent-calculate-virtual))
- (when (looking-at comment-start-skip)
- (forward-comment (point-max))
- (css-indent-calculate))
- (when (save-excursion (forward-comment (- (point-max)))
- (setq pos (point))
- (eq (char-syntax (preceding-char)) ?\())
- (goto-char (1- pos))
- (if (not (looking-at "\\s([ \t]*"))
- (error "Internal css-mode error")
- (if (or (memq (char-after (match-end 0)) '(?\n nil))
- (save-excursion (goto-char (match-end 0))
- (looking-at comment-start-skip)))
- (+ (css-indent-calculate-virtual) css-indent-offset)
- (progn (goto-char (match-end 0)) (current-column)))))
- (progn
- (css-backward-sexp 1)
- (if (looking-at "\\s(")
- (css-indent-calculate)
- (css-indent-calculate-virtual))))))))))
-
-
-(defun css-indent-line ()
- "Indent current line according to CSS indentation rules."
- (interactive)
- (let* ((savep (point))
- (forward-sexp-function nil)
- (indent (condition-case nil
- (save-excursion
- (forward-line 0)
- (skip-chars-forward " \t")
- (if (>= (point) savep) (setq savep nil))
- (css-indent-calculate))
- (error nil))))
- (if (not (numberp indent)) 'noindent
- (if savep
- (save-excursion (indent-line-to indent))
- (indent-line-to indent)))))
+(defun css-adaptive-fill ()
+ (when (looking-at "[ \t]*/\\*[ \t]*")
+ (let ((str (match-string 0)))
+ (and (string-match "/\\*" str)
+ (replace-match " *" t t str)))))
(defun css-current-defun-name ()
"Return the name of the CSS section at point, or nil."
@@ -491,5 +516,36 @@
(if (looking-at "^[ \t]*\\([^{\r\n]*[^ {\t\r\n]\\)")
(match-string-no-properties 1))))))
+;;; SCSS mode
+
+(defvar scss-mode-syntax-table
+ (let ((st (make-syntax-table css-mode-syntax-table)))
+ (modify-syntax-entry ?/ ". 124" st)
+ (modify-syntax-entry ?\n ">" st)
+ st))
+
+(defvar scss-font-lock-keywords
+ (append `((,(concat "$" css-ident-re) (0 font-lock-variable-name-face)))
+ (css--font-lock-keywords 'sassy)
+ `((,(concat "@mixin[ \t]+\\(" css-ident-re "\\)[ \t]*(")
+ (1 font-lock-function-name-face)))))
+
+(defun scss-smie--not-interpolation-p ()
+ (save-excursion
+ (forward-char -1)
+ (or (zerop (skip-chars-backward "-[:alnum:]"))
+ (not (looking-back "#{\\$" (- (point) 3))))))
+
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
+;;;###autoload
+(define-derived-mode scss-mode css-mode "SCSS"
+ "Major mode to edit \"Sassy CSS\" files."
+ (setq-local comment-start "// ")
+ (setq-local comment-end "")
+ (setq-local comment-continue " *")
+ (setq-local comment-start-skip "/[*/]+[ \t]*")
+ (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
+ (setq-local font-lock-defaults '(scss-font-lock-keywords nil t)))
+
(provide 'css-mode)
;;; css-mode.el ends here
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index fe7ae17373c..4862d453d97 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -1,6 +1,6 @@
;;; dns-mode.el --- a mode for viewing/editing Domain Name System master files
-;; Copyright (C) 2000-2001, 2004-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2004-2015 Free Software Foundation, Inc.
;; Author: Simon Josefsson <simon@josefsson.org>
;; Keywords: DNS master zone file SOA comm
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el
index e22ad24ccae..040a50e3099 100644
--- a/lisp/textmodes/enriched.el
+++ b/lisp/textmodes/enriched.el
@@ -1,6 +1,6 @@
;;; enriched.el --- read and save files in text/enriched format
-;; Copyright (C) 1994-1996, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2001-2015 Free Software Foundation, Inc.
;; Author: Boris Goldowsky <boris@gnu.org>
;; Keywords: wp, faces
@@ -31,7 +31,7 @@
;; are supported except for <smaller> and <bigger>, which are currently not
;; possible to display.
-;; A separate file, enriched.doc, contains further documentation and other
+;; A separate file, enriched.txt, contains further documentation and other
;; important information about this code. It also serves as an example
;; file in text/enriched format. It should be in the etc directory of your
;; emacs distribution.
@@ -199,7 +199,7 @@ if ARG is omitted or nil.
Turning the mode on or off runs `enriched-mode-hook'.
More information about Enriched mode is available in the file
-etc/enriched.doc in the Emacs distribution directory.
+\"enriched.txt\" in `data-directory'.
Commands:
@@ -314,7 +314,8 @@ the region, and the START and END of each region."
;;;###autoload
(defun enriched-encode (from to orig-buf)
(if enriched-verbose (message "Enriched: encoding document..."))
- (let ((inhibit-read-only t))
+ (let ((inhibit-read-only t)
+ (inhibit-point-motion-hooks t))
(save-restriction
(narrow-to-region from to)
(delete-to-left-margin)
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 119b4b04593..a97facf5427 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -1,9 +1,9 @@
-;;; fill.el --- fill commands for Emacs -*- coding: utf-8 -*-
+;;; fill.el --- fill commands for Emacs
-;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2013 Free
+;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2015 Free
;; Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; Package: emacs
@@ -329,13 +329,24 @@ places."
(and (memq (preceding-char) '(?\t ?\s))
(eq (char-syntax (following-char)) ?w)))))))
+(defun fill-single-char-nobreak-p ()
+ "Return non-nil if a one-letter word is before point.
+This function is suitable for adding to the hook `fill-nobreak-predicate',
+to prevent the breaking of a line just after a one-letter word,
+which is an error according to some typographical conventions."
+ (save-excursion
+ (skip-chars-backward " \t")
+ (backward-char 2)
+ (looking-at "[[:space:]][[:alpha:]]")))
+
(defcustom fill-nobreak-predicate nil
"List of predicates for recognizing places not to break a line.
The predicates are called with no arguments, with point at the place to
be tested. If it returns t, fill commands do not break the line there."
:group 'fill
:type 'hook
- :options '(fill-french-nobreak-p fill-single-word-nobreak-p))
+ :options '(fill-french-nobreak-p fill-single-word-nobreak-p
+ fill-single-char-nobreak-p))
(defcustom fill-nobreak-invisible nil
"Non-nil means that fill commands do not break lines in invisible text."
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 81f17c897eb..6c4a731629c 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1,9 +1,9 @@
-;;; flyspell.el --- on-the-fly spell checker
+;;; flyspell.el --- On-the-fly spell checker -*- lexical-binding:t -*-
-;; Copyright (C) 1998, 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2015 Free Software Foundation, Inc.
;; Author: Manuel Serrano <Manuel.Serrano@sophia.inria.fr>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: convenience
;; This file is part of GNU Emacs.
@@ -39,6 +39,7 @@
;;; Code:
(require 'ispell)
+(eval-when-compile (require 'cl-lib))
;;*---------------------------------------------------------------------*/
;;* Group ... */
@@ -92,7 +93,7 @@ downcased before comparing with these exceptions."
:version "21.1"
:type 'boolean)
-(defcustom flyspell-duplicate-distance -1
+(defcustom flyspell-duplicate-distance 400000
"The maximum distance for finding duplicates of unrecognized words.
This applies to the feature that when a word is not found in the dictionary,
if the same spelling occurs elsewhere in the buffer,
@@ -101,7 +102,7 @@ This variable specifies how far to search to find such a duplicate.
-1 means no limit (search the whole buffer).
0 means do not search for duplicate unrecognized spellings."
:group 'flyspell
- :version "21.1"
+ :version "24.5" ; -1 -> 400000
:type '(choice (const :tag "no limit" -1)
number))
@@ -283,6 +284,7 @@ If this variable is nil, all regions are treated as small."
(defcustom flyspell-auto-correct-binding
[(control ?\;)]
"The key binding for flyspell auto correction."
+ :type 'key-sequence
:group 'flyspell)
;;*---------------------------------------------------------------------*/
@@ -302,8 +304,8 @@ Returns t to continue checking, nil otherwise.
Flyspell mode sets this variable to whatever is the `flyspell-mode-predicate'
property of the major mode name.")
(make-variable-buffer-local 'flyspell-generic-check-word-predicate)
-(defvaralias 'flyspell-generic-check-word-p
- 'flyspell-generic-check-word-predicate)
+(define-obsolete-variable-alias 'flyspell-generic-check-word-p
+ 'flyspell-generic-check-word-predicate "25.1")
;;*--- mail mode -------------------------------------------------------*/
(put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
@@ -311,21 +313,22 @@ property of the major mode name.")
(defvar message-signature-separator)
(defun mail-mode-flyspell-verify ()
"Function used for `flyspell-generic-check-word-predicate' in Mail mode."
- (let ((header-end (save-excursion
- (goto-char (point-min))
- (re-search-forward
- (concat "^"
- (regexp-quote mail-header-separator)
- "$")
- nil t)
- (point)))
- (signature-begin
- (if (not (boundp 'message-signature-separator))
- (point-max)
- (save-excursion
- (goto-char (point-max))
- (re-search-backward message-signature-separator nil t)
- (point)))))
+ (let* ((header-end (save-excursion
+ (goto-char (point-min))
+ (re-search-forward
+ (concat "^\\(?:"
+ (regexp-quote mail-header-separator)
+ "\\)?$")
+ nil t)
+ (point)))
+ (signature-begin
+ (if (not (boundp 'message-signature-separator))
+ (point-max)
+ (save-excursion
+ (goto-char (point-max))
+ (re-search-backward message-signature-separator
+ (max header-end (- (point) 4000)) t)
+ (point)))))
(cond ((< (point) header-end)
(and (save-excursion (beginning-of-line)
(looking-at "^Subject:"))
@@ -395,7 +398,7 @@ like <img alt=\"Some thing.\">."
"Turn on `flyspell-mode' for comments and strings."
(interactive)
(setq flyspell-generic-check-word-predicate
- 'flyspell-generic-progmode-verify)
+ #'flyspell-generic-progmode-verify)
(flyspell-mode 1)
(run-hooks 'flyspell-prog-mode-hook))
@@ -498,7 +501,7 @@ invoking `ispell-change-dictionary'.
Consider using the `ispell-parser' to check your text. For instance
consider adding:
-\(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))
+\(add-hook \\='tex-mode-hook (function (lambda () (setq ispell-parser \\='tex))))
in your init file.
\\[flyspell-region] checks all words inside a region.
@@ -790,7 +793,7 @@ before the current command."
;;*---------------------------------------------------------------------*/
;;* flyspell-after-change-function ... */
;;*---------------------------------------------------------------------*/
-(defun flyspell-after-change-function (start stop len)
+(defun flyspell-after-change-function (start stop _len)
"Save the current buffer and point for Flyspell's post-command hook."
(push (cons start stop) flyspell-changes))
@@ -1009,17 +1012,33 @@ Mostly we check word delimiters."
;;*---------------------------------------------------------------------*/
(defun flyspell-word-search-backward (word bound &optional ignore-case)
(save-excursion
- (let ((r '())
- (inhibit-point-motion-hooks t)
- p)
- (while (and (not r) (setq p (search-backward word bound t)))
- (let ((lw (flyspell-get-word)))
- (if (and (consp lw)
- (if ignore-case
- (string-equal (downcase (car lw)) (downcase word))
- (string-equal (car lw) word)))
- (setq r p)
- (goto-char p))))
+ (let* ((r '())
+ (inhibit-point-motion-hooks t)
+ (flyspell-not-casechars (flyspell-get-not-casechars))
+ (bound (if (and bound
+ (> bound (point-min)))
+ (- bound 1)))
+ (word-re (concat
+ "\\(?:" flyspell-not-casechars "\\|\\`\\)"
+ (regexp-quote word)
+ flyspell-not-casechars))
+ p)
+ (while
+ (and (not r)
+ (setq p
+ (and
+ (re-search-backward word-re bound t)
+ (if (bobp)
+ (point)
+ (forward-char)
+ (point)))))
+ (let ((lw (flyspell-get-word)))
+ (if (and (consp lw)
+ (if ignore-case
+ (string-equal (downcase (car lw)) (downcase word))
+ (string-equal (car lw) word)))
+ (setq r p)
+ (goto-char p))))
r)))
;;*---------------------------------------------------------------------*/
@@ -1027,16 +1046,32 @@ Mostly we check word delimiters."
;;*---------------------------------------------------------------------*/
(defun flyspell-word-search-forward (word bound)
(save-excursion
- (let ((r '())
- (inhibit-point-motion-hooks t)
- p)
- (while (and (not r) (setq p (search-forward word bound t)))
- (let ((lw (flyspell-get-word)))
- (if (and (consp lw) (string-equal (car lw) word))
- (setq r p)
- (goto-char (1+ p)))))
+ (let* ((r '())
+ (inhibit-point-motion-hooks t)
+ (flyspell-not-casechars (flyspell-get-not-casechars))
+ (bound (if (and bound
+ (< bound (point-max)))
+ (+ bound 1)))
+ (word-re (concat flyspell-not-casechars
+ (regexp-quote word)
+ "\\(?:" flyspell-not-casechars "\\|\\'\\)"))
+ p)
+ (while
+ (and (not r)
+ (setq p (and
+ (re-search-forward word-re bound t)
+ (if (eobp)
+ (point)
+ (backward-char)
+ (point)))))
+ (let ((lw (flyspell-get-word)))
+ (if (and (consp lw) (string-equal (car lw) word))
+ (setq r p)
+ (goto-char (1+ p)))))
r)))
+(defvar flyspell-word) ;Backward compatibility; some predicates made use of it!
+
;;*---------------------------------------------------------------------*/
;;* flyspell-word ... */
;;*---------------------------------------------------------------------*/
@@ -1084,7 +1119,8 @@ misspelling and skips redundant spell-checking step."
(let* ((bound
(- start
(- end start)
- (- (skip-chars-backward " \t\n\f"))))
+ (- (save-excursion
+ (skip-chars-backward " \t\n\f")))))
(p (when (>= bound (point-min))
(flyspell-word-search-backward word bound t))))
(and p (/= p start)))))
@@ -1314,7 +1350,7 @@ that may be included as part of a word (see `ispell-dictionary-alist')."
(if (and flyspell-issue-message-flag (= count 100))
(progn
(message "Spell Checking...%d%%"
- (* 100 (/ (float (- (point) beg)) (- end beg))))
+ (floor (* 100.0 (- (point) beg)) (- end beg)))
(setq count 0))
(setq count (+ 1 count)))
(flyspell-word)
@@ -1367,7 +1403,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
;; be unnecessary too. -- rms.
(if flyspell-issue-message-flag
(message "Spell Checking...%d%% [%s]"
- (* 100 (/ (float (point)) (point-max)))
+ (floor (* 100.0 (point)) (point-max))
word))
(with-current-buffer flyspell-large-region-buffer
(goto-char buffer-scan-pos)
@@ -1419,9 +1455,9 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
;; end of last validated match.
(setq buffer-scan-pos (point))))
;; Record if misspelling is not found and try new one
- (add-to-list 'words-not-found
- (concat " -> " word " - "
- (int-to-string wordpos)))
+ (cl-pushnew (concat " -> " word " - "
+ (int-to-string wordpos))
+ words-not-found :test #'equal)
(setq keep nil)))))))
;; we are done
(if flyspell-issue-message-flag (message "Spell Checking completed.")))
@@ -1527,7 +1563,8 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
(let ((extended-char-mode (ispell-get-extended-character-mode)))
(and extended-char-mode ; ~ extended character mode
(string-match "[^~]+$" extended-char-mode)
- (add-to-list 'args (concat "-T" (match-string 0 extended-char-mode)))))
+ (cl-pushnew (concat "-T" (match-string 0 extended-char-mode))
+ args :test #'equal)))
;; Add ispell-extra-args
(setq args (append args ispell-extra-args))
@@ -1791,11 +1828,12 @@ as returned by `ispell-parse-output'."
;;* flyspell-check-previous-highlighted-word ... */
;;*---------------------------------------------------------------------*/
(defun flyspell-check-previous-highlighted-word (&optional arg)
- "Correct the closer misspelled word.
-This function scans a mis-spelled word before the cursor. If it finds one
-it proposes replacement for that word. With prefix arg, count that many
-misspelled words backwards."
- (interactive)
+ "Correct the closest previous word that is highlighted as misspelled.
+This function scans for a word which starts before point that has been
+highlighted by Flyspell as misspelled. If it finds one, it proposes
+a replacement for that word. With prefix arg N, check the Nth word
+before point that's highlighted as misspelled."
+ (interactive "P")
(let ((pos1 (point))
(pos (point))
(arg (if (or (not (numberp arg)) (< arg 1)) 1 arg))
@@ -1806,7 +1844,7 @@ misspelled words backwards."
(setq pos1 pos)
(if (> pos (point-min))
(progn
- (setq ovs (overlays-at (1- pos)))
+ (setq ovs (overlays-at pos))
(while (consp ovs)
(setq ov (car ovs))
(setq ovs (cdr ovs))
@@ -2051,8 +2089,6 @@ If EVENT is non-nil, it is the mouse event that invoked this operation;
that controls where to put the menu.
If OPOINT is non-nil, restore point there after adjusting it for replacement."
(interactive)
- (unless (mouse-position)
- (error "Pop-up menus do not work on this terminal"))
;; use the correct dictionary
(flyspell-accept-buffer-local-defs)
(or opoint (setq opoint (point)))
@@ -2167,9 +2203,8 @@ If OPOINT is non-nil, restore point there after adjusting it for replacement."
;;*---------------------------------------------------------------------*/
(defun flyspell-emacs-popup (event poss word)
"The Emacs popup menu."
- (unless window-system
- (error "This command requires pop-up dialogs"))
- (if (not event)
+ (if (and (not event)
+ (display-mouse-p))
(let* ((mouse-pos (mouse-position))
(mouse-pos (if (nth 1 mouse-pos)
mouse-pos
@@ -2291,7 +2326,7 @@ If the text between BEG and END is equal to a correction suggested by
Ispell, after transposing two adjacent characters, correct the text,
and return t.
-The third arg POSS is either the symbol 'doublon' or a list of
+The third arg POSS is either the symbol `doublon' or a list of
possible corrections as returned by `ispell-parse-output'.
This function is meant to be added to `flyspell-incorrect-hook'."
@@ -2321,7 +2356,7 @@ If the text between BEG and END is equal to a correction suggested by
Ispell, after removing a pair of doubled characters, correct the text,
and return t.
-The third arg POSS is either the symbol 'doublon' or a list of
+The third arg POSS is either the symbol `doublon' or a list of
possible corrections as returned by `ispell-parse-output'.
This function is meant to be added to `flyspell-incorrect-hook'."
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 3998fafa5cc..fe27f0f158c 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1,6 +1,6 @@
;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
-;; Copyright (C) 1994-1995, 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 1997-2015 Free Software Foundation, Inc.
;; Author: Ken Stevens <k.stevens@ieee.org>
;; Maintainer: Ken Stevens <k.stevens@ieee.org>
@@ -388,7 +388,7 @@ It consists of pairs (REGEXP . DICTIONARY). If REGEXP is found
in the message headers, `ispell-local-dictionary' will be set to
DICTIONARY if `ispell-local-dictionary' is not buffer-local.
E.g. you may use the following value:
- '((\"^Newsgroups:[ \\t]*de\\\\.\" . \"deutsch8\")
+ ((\"^Newsgroups:[ \\t]*de\\\\.\" . \"deutsch8\")
(\"^To:[^\\n,]+\\\\.de[ \\t\\n,>]\" . \"deutsch8\"))"
:type '(repeat (cons regexp string))
:group 'ispell)
@@ -484,7 +484,7 @@ The function must take one string argument and return a string."
"When non-nil ispell uses framepop to display choices in a dedicated frame.
You can set this variable to dynamically use framepop if you are in a
window system by evaluating the following on startup to set this variable:
- (and window-system (condition-case () (require 'framepop) (error nil)))"
+ (and window-system (condition-case () (require \\='framepop) (error nil)))"
:type 'boolean
:group 'ispell)
@@ -492,7 +492,7 @@ window system by evaluating the following on startup to set this variable:
(defcustom ispell-personal-dictionary nil
"File name of your personal spelling dictionary, or nil.
If nil, the default personal dictionary, (\"~/.ispell_DICTNAME\" for ispell or
-\"~/.aspell.LANG.pws\" for aspell) is used, where DICTNAME is the name of your
+\"~/.aspell.LANG.pws\" for Aspell) is used, where DICTNAME is the name of your
default dictionary and LANG the two letter language code."
:type '(choice file
(const :tag "default" nil))
@@ -699,8 +699,8 @@ re-start Emacs."
Each element of this list is also a list:
-\(DICTIONARY-NAME CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P
- ISPELL-ARGS EXTENDED-CHARACTER-MODE CHARACTER-SET\)
+ (DICTIONARY-NAME CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P
+ ISPELL-ARGS EXTENDED-CHARACTER-MODE CHARACTER-SET)
DICTIONARY-NAME is a possible string value of variable `ispell-dictionary',
nil means the default dictionary.
@@ -747,35 +747,35 @@ when the language uses non-ASCII characters.
Note that with \"ispell\" as the speller, the CASECHARS and
OTHERCHARS slots of the alist should contain the same character
set as casechars and otherchars in the LANGUAGE.aff file \(e.g.,
-english.aff\). aspell and hunspell don't have this limitation.")
+english.aff). Aspell and Hunspell don't have this limitation.")
(defvar ispell-really-aspell nil
- "Non-nil if we can use aspell extensions.")
+ "Non-nil if we can use Aspell extensions.")
(defvar ispell-really-hunspell nil
- "Non-nil if we can use hunspell extensions.")
+ "Non-nil if we can use Hunspell extensions.")
(defvar ispell-encoding8-command nil
"Command line option prefix to select encoding if supported, nil otherwise.
If setting the encoding is supported by spellchecker and is selectable from
-the command line, this variable will contain \"--encoding=\" for aspell
-and \"-i \" for hunspell, so the appropriate mime charset can be selected.
-That will be set in `ispell-check-version' for hunspell >= 1.1.6 and
-aspell >= 0.60.
+the command line, this variable will contain \"--encoding=\" for Aspell
+and \"-i \" for Hunspell, so the appropriate mime charset can be selected.
+That will be set in `ispell-check-version' for Hunspell >= 1.1.6 and
+Aspell >= 0.60.
-For aspell, non-nil also means to try to automatically find its dictionaries.
+For Aspell, non-nil also means to try to automatically find its dictionaries.
-Earlier aspell versions do not consistently support charset encoding. Handling
+Earlier Aspell versions do not consistently support charset encoding. Handling
this would require some extra guessing in `ispell-aspell-find-dictionary'.")
(defvar ispell-aspell-supports-utf8 nil
- "Non-nil if aspell has consistent command line UTF-8 support. Obsolete.
+ "Non-nil if Aspell has consistent command line UTF-8 support. Obsolete.
ispell.el and flyspell.el will use for this purpose the more generic
-variable `ispell-encoding8-command' for both aspell and hunspell. Is left
+variable `ispell-encoding8-command' for both Aspell and Hunspell. Is left
here just for backwards compatibility.")
(make-obsolete-variable 'ispell-aspell-supports-utf8
'ispell-encoding8-command "23.1")
-(defvar ispell-hunspell-dictionary-equivs-alist
+(defvar ispell-dicts-name2locale-equivs-alist
'(("american" "en_US")
("brasileiro" "pt_BR")
("british" "en_GB")
@@ -807,7 +807,7 @@ here just for backwards compatibility.")
("slovenian" "sl_SI")
("svenska" "sv_SE")
("hebrew" "he_IL"))
- "Alist with matching hunspell dict names for standard dict names in
+ "Alist with known matching locales for standard dict names in
`ispell-dictionary-base-alist'.")
(defvar ispell-emacs-alpha-regexp
@@ -931,22 +931,20 @@ Otherwise returns the library directory name, if that is defined."
(defun ispell-call-process (&rest args)
"Like `call-process' but defend against bad `default-directory'."
(let ((default-directory default-directory))
- (unless (and (file-directory-p default-directory)
- (file-readable-p default-directory))
+ (unless (file-accessible-directory-p default-directory)
(setq default-directory (expand-file-name "~/")))
(apply 'call-process args)))
(defun ispell-call-process-region (&rest args)
"Like `call-process-region' but defend against bad `default-directory'."
(let ((default-directory default-directory))
- (unless (and (file-directory-p default-directory)
- (file-readable-p default-directory))
+ (unless (file-accessible-directory-p default-directory)
(setq default-directory (expand-file-name "~/")))
(apply 'call-process-region args)))
(defun ispell-create-debug-buffer (&optional append)
"Create an ispell debug buffer for debugging output.
-Use APPEND to append the info to previous buffer if exists,
+If APPEND is non-nil, append the info to previous buffer if exists,
otherwise is reset. Returns name of ispell debug buffer.
See `ispell-buffer-with-debug' for an example of use."
(let ((ispell-debug-buffer (get-buffer-create "*ispell-debug*")))
@@ -958,7 +956,7 @@ See `ispell-buffer-with-debug' for an example of use."
ispell-debug-buffer))
(defsubst ispell-print-if-debug (format &rest args)
- "Print message to `ispell-debug-buffer' buffer if enabled."
+ "Print message using FORMAT and ARGS to `ispell-debug-buffer' buffer if enabled."
(if (boundp 'ispell-debug-buffer)
(with-current-buffer ispell-debug-buffer
(goto-char (point-max))
@@ -1011,13 +1009,13 @@ and added as a submenu of the \"Edit\" menu.")
;; Make ispell.el work better with aspell.
(defvar ispell-aspell-dictionary-alist nil
- "An alist of parsed aspell dicts and associated parameters.
+ "An alist of parsed Aspell dicts and associated parameters.
Internal use.")
(defun ispell-find-aspell-dictionaries ()
"Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
(unless (and ispell-really-aspell ispell-encoding8-command)
- (error "This function only works with aspell >= 0.60"))
+ (error "This function only works with Aspell >= 0.60"))
(let* ((dictionaries
(split-string
(with-temp-buffer
@@ -1055,30 +1053,40 @@ Assumes that value contains no whitespace."
(car (split-string (buffer-string)))))
(defun ispell-aspell-find-dictionary (dict-name)
- "For aspell dictionary DICT-NAME, return a list of parameters if an
+ "For Aspell dictionary DICT-NAME, return a list of parameters if an
associated data file is found or nil otherwise. List format is that
of `ispell-dictionary-base-alist' elements."
+
+ ;; Make sure `ispell-aspell-dict-dir' is defined
+ (or ispell-aspell-dict-dir
+ (setq ispell-aspell-dict-dir
+ (ispell-get-aspell-config-value "dict-dir")))
+
;; Make sure `ispell-aspell-data-dir' is defined
(or ispell-aspell-data-dir
(setq ispell-aspell-data-dir
(ispell-get-aspell-config-value "data-dir")))
- ;; Try finding associated datafile
- (let* ((datafile1
- (concat ispell-aspell-data-dir "/"
- ;; Strip out variant, country code, etc.
- (and (string-match "^[[:alpha:]]+" dict-name)
- (match-string 0 dict-name)) ".dat"))
- (datafile2
- (concat ispell-aspell-data-dir "/"
- ;; Strip out anything but xx_YY.
- (and (string-match "^[[:alpha:]_]+" dict-name)
- (match-string 0 dict-name)) ".dat"))
- (data-file
- (if (file-readable-p datafile1)
- datafile1
- (if (file-readable-p datafile2)
- datafile2)))
- otherchars)
+
+ ;; Try finding associated datafile. aspell will look for master .dat
+ ;; file in `dict-dir' and `data-dir'. Associated .dat files must be
+ ;; in the same directory as master file.
+ (let ((data-file
+ (catch 'datafile
+ (dolist ( tmp-path (list ispell-aspell-dict-dir
+ ispell-aspell-data-dir ))
+ ;; Try xx.dat first, strip out variant, country code, etc,
+ ;; then try xx_YY.dat (without stripping country code),
+ ;; then try xx-alt.dat, for de-alt etc.
+ (dolist (tmp-regexp (list "^[[:alpha:]]+"
+ "^[[:alpha:]_]+"
+ "^[[:alpha:]]+-\\(alt\\|old\\)"))
+ (let ((fullpath
+ (concat tmp-path "/"
+ (and (string-match tmp-regexp dict-name)
+ (match-string 0 dict-name)) ".dat")))
+ (if (file-readable-p fullpath)
+ (throw 'datafile fullpath)))))))
+ otherchars)
(if data-file
(with-temp-buffer
@@ -1111,7 +1119,7 @@ of `ispell-dictionary-base-alist' elements."
'utf-8)))))
(defun ispell-aspell-add-aliases (alist)
- "Find aspell's dictionary aliases and add them to dictionary ALIST.
+ "Find Aspell's dictionary aliases and add them to dictionary ALIST.
Return the new dictionary alist."
(let ((aliases
(file-expand-wildcards
@@ -1130,46 +1138,53 @@ Return the new dictionary alist."
(realdict (assoc realname alist)))
(when (and realdict (not already-exists-p))
(push (cons aliasname (cdr realdict)) alist))))))
+ ;; Add entries for standard dict-names with found locale-matching entry
+ (dolist (dict-map-entry ispell-dicts-name2locale-equivs-alist)
+ (let ((name (car dict-map-entry))
+ (locale (cadr dict-map-entry)))
+ (unless (assoc name alist) ;; skip if already present
+ (if (assoc locale alist)
+ (push (cons name (cdr (assoc locale alist))) alist)))))
alist))
;; Make ispell.el work better with hunspell.
(defvar ispell-hunspell-dict-paths-alist nil
- "Alist of parsed hunspell dicts and associated affix files.
+ "Alist of parsed Hunspell dicts and associated affix files.
Will be used to parse corresponding .aff file and create associated
parameters to be inserted into `ispell-hunspell-dictionary-alist'.
Internal use.")
(defvar ispell-hunspell-dictionary-alist nil
- "Alist of parsed hunspell dicts and associated parameters.
+ "Alist of parsed Hunspell dicts and associated parameters.
This alist will initially contain names of found dicts. Associated
parameters will be added when dict is used for the first time.
Internal use.")
(defun ispell-hunspell-fill-dictionary-entry (dict)
- "Fill `ispell-dictionary-alist' uninitialized entries for `DICT' and aliases.
-Value will be extracted from hunspell affix file and used for
+ "Fill uninitialized entries in `ispell-dictionary-alist' for DICT and aliases.
+Value of those entries will be extracted from Hunspell affix file and used for
all uninitialized dicts using that affix file."
(if (cadr (assoc dict ispell-dictionary-alist))
(message "ispell-hfde: Non void entry for %s. Skipping.\n" dict)
(let ((dict-alias
- (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist)))
+ (cadr (assoc dict ispell-dicts-name2locale-equivs-alist)))
(use-for-dicts (list dict))
(dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict)))
newlist)
;; Get a list of uninitialized dicts using the same affix file.
- (dolist (dict-equiv-alist-entry ispell-hunspell-dictionary-equivs-alist)
+ (dolist (dict-equiv-alist-entry ispell-dicts-name2locale-equivs-alist)
(let ((dict-equiv-key (car dict-equiv-alist-entry))
(dict-equiv-value (cadr dict-equiv-alist-entry)))
(if (or (member dict dict-equiv-alist-entry)
(member dict-alias dict-equiv-alist-entry))
- (dolist ( tmp-dict (list dict-equiv-key dict-equiv-value))
+ (dolist (tmp-dict (list dict-equiv-key dict-equiv-value))
(if (cadr (assoc tmp-dict ispell-dictionary-alist))
(ispell-print-if-debug
- "ispell-hfde: %s already expanded. Skipping.\n" tmp-dict)
+ "ispell-hfde: %s already expanded; skipping.\n" tmp-dict)
(add-to-list 'use-for-dicts tmp-dict))))))
(ispell-print-if-debug
- "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts)
+ "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts)
;; The final loop.
(dolist (entry ispell-dictionary-alist)
(if (member (car entry) use-for-dicts)
@@ -1179,52 +1194,89 @@ all uninitialized dicts using that affix file."
(setq ispell-dictionary-alist newlist))))
(defun ispell-parse-hunspell-affix-file (dict-key)
- "Parse hunspell affix file to extract parameters for `DICT-KEY'.
-Return a list in `ispell-dictionary-alist' format."
- (let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist))))
- (unless affix-file
- (error "ispell-phaf: No matching entry for %s.\n" dict-key))
- (if (not (file-exists-p affix-file))
- (error "ispell-phaf: File \"%s\" not found.\n" affix-file))
- (let ((dict-name (file-name-sans-extension
- (file-name-nondirectory affix-file)))
- otherchars-string otherchars-list)
- (with-temp-buffer
- (insert-file-contents affix-file)
- (setq otherchars-string
- (save-excursion
- (goto-char (point-min))
- (if (search-forward-regexp "^WORDCHARS +" nil t )
- (buffer-substring (point)
- (progn (end-of-line) (point))))))
- ;; Remove trailing whitespace and extra stuff. Make list if
- ;; non-nil.
- (setq otherchars-list
- (if otherchars-string
- (split-string
- (if (string-match " +.*$" otherchars-string)
- (replace-match "" nil nil otherchars-string)
- otherchars-string)
- "" t)))
-
- ;; Fill dict entry
- (list dict-key
- "[[:alpha:]]"
- "[^[:alpha:]]"
- (if otherchars-list
- (regexp-opt otherchars-list)
- "")
- t ; many-otherchars-p: We can't tell, set to t.
- (list "-d" dict-name)
- nil ; extended-char-mode: not supported by hunspell!
- 'utf-8)))))
+ "Parse Hunspell affix file to extract parameters for DICT-KEY.
+Return a list in `ispell-dictionary-alist' format.
+
+DICT_KEY can be in the \"DICT1,DICT2,DICT3\" format, to invoke Hunspell
+with a list of dictionaries. The first dictionary in the list must have
+a corresponding .aff affix file; the rest are allowed to have no affix
+files, and will then use the affix file of the preceding dictionary that
+did."
+ (let ((dict-list (split-string dict-key "," t))
+ (first-p t)
+ (dict-arg "")
+ otherchars-list)
+ (dolist (dict-key dict-list)
+ (let ((affix-file
+ (cadr (assoc dict-key ispell-hunspell-dict-paths-alist))))
+ (unless affix-file
+ (error "ispell-phaf: No matching entry for %s in `ispell-hunspell-dict-paths-alist'.\n" dict-key))
+ (if (and first-p (not (file-exists-p affix-file)))
+ (error "ispell-phaf: File \"%s\" not found.\n" affix-file))
+ (and first-p (setq first-p nil))
+ (let ((dict-name (file-name-sans-extension
+ (file-name-nondirectory affix-file)))
+ otherchars-string)
+ (with-temp-buffer
+ (insert-file-contents affix-file)
+ (setq otherchars-string
+ (save-excursion
+ (goto-char (point-min))
+ (if (search-forward-regexp "^WORDCHARS +" nil t )
+ (buffer-substring (point)
+ (progn (end-of-line) (point))))))
+ ;; Remove trailing whitespace and extra stuff. Make list
+ ;; if non-nil.
+ (if otherchars-string
+ (let* ((otherchars-string
+ ;; Remove trailing junk.
+ (substring otherchars-string
+ 0 (string-match " +" otherchars-string)))
+ (chars-list (append otherchars-string nil)))
+ (setq chars-list (delq ?\ chars-list))
+ (dolist (ch chars-list)
+ (add-to-list 'otherchars-list ch)))))
+ ;; Cons the argument for the -d switch.
+ (setq dict-arg (concat dict-arg
+ (if (> (length dict-arg) 0) ",")
+ dict-name)))))
+
+ ;; Fill dict entry
+ (list dict-key
+ "[[:alpha:]]"
+ "[^[:alpha:]]"
+ (if otherchars-list
+ (regexp-opt (mapcar 'char-to-string otherchars-list))
+ "")
+ t ; many-otherchars-p: We can't tell, set to t.
+ (list "-d" dict-arg)
+ nil ; extended-char-mode: not supported by hunspell!
+ 'utf-8)))
+
+(defun ispell-hunspell-add-multi-dic (dict)
+ "Add DICT of the form \"DICT1,DICT2,...\" to `ispell-dictionary-alist'.
+
+Invoke this command before you want to start Hunspell for the first time
+with a particular combination of dictionaries. The first dictionary
+in the list must have an affix file where Hunspell affix files are kept."
+ (interactive "sMulti-dictionary combination: ")
+ ;; Make sure the first dictionary in the list is known to us.
+ (let ((first-dict (car (split-string dict "," t))))
+ (unless ispell-hunspell-dictionary-alist
+ (ispell-find-hunspell-dictionaries)
+ (setq ispell-dictionary-alist ispell-hunspell-dictionary-alist))
+ (or (assoc first-dict ispell-local-dictionary-alist)
+ (assoc first-dict ispell-dictionary-alist)
+ (error "Unknown dictionary: %s" first-dict)))
+ (add-to-list 'ispell-dictionary-alist (list dict '()))
+ (ispell-hunspell-fill-dictionary-entry dict))
(defun ispell-find-hunspell-dictionaries ()
- "Look for installed hunspell dictionaries.
+ "Look for installed Hunspell dictionaries.
Will initialize `ispell-hunspell-dictionary-alist' and
`ispell-hunspell-dictionary-alist' after values found
-and remove `ispell-hunspell-dictionary-equivs-alist'
-entries if a specific dict was found."
+and remove `ispell-dicts-name2locale-equivs-alist'
+entries if a specific dictionary was found."
(let ((hunspell-found-dicts
(split-string
(with-temp-buffer
@@ -1245,7 +1297,7 @@ entries if a specific dict was found."
(if (string-match "\\.aff$" dict)
;; Found default dictionary
(if hunspell-default-dict
- (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n"
+ (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n"
hunspell-default-dict dict)
(setq affix-file dict)
(setq hunspell-default-dict (list basename affix-file)))
@@ -1262,15 +1314,15 @@ entries if a specific dict was found."
"-- ispell-fhd: Skipping entry: %s\n" dict)))))
;; Remove entry from aliases alist if explicit dict was found.
(let (newlist)
- (dolist (dict ispell-hunspell-dictionary-equivs-alist)
+ (dolist (dict ispell-dicts-name2locale-equivs-alist)
(if (assoc (car dict) ispell-hunspell-dict-paths-alist)
(ispell-print-if-debug
- "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
+ "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
(car dict))
(add-to-list 'newlist dict)))
- (setq ispell-hunspell-dictionary-equivs-alist newlist))
+ (setq ispell-dicts-name2locale-equivs-alist newlist))
;; Add known hunspell aliases
- (dolist (dict-equiv ispell-hunspell-dictionary-equivs-alist)
+ (dolist (dict-equiv ispell-dicts-name2locale-equivs-alist)
(let ((dict-equiv-key (car dict-equiv))
(dict-equiv-value (cadr dict-equiv))
(exclude-aliases (list ;; Exclude TeX aliases
@@ -1367,7 +1419,7 @@ aspell is used along with Emacs).")
(let* ((dict-name (nth 0 adict))
(dict-equiv
(cadr (assoc dict-name
- ispell-hunspell-dictionary-equivs-alist)))
+ ispell-dicts-name2locale-equivs-alist)))
(ispell-args (nth 5 adict))
(ispell-args-has-d (member "-d" ispell-args))
skip-dict)
@@ -1386,7 +1438,7 @@ aspell is used along with Emacs).")
(setq ispell-args
(nconc ispell-args (list "-d" dict-equiv)))
(message
- "ispell-set-spellchecker-params: Missing hunspell equiv for \"%s\". Skipping."
+ "ispell-set-spellchecker-params: Missing Hunspell equiv for \"%s\". Skipping."
dict-name)
(setq skip-dict t)))
@@ -1604,12 +1656,12 @@ The variable `ispell-library-directory' defines their location."
(defvar ispell-current-dictionary nil
"The name of the current dictionary, or nil for the default.
-This is passed to the ispell process using the `-d' switch and is
+This is passed to the Ispell process using the `-d' switch and is
used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.")
(defvar ispell-current-personal-dictionary nil
"The name of the current personal dictionary, or nil for the default.
-This is passed to the ispell process using the `-p' switch.")
+This is passed to the Ispell process using the `-p' switch.")
(defun ispell-decode-string (str)
"Decodes multibyte character strings.
@@ -1844,7 +1896,7 @@ Currently the only other valid parser is `tex'.
You can set this variable in hooks in your init file -- eg:
-\(add-hook 'tex-mode-hook (lambda () (setq ispell-parser 'tex)))")
+\(add-hook \\='tex-mode-hook (lambda () (setq ispell-parser \\='tex)))")
(defvar ispell-region-end (make-marker)
"Marker that allows spelling continuations.")
@@ -1862,9 +1914,9 @@ You can set this variable in hooks in your init file -- eg:
(defun ispell-accept-output (&optional timeout-secs timeout-msecs)
- "Wait for output from ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS.
+ "Wait for output from Ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS.
If asynchronous subprocesses are not supported, call function `ispell-filter'
-and pass it the output of the last ispell invocation."
+and pass it the output of the last Ispell invocation."
(if ispell-async-processp
(accept-process-output ispell-process timeout-secs timeout-msecs)
(if (null ispell-process)
@@ -1881,8 +1933,8 @@ and pass it the output of the last ispell invocation."
(erase-buffer)))))))
(defun ispell-send-replacement (misspelled replacement)
- "Notify aspell that MISSPELLED should be spelled REPLACEMENT.
-This allows it to improve the suggestion list based on actual misspellings."
+ "Notify Aspell that MISSPELLED should be spelled REPLACEMENT.
+This allows to improve the suggestion list based on actual misspellings."
(and ispell-really-aspell
(ispell-send-string (concat "$$ra " misspelled "," replacement "\n"))))
@@ -1972,7 +2024,7 @@ in a window allowing you to choose one.
If optional argument FOLLOWING is non-nil or if `ispell-following-word'
is non-nil when called interactively, then the following word
-\(rather than preceding\) is checked when the cursor is not over a word.
+\(rather than preceding) is checked when the cursor is not over a word.
When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil
when called interactively, non-corrective messages are suppressed.
@@ -1992,7 +2044,7 @@ Return values:
nil word is correct or spelling is accepted.
0 word is inserted into buffer-local definitions.
\"word\" word corrected from word list.
-\(\"word\" arg\) word is hand entered.
+\(\"word\" arg) word is hand entered.
quit spell session exited."
(interactive (list ispell-following-word ispell-quietly current-prefix-arg t))
(cond
@@ -2110,7 +2162,7 @@ quit spell session exited."
"Return the word for spell-checking according to ispell syntax.
If optional argument FOLLOWING is non-nil or if `ispell-following-word'
is non-nil when called interactively, then the following word
-\(rather than preceding\) is checked when the cursor is not over a word.
+\(rather than preceding) is checked when the cursor is not over a word.
Optional second argument contains otherchars that can be included in word
many times (see the doc string of `ispell-dictionary-alist' for details
about otherchars).
@@ -2211,16 +2263,12 @@ indicates whether the dictionary has been modified when option `a'
or `i' is used.
Global `ispell-quit' set to start location to continue spell session."
(let ((count ?0)
- (line ispell-choices-win-default-height)
- ;; ensure 4 context lines.
- (max-lines (- (ispell-adjusted-window-height) 4))
(choices miss)
(window-min-height (min window-min-height
ispell-choices-win-default-height))
(command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m ))
- (dedicated (window-dedicated-p))
(skipped 0)
- char num result textwin dedicated-win)
+ char num result textwin)
;; setup the *Choices* buffer with valid data.
(with-current-buffer (get-buffer-create ispell-choices-buffer)
@@ -2235,30 +2283,28 @@ Global `ispell-quit' set to start location to continue spell session."
(boundp 'horizontal-scrollbar-visible-p)
(set-specifier horizontal-scrollbar-visible-p nil
(cons (current-buffer) nil))))
+ (ispell-with-no-warnings
+ (and (boundp 'horizontal-scroll-bar)
+ (setq horizontal-scroll-bar nil)))
(erase-buffer)
(if guess
(progn
(insert "Affix rules generate and capitalize "
"this word as shown below:\n\t")
(while guess
- (if (> (+ 4 (current-column) (length (car guess)))
- (window-width))
- (progn
- (insert "\n\t")
- (setq line (1+ line))))
+ (when (> (+ 4 (current-column) (length (car guess)))
+ (window-width))
+ (insert "\n\t"))
(insert (car guess) " ")
(setq guess (cdr guess)))
- (insert "\nUse option `i' to accept this spelling and put it in your private dictionary.\n")
- (setq line (+ line (if choices 3 2)))))
- (while (and choices
- (< (if (> (+ 7 (current-column) (length (car choices))
- (if (> count ?~) 3 0))
- (window-width))
- (progn
- (insert "\n")
- (setq line (1+ line)))
- line)
- max-lines))
+ (insert (substitute-command-keys
+ "\nUse option `i' to accept this spelling and put it in your private dictionary.\n"))))
+ (while choices
+ (when (> (+ 7 (current-column)
+ (length (car choices))
+ (if (> count ?~) 3 0))
+ (window-width))
+ (insert "\n"))
;; not so good if there are over 20 or 30 options, but then, if
;; there are that many you don't want to scan them all anyway...
(while (memq count command-characters) ; skip command characters.
@@ -2273,15 +2319,10 @@ Global `ispell-quit' set to start location to continue spell session."
(if (not (pos-visible-in-window-p end))
(sit-for 0))
- ;; allow temporary split of dedicated windows...
- (if dedicated
- (progn
- (setq dedicated-win (selected-window))
- (set-window-dedicated-p dedicated-win nil)))
-
;; Display choices for misspelled word.
- (ispell-show-choices line end)
- (select-window (setq textwin (next-window)))
+ (setq textwin (selected-window))
+ (ispell-show-choices)
+ (select-window textwin)
;; highlight word, protecting current buffer status
(unwind-protect
@@ -2407,19 +2448,14 @@ Global `ispell-quit' set to start location to continue spell session."
" -- word-list: "
(or ispell-complete-word-dict
ispell-alternate-dictionary))
- miss (lookup-words new-word)
- choices miss
- line ispell-choices-win-default-height)
- (while (and choices ; adjust choices window.
- (< (if (> (+ 7 (current-column)
- (length (car choices))
- (if (> count ?~) 3 0))
- (window-width))
- (progn
- (insert "\n")
- (setq line (1+ line)))
- line)
- max-lines))
+ miss (ispell-lookup-words new-word)
+ choices miss)
+ (while choices
+ (when (> (+ 7 (current-column)
+ (length (car choices))
+ (if (> count ?~) 3 0))
+ (window-width))
+ (insert "\n"))
(while (memq count command-characters)
(setq count (ispell-int-char (1+ count))
skipped (1+ skipped)))
@@ -2428,8 +2464,9 @@ Global `ispell-quit' set to start location to continue spell session."
count (ispell-int-char (1+ count))))
(setq count (ispell-int-char
(- count ?0 skipped))))
- (ispell-show-choices line end)
- (select-window (next-window)))))
+ (setq textwin (selected-window))
+ (ispell-show-choices)
+ (select-window textwin))))
(and (eq 'block ispell-highlight-p)
(ispell-highlight-spelling-error start end nil
'block))
@@ -2489,44 +2526,19 @@ Global `ispell-quit' set to start location to continue spell session."
(and ispell-highlight-p ; unhighlight
(save-window-excursion
(select-window textwin)
- (ispell-highlight-spelling-error start end)))
- (if dedicated
- (set-window-dedicated-p dedicated-win t)))))
+ (ispell-highlight-spelling-error start end))))))
-(defun ispell-show-choices (line end)
+(defun ispell-show-choices ()
"Show the choices in another buffer or frame."
(if (and ispell-use-framepop-p (fboundp 'framepop-display-buffer))
(progn
(framepop-display-buffer (get-buffer ispell-choices-buffer))
;; (get-buffer-window ispell-choices-buffer t)
(select-window (previous-window))) ; *Choices* window
- ;; standard selection by splitting a small buffer out of this window.
- (let ((choices-window (get-buffer-window ispell-choices-buffer)))
- (if choices-window
- (if (= line (ispell-adjusted-window-height choices-window))
- (select-window choices-window)
- ;; *Choices* window changed size. Adjust the choices window
- ;; without scrolling the spelled window when possible
- (let ((window-line
- (- line (ispell-adjusted-window-height choices-window)))
- (visible (progn (vertical-motion -1) (point))))
- (if (< line ispell-choices-win-default-height)
- (setq window-line (+ window-line
- (- ispell-choices-win-default-height
- line))))
- (move-to-window-line 0)
- (vertical-motion window-line)
- (set-window-start (selected-window)
- (if (> (point) visible) visible (point)))
- (goto-char end)
- (select-window choices-window)
- (enlarge-window window-line)))
- ;; Overlay *Choices* window when it isn't showing
- (ispell-overlay-window (max line ispell-choices-win-default-height)))
- (switch-to-buffer ispell-choices-buffer)
- (goto-char (point-min)))))
+ ;; Display choices above selected window.
+ (ispell-display-buffer (get-buffer-create ispell-choices-buffer))))
;;;###autoload
@@ -2596,10 +2608,10 @@ SPC: Accept word this time.
"Type 'x C-h f ispell-help' for more help")))
(save-window-excursion
(if ispell-help-in-bufferp
- (progn
- (ispell-overlay-window 4)
- (switch-to-buffer (get-buffer-create "*Ispell Help*"))
- (insert (concat help-1 "\n" help-2 "\n" help-3))
+ (let ((buffer (get-buffer-create "*Ispell Help*")))
+ (with-current-buffer buffer
+ (insert (concat help-1 "\n" help-2 "\n" help-3)))
+ (ispell-display-buffer buffer)
(sit-for 5)
(kill-buffer "*Ispell Help*"))
(unwind-protect
@@ -2613,8 +2625,9 @@ SPC: Accept word this time.
(sit-for 5))
(erase-buffer)))))))
+(define-obsolete-function-alias 'lookup-words 'ispell-lookup-words "24.4")
-(defun lookup-words (word &optional lookup-dict)
+(defun ispell-lookup-words (word &optional lookup-dict)
"Look up WORD in optional word-list dictionary LOOKUP-DICT.
A `*' serves as a wild card. If no wild cards, `look' is used if it exists.
Otherwise the variable `ispell-grep-command' contains the command used to
@@ -2648,8 +2661,12 @@ if defined."
(message "Starting \"%s\" process..." (file-name-nondirectory prog))
(if look-p
nil
+ (insert "^" word)
+ ;; When there are no wildcards, append one, for consistency
+ ;; with `look' behavior.
+ (unless wild-p (insert "*"))
+ (insert "$")
;; Convert * to .*
- (insert "^" word "$")
(while (search-backward "*" nil t) (insert "."))
(setq word (buffer-string))
(erase-buffer))
@@ -2813,49 +2830,35 @@ The variable `ispell-highlight-face' selects the face to use for highlighting."
(ispell-highlight-spelling-error-overlay start end highlight))
(t (ispell-highlight-spelling-error-generic start end highlight refresh))))
-(defun ispell-adjusted-window-height (&optional window)
- "Like `window-height', adjusted to correct for the effect of tall mode-lines.
-The value returned is actually the nominal number of text-lines in the
-window plus 1. On a terminal, this is the same value returned by
-`window-height', but if the window has a mode-line is taller than a normal
-text line, the returned value may be smaller than that from
-`window-height'."
- (cond ((fboundp 'window-text-height)
- (1+ (window-text-height window)))
- ((or (and (fboundp 'display-graphic-p) (display-graphic-p))
- (and (featurep 'xemacs) window-system))
- (1- (window-height window)))
- (t
- (window-height window))))
-
-(defun ispell-overlay-window (height)
- "Create a window covering the top HEIGHT lines of the current window.
-Ensure that the line above point is still visible but otherwise avoid
-scrolling the current window. Leave the new window selected."
- (save-excursion
- (let ((oldot (save-excursion (vertical-motion -1) (point)))
- (top (save-excursion (move-to-window-line height) (point))))
- ;; If line above old point (line starting at oldot) would be
- ;; hidden by new window, scroll it to just below new win
- ;; otherwise set top line of other win so it doesn't scroll.
- (if (< oldot top) (setq top oldot))
- ;; if frame is unsplittable, temporarily disable that...
- (if (cdr (assq 'unsplittable (frame-parameters (selected-frame))))
- (let ((frame (selected-frame)))
- (modify-frame-parameters frame '((unsplittable . nil)))
- (split-window nil height)
- (modify-frame-parameters frame '((unsplittable . t))))
- (split-window nil height))
- (let ((deficit (- height (ispell-adjusted-window-height))))
- (when (> deficit 0)
- ;; Number of lines the window is still too short. We ensure that
- ;; there are at least (1- HEIGHT) lines visible in the window.
- (enlarge-window deficit)
- (goto-char top)
- (vertical-motion deficit)
- (setq top (min (point) oldot))))
- (set-window-start (next-window) top))))
-
+(defun ispell-display-buffer (buffer)
+ "Show BUFFER in new window above selected one.
+Also position fit window to BUFFER and select it."
+ (let* ((unsplittable
+ (cdr (assq 'unsplittable (frame-parameters (selected-frame)))))
+ (window
+ (or (get-buffer-window buffer)
+ (and unsplittable
+ ;; If frame is unsplittable, temporarily disable that...
+ (let ((frame (selected-frame)))
+ (modify-frame-parameters frame '((unsplittable . nil)))
+ (prog1
+ (condition-case nil
+ (split-window
+ nil (- ispell-choices-win-default-height) 'above)
+ (error nil))
+ (modify-frame-parameters frame '((unsplittable . t))))))
+ (and (not unsplittable)
+ (condition-case nil
+ (split-window
+ nil (- ispell-choices-win-default-height) 'above)
+ (error nil)))
+ (display-buffer buffer))))
+ (if (not window)
+ (error "Couldn't make window for *Choices*")
+ (select-window window)
+ (set-window-buffer window buffer)
+ (set-window-point window (point-min))
+ (fit-window-to-buffer window nil nil nil nil t))))
;; Should we add a compound word match return value?
(defun ispell-parse-output (output &optional accept-list shift)
@@ -2934,8 +2937,7 @@ Keeps argument list for future Ispell invocations for no async support."
(ispell-hunspell-fill-dictionary-entry ispell-current-dictionary)))
(let* ((default-directory
- (if (and (file-directory-p default-directory)
- (file-readable-p default-directory))
+ (if (file-accessible-directory-p default-directory)
default-directory
;; Defend against bad `default-directory'.
(expand-file-name "~/")))
@@ -2993,8 +2995,7 @@ Keeps argument list for future Ispell invocations for no async support."
(if (or ispell-really-aspell
ispell-really-hunspell
;; Protect against bad default-directory
- (not (and (file-directory-p default-directory)
- (file-readable-p default-directory)))
+ (not (file-accessible-directory-p default-directory))
;; Ispell and per-dir personal dicts available
(not (or (file-readable-p (concat default-directory
".ispell_words"))
@@ -3020,15 +3021,19 @@ Keeps argument list for future Ispell invocations for no async support."
(setq ispell-filter nil ispell-filter-continue nil)
;; may need to restart to select new personal dictionary.
(ispell-kill-ispell t)
- (message "Starting new Ispell process [%s::%s] ..."
+ (message "Starting new Ispell process %s with %s dictionary..."
ispell-program-name
(or ispell-local-dictionary ispell-dictionary "default"))
(sit-for 0)
(setq ispell-library-directory (ispell-check-version)
+ ;; Assign a non-nil value to ispell-process-directory
+ ;; before calling ispell-start-process, since that
+ ;; function needs it to set default-directory when
+ ;; ispell-async-processp is nil.
+ ispell-process-directory default-directory
ispell-process (ispell-start-process)
ispell-filter nil
- ispell-filter-continue nil
- ispell-process-directory default-directory)
+ ispell-filter-continue nil)
(unless (equal ispell-process-directory (expand-file-name "~/"))
;; At this point, `ispell-process-directory' will be "~/" unless using
@@ -3054,7 +3059,12 @@ Keeps argument list for future Ispell invocations for no async support."
(if (and (or (featurep 'xemacs)
(and (boundp 'enable-multibyte-characters)
enable-multibyte-characters))
- (fboundp 'set-process-coding-system))
+ (fboundp 'set-process-coding-system)
+ ;; Evidently, some people use the synchronous mode even
+ ;; when async subprocesses are supported, in which case
+ ;; set-process-coding-system is bound, but
+ ;; ispell-process is not a process object.
+ ispell-async-processp)
(set-process-coding-system ispell-process (ispell-get-coding-system)
(ispell-get-coding-system)))
;; Get version ID line
@@ -3300,7 +3310,8 @@ ispell-region: Search for first region to skip after (ispell-begin-skip-region-r
ispell-start ispell-end (point-at-eol) in-comment add-comment string)
(if add-comment ; account for comment chars added
(setq ispell-start (- ispell-start (length add-comment))
- add-comment nil))
+ ;; Reset `in-comment' (and indirectly `add-comment') for new line
+ in-comment nil))
(setq ispell-end (point)) ; "end" tracks region retrieved.
(if string ; there is something to spell check!
;; (special start end)
@@ -3429,7 +3440,7 @@ Must be called after `ispell-buffer-local-parsing' due to dependence on mode."
(defun ispell-ignore-fcc (start end)
"Delete the Fcc: message header when large attachments are included.
-Return value `nil' if file with large attachments is saved.
+Return value nil if file with large attachments is saved.
This can be used to avoid multiple questions for multiple large attachments.
Returns point to starting location afterwards."
(let ((result t))
@@ -3729,7 +3740,7 @@ Returns the sum SHIFT due to changes in word replacements."
;;;###autoload
(defun ispell-buffer-with-debug (&optional append)
"`ispell-buffer' with some output sent to `ispell-debug-buffer' buffer.
-Use APPEND to append the info to previous buffer if exists."
+If APPEND is non-n il, append the info to previous buffer if exists."
(interactive)
(let ((ispell-debug-buffer (ispell-create-debug-buffer append)))
(ispell-buffer)))
@@ -3766,8 +3777,8 @@ Use APPEND to append the info to previous buffer if exists."
;;;###autoload
(defun ispell-complete-word (&optional interior-frag)
- "Try to complete the word before or under point (see `lookup-words').
-If optional INTERIOR-FRAG is non-nil then the word may be a character
+ "Try to complete the word before or at point.
+If optional INTERIOR-FRAG is non-nil, then the word may be a character
sequence inside of a word.
Standard ispell choices are then available."
@@ -3782,11 +3793,11 @@ Standard ispell choices are then available."
word (car word)
possibilities
(or (string= word "") ; Will give you every word
- (lookup-words (concat (and interior-frag "*") word
- (if (or interior-frag (null ispell-look-p))
- "*"))
- (or ispell-complete-word-dict
- ispell-alternate-dictionary))))
+ (ispell-lookup-words
+ (concat (and interior-frag "*") word
+ (and interior-frag "*"))
+ (or ispell-complete-word-dict
+ ispell-alternate-dictionary))))
(cond ((eq possibilities t)
(message "No word to complete"))
((null possibilities)
@@ -3873,7 +3884,7 @@ typing SPC or RET warns you if the previous word is incorrectly
spelled.
All the buffer-local variables and dictionaries are ignored. To
-read them into the running ispell process, type \\[ispell-word]
+read them into the running Ispell process, type \\[ispell-word]
SPC.
For spell-checking \"on the fly\", not just after typing SPC or
@@ -3927,7 +3938,7 @@ Otherwise, it must be a function which is called to get the limit.")
(defun ispell-mime-multipartp (&optional limit)
"Return multipart message start boundary or nil if none."
- ;; caller must ensure `case-fold-search' is set to `t'
+ ;; caller must ensure `case-fold-search' is set to t
(and
(re-search-forward
"Content-Type: *multipart/\\([^ \t\n]*;[ \t]*[\n]?[ \t]*\\)+boundary="
@@ -4029,14 +4040,14 @@ The `X' command aborts sending the message so that you can edit the buffer.
To spell-check whenever a message is sent, include the appropriate lines
in your init file:
- (add-hook 'message-send-hook 'ispell-message) ;; GNUS 5
- (add-hook 'news-inews-hook 'ispell-message) ;; GNUS 4
- (add-hook 'mail-send-hook 'ispell-message)
- (add-hook 'mh-before-send-letter-hook 'ispell-message)
+ (add-hook \\='message-send-hook \\='ispell-message) ;; GNUS 5
+ (add-hook \\='news-inews-hook \\='ispell-message) ;; GNUS 4
+ (add-hook \\='mail-send-hook \\='ispell-message)
+ (add-hook \\='mh-before-send-letter-hook \\='ispell-message)
You can bind this to the key C-c i in GNUS or mail by adding to
`news-reply-mode-hook' or `mail-mode-hook' the following lambda expression:
- (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))"
+ (function (lambda () (local-set-key \"\\C-ci\" \\='ispell-message)))"
(interactive)
(save-excursion
(goto-char (point-min))
diff --git a/lisp/textmodes/makeinfo.el b/lisp/textmodes/makeinfo.el
index 4b57e0b9746..0ca4cbefe93 100644
--- a/lisp/textmodes/makeinfo.el
+++ b/lisp/textmodes/makeinfo.el
@@ -1,9 +1,9 @@
;;; makeinfo.el --- run makeinfo conveniently
-;; Copyright (C) 1991, 1993, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993, 2001-2015 Free Software Foundation, Inc.
;; Author: Robert J. Chassell
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: docs convenience
;; This file is part of GNU Emacs.
@@ -66,7 +66,7 @@ The name of the file is appended to this string, separated by a space."
"String containing options for running `makeinfo'.
Do not include `--footnote-style' or `--paragraph-indent';
the proper way to specify those is with the Texinfo commands
-`@footnotestyle` and `@paragraphindent'."
+`@footnotestyle' and `@paragraphindent'."
:type 'string
:group 'makeinfo)
@@ -228,7 +228,7 @@ nonsensical results."
"Make Info file from current buffer.
Use the \\[next-error] command to move to the next error
-\(if there are errors\)."
+\(if there are errors)."
(interactive)
(cond ((null buffer-file-name)
@@ -253,11 +253,12 @@ Use the \\[next-error] command to move to the next error
(setq makeinfo-output-node-name (makeinfo-current-node))
(save-excursion
- (makeinfo-compile
- (concat makeinfo-run-command " " makeinfo-options
- " " buffer-file-name)
- nil
- 'makeinfo-compilation-sentinel-buffer)))
+ (let ((default-directory (file-name-directory buffer-file-name)))
+ (makeinfo-compile
+ (concat makeinfo-run-command " " makeinfo-options
+ " " (file-name-nondirectory buffer-file-name))
+ nil
+ 'makeinfo-compilation-sentinel-buffer))))
(defun makeinfo-compilation-sentinel-buffer (proc msg)
"Sentinel for `makeinfo-compile' run from `makeinfo-buffer'."
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el
index 1ca5e8b1a63..bf88551e6bf 100644
--- a/lisp/textmodes/nroff-mode.el
+++ b/lisp/textmodes/nroff-mode.el
@@ -1,9 +1,9 @@
;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source
-;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2013 Free Software
+;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2015 Free Software
;; Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el
index 2c3271911fb..99962c75897 100644
--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -1,6 +1,6 @@
;;; page-ext.el --- extended page handling commands
-;; Copyright (C) 1990-1991, 1993-1994, 2001-2013 Free Software
+;; Copyright (C) 1990-1991, 1993-1994, 2001-2015 Free Software
;; Foundation, Inc.
;; Author: Robert J. Chassell <bob@gnu.org>
@@ -345,14 +345,13 @@ If point is in the pages directory buffer, insert the new page in the
buffer associated with the directory.
Insert the new page just before current page if
- pages-directory-for-adding-new-page-before-current-page-p variable
-is non-nil. Else insert at exact location of point.
+`pages-directory-for-adding-new-page-before-current-page-p' is non-nil.
+Else insert at exact location of point.
-Narrow to new page if
- pages-directory-for-adding-page-narrowing-p variable
-is non-nil.
+Narrow to new page if `pages-directory-for-adding-page-narrowing-p' is
+non-nil.
-Page begins with a `^L' as the default page-delimiter.
+Page begins with a '^L' as the default `page-delimiter'.
Use \\[set-page-delimiter] to change the page-delimiter.
Point is left in the body of page."
(interactive "sHeader line: ")
@@ -396,8 +395,8 @@ Point is left in the body of page."
"Search for REGEXP, starting from point, and narrow to page it is in."
(interactive (list
(read-string
- (format "Search for `%s' (end with RET): "
- (or pages-last-search "regexp")))))
+ (format-message "Search for `%s' (end with RET): "
+ (or pages-last-search "regexp")))))
(if (equal regexp "")
(setq regexp pages-last-search)
(setq pages-last-search regexp))
@@ -447,7 +446,7 @@ REVERSE (non-nil means reverse order), BEG and END (region to sort)."
(defun sort-pages-buffer (&optional reverse)
"Sort pages alphabetically in buffer. Prefix arg means reverse order.
-\(Non-nil arg if not interactive.\)"
+\(Non-nil arg if not interactive.)"
(interactive "P")
(or reverse (setq reverse nil))
@@ -462,7 +461,7 @@ REVERSE (non-nil means reverse order), BEG and END (region to sort)."
(defvar pages-directory-previous-regexp nil
"Value of previous regexp used by `pages-directory'.
\(This regular expression may be used to select only those pages that
-contain matches to the regexp.\)")
+contain matches to the regexp.)")
(defvar pages-buffer nil
"The buffer for which the pages-directory function creates the directory.")
@@ -516,7 +515,7 @@ resets the page-delimiter to the original value."
(defun pages-directory
(pages-list-all-headers-p count-lines-p &optional regexp)
"Display a directory of the page headers in a temporary buffer.
-A header is the first non-blank line after the page-delimiter.
+A header is the first non-blank line after the `page-delimiter'.
\\[pages-directory-mode]
You may move point to one of the lines in the temporary buffer,
then use \\<pages-directory-goto> to go to the same line in the pages buffer.
@@ -550,16 +549,18 @@ directory for only the accessible portion of the buffer."
(list nil
nil
(read-string
- (format "Select according to `%s' (end with RET): "
- (or pages-directory-previous-regexp "regexp")))))
+ (format-message
+ "Select according to `%s' (end with RET): "
+ (or pages-directory-previous-regexp "regexp")))))
((> (prefix-numeric-value current-prefix-arg) 0)
(list t t nil))
((< (prefix-numeric-value current-prefix-arg) 0)
(list nil
t
(read-string
- (format "Select according to `%s' (end with RET): "
- (or pages-directory-previous-regexp "regexp")))))))
+ (format-message
+ "Select according to `%s' (end with RET): "
+ (or pages-directory-previous-regexp "regexp")))))))
(if (equal regexp "")
(setq regexp pages-directory-previous-regexp)
@@ -752,10 +753,10 @@ Move point to one of the lines in the displayed directory,
then use \\[pages-directory-goto] to go to the same line
in the addresses buffer.
-If pages-directory-for-addresses-goto-narrowing-p is non-nil,
+If `pages-directory-for-addresses-goto-narrowing-p' is non-nil,
`pages-directory-goto' narrows addresses buffer to entry.
-If pages-directory-for-addresses-buffer-keep-windows-p is nil,
+If `pages-directory-for-addresses-buffer-keep-windows-p' is nil,
this command deletes other windows when it displays the addresses
directory."
diff --git a/lisp/textmodes/page.el b/lisp/textmodes/page.el
index 60e49063c43..39db5bbcfad 100644
--- a/lisp/textmodes/page.el
+++ b/lisp/textmodes/page.el
@@ -1,8 +1,8 @@
;;; page.el --- page motion commands for Emacs
-;; Copyright (C) 1985, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2015 Free Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp convenience
;; Package: emacs
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index e773b53a73f..58c65678802 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -1,9 +1,9 @@
;;; paragraphs.el --- paragraph and sentence parsing
-;; Copyright (C) 1985-1987, 1991, 1994-1997, 1999-2013 Free Software
+;; Copyright (C) 1985-1987, 1991, 1994-1997, 1999-2015 Free Software
;; Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; Package: emacs
@@ -168,11 +168,11 @@ to obtain the value of this variable."
:type '(choice regexp (const :tag "Use default value" nil)))
(put 'sentence-end 'safe-local-variable 'string-or-null-p)
-(defcustom sentence-end-base "[.?!][]\"'”)}]*"
+(defcustom sentence-end-base "[.?!…‽][]\"'”’)}]*"
"Regexp matching the basic end of a sentence, not including following space."
:group 'paragraphs
:type 'string
- :version "22.1")
+ :version "25.1")
(put 'sentence-end-base 'safe-local-variable 'stringp)
(defun sentence-end ()
@@ -468,7 +468,7 @@ sentences. Also, every paragraph boundary terminates sentences as well."
(setq par-text-beg (point))
;; Start of the first line of the paragraph.
;; We use this as the search limit
- ;; to allow s1entence-end to match if it is anchored at
+ ;; to allow sentence-end to match if it is anchored at
;; BOL and the paragraph starts indented.
(beginning-of-line)
(setq par-beg (point)))
@@ -536,8 +536,4 @@ the current sentence with the one containing the mark."
(interactive "*p")
(transpose-subr 'forward-sentence arg))
-;; Local Variables:
-;; coding: utf-8
-;; End:
-
;;; paragraphs.el ends here
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index 21c86dd38f3..201b85b2528 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -1,9 +1,9 @@
;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model
-;; Copyright (C) 1985, 1994, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001-2015 Free Software Foundation, Inc.
;; Author: K. Shane Hartman
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: convenience wp
;; This file is part of GNU Emacs.
@@ -418,7 +418,8 @@ stops computed are displayed in the minibuffer with `:' at each stop."
(save-excursion
(let (tabs)
(if arg
- (setq tabs (default-value 'tab-stop-list))
+ (setq tabs (or (default-value 'tab-stop-list)
+ (indent-accumulate-tab-stops (window-width))))
(let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")))
(beginning-of-line)
(let ((bol (point)))
@@ -494,8 +495,12 @@ prefix argument, the rectangle is actually killed, shifting remaining text."
(defun picture-clear-rectangle-to-register (start end register &optional killp)
"Clear rectangle delineated by point and mark into REGISTER.
The rectangle is saved in REGISTER and replaced with whitespace. With
-prefix argument, the rectangle is actually killed, shifting remaining text."
- (interactive "r\ncRectangle to register: \nP")
+prefix argument, the rectangle is actually killed, shifting remaining text.
+
+Interactively, reads the register using `register-read-with-preview'."
+ (interactive (list (region-beginning) (region-end)
+ (register-read-with-preview "Rectangle to register: ")
+ current-prefix-arg))
(set-register register (picture-snarf-rectangle start end killp)))
(defun picture-snarf-rectangle (start end &optional killp)
@@ -534,8 +539,11 @@ regardless of where you click."
The rectangle is positioned with upper left corner at point, overwriting
existing text. With prefix argument, the rectangle is
inserted instead, shifting existing text. Leaves mark at one corner
-of rectangle and point at the other (diagonally opposed) corner."
- (interactive "cRectangle from register: \nP")
+of rectangle and point at the other (diagonally opposed) corner.
+
+Interactively, reads the register using `register-read-with-preview'."
+ (interactive (list (register-read-with-preview "Rectangle from register: ")
+ current-prefix-arg))
(let ((rectangle (get-register register)))
(if (not (consp rectangle))
(error "Register %c does not contain a rectangle" register)
diff --git a/lisp/textmodes/po.el b/lisp/textmodes/po.el
index 610227af794..a5f39461498 100644
--- a/lisp/textmodes/po.el
+++ b/lisp/textmodes/po.el
@@ -1,6 +1,6 @@
-;;; po.el --- basic support of PO translation files -*- coding: utf-8; -*-
+;;; po.el --- basic support of PO translation files
-;; Copyright (C) 1995-1998, 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1998, 2000-2015 Free Software Foundation, Inc.
;; Authors: François Pinard <pinard@iro.umontreal.ca>,
;; Greg McGary <gkm@magilla.cichlid.com>,
diff --git a/lisp/textmodes/refbib.el b/lisp/textmodes/refbib.el
index 975c9396d49..424b6d0f6a1 100644
--- a/lisp/textmodes/refbib.el
+++ b/lisp/textmodes/refbib.el
@@ -1,9 +1,9 @@
;;; refbib.el --- convert refer-style references to ones usable by Latex bib
-;; Copyright (C) 1989, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2015 Free Software Foundation, Inc.
;; Author: Henry Kautz <kautz@research.att.com>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: bib, tex
;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el
index 1e4d453e905..22dc7dc9165 100644
--- a/lisp/textmodes/refer.el
+++ b/lisp/textmodes/refer.el
@@ -1,6 +1,6 @@
;;; refer.el --- look up references in bibliography files
-;; Copyright (C) 1992, 1996, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1996, 2001-2015 Free Software Foundation, Inc.
;; Author: Ashwin Ram <ashwin@cc.gatech.edu>
;; Maintainer: Gernot Heiser <gernot@acm.org>
@@ -229,7 +229,7 @@ found on the last `refer-find-entry' or `refer-find-next-entry'."
(sit-for 1)
(setq files (cdr files))))))
(ding)
- (message "Keywords \"%s\" not found in any \.bib file" keywords))
+ (message "Keywords \"%s\" not found in any .bib file" keywords))
(select-window old-window)))
(defun refer-find-entry-in-file (keywords-list file &optional old-pos)
@@ -351,21 +351,21 @@ found on the last `refer-find-entry' or `refer-find-next-entry'."
(if (progn
(goto-char (point-min))
(re-search-forward (concat refer-bib-files-regexp
- "\\s-*\{") nil t))
+ "\\s-*{") nil t))
(let ((files (list (buffer-substring
(point)
(progn
- (re-search-forward "[,\}]"
+ (re-search-forward "[,}]"
nil t)
(backward-char 1)
(point))))))
- (while (not (looking-at "\}"))
+ (while (not (looking-at "}"))
(setq files (append files
(list (buffer-substring
(progn (forward-char 1)
(point))
(progn (re-search-forward
- "[,\}]" nil t)
+ "[,}]" nil t)
(backward-char 1)
(point)))))))
files)
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
index ebbc6ee0afb..97db70d2de3 100644
--- a/lisp/textmodes/refill.el
+++ b/lisp/textmodes/refill.el
@@ -1,6 +1,6 @@
;;; refill.el --- `auto-fill' by refilling paragraphs on changes
-;; Copyright (C) 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
;; Author: Dave Love <fx@gnu.org>
;; Maintainer: Miles Bader <miles@gnu.org>
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index 315b9d7fc30..bbad065c4ba 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -1,6 +1,6 @@
;;; reftex-auc.el --- RefTeX's interface to AUCTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -47,6 +47,7 @@
(and (listp reftex-plug-into-AUCTeX)
(nth which reftex-plug-into-AUCTeX))))
+;;;###autoload
(defun reftex-arg-label (optional &optional prompt definition)
"Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
What is being used depends upon `reftex-plug-into-AUCTeX'."
@@ -68,6 +69,7 @@ What is being used depends upon `reftex-plug-into-AUCTeX'."
(LaTeX-add-labels label))
(TeX-argument-insert label optional)))
+;;;###autoload
(defun reftex-arg-cite (optional &optional prompt definition)
"Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
What is being used depends upon `reftex-plug-into-AUCTeX'."
@@ -85,6 +87,7 @@ What is being used depends upon `reftex-plug-into-AUCTeX'."
optional)))
+;;;###autoload
(defun reftex-arg-index-tag (optional &optional prompt &rest args)
"Prompt for an index tag with completion.
This is the name of an index, not the entry."
@@ -104,6 +107,7 @@ This is the name of an index, not the entry."
(setq tag (read-string prompt)))
(TeX-argument-insert tag optional)))
+;;;###autoload
(defun reftex-arg-index (optional &optional prompt &rest args)
"Prompt for an index entry completing with known entries.
Completion is specific for just one index, if the macro or a tag
@@ -138,6 +142,7 @@ argument identify one of multiple indices."
(t "idx")))))
(defvar LaTeX-label-function)
+;;;###autoload
(defun reftex-plug-into-AUCTeX ()
;; Replace AUCTeX functions with RefTeX functions.
;; Which functions are replaced is controlled by the variable
@@ -162,6 +167,7 @@ argument identify one of multiple indices."
(fboundp 'TeX-arg-index)
(fset 'TeX-arg-index 'reftex-arg-index)))
+;;;###autoload
(defun reftex-toggle-plug-into-AUCTeX ()
"Toggle Interface between AUCTeX and RefTeX on and off."
(interactive)
@@ -173,6 +179,7 @@ argument identify one of multiple indices."
(message "RefTeX has been plugged into AUCTeX.")
(message "RefTeX no longer interacts with AUCTeX.")))
+;;;###autoload
(defun reftex-add-label-environments (entry-list)
"Add label environment descriptions to `reftex-label-alist-style'.
The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there
@@ -197,8 +204,10 @@ the label information is recompiled on next use."
(push entry list)))
(when changed
(put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
+;;;###autoload
(defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
+;;;###autoload
(defun reftex-add-section-levels (entry-list)
"Add entries to the value of `reftex-section-levels'.
The added values are kept local to the current document. The format
@@ -219,9 +228,14 @@ of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See
(when changed
(put reftex-docstruct-symbol 'reftex-section-levels list)))))
+;;;###autoload
(defun reftex-notice-new-section ()
(reftex-notice-new 1 'force))
(provide 'reftex-auc)
;;; reftex-auc.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index 6c103294a06..a35d41109e6 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1,6 +1,6 @@
;;; reftex-cite.el --- creating citations with RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -58,6 +58,7 @@
,@body)
(set-syntax-table saved-syntax))))
+;;;###autoload
(defun reftex-default-bibliography ()
"Return the expanded value of variable `reftex-default-bibliography'.
The expanded value is cached."
@@ -70,6 +71,7 @@ The expanded value is cached."
reftex-default-bibliography))
(get 'reftex-default-bibliography :reftex-expanded))
+;;;###autoload
(defun reftex-bib-or-thebib ()
"Test if BibTeX or \begin{thebibliography} should be used for the citation.
Find the bof of the current file"
@@ -89,6 +91,7 @@ Find the bof of the current file"
(if bib 'bib nil)
(if thebib 'thebib nil))))
+;;;###autoload
(defun reftex-get-bibfile-list ()
"Return list of bibfiles for current document.
When using the chapterbib or bibunits package you should either
@@ -112,6 +115,7 @@ Then this function will return the applicable database files."
(error "\\bibliography statement missing or .bib files not found")))
;;; Find a certain reference in any of the BibTeX files.
+;;;###autoload
(defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill
highlight item return)
"Find BibTeX KEY in any file in FILE-LIST in another window.
@@ -161,6 +165,7 @@ If RETURN is non-nil, just return the entry and restore point."
(error "No \\bibitem with citation key %s" key)
(error "No BibTeX entry with citation key %s" key)))))
+;;;###autoload
(defun reftex-end-of-bib-entry (item)
(save-excursion
(condition-case nil
@@ -172,6 +177,28 @@ If RETURN is non-nil, just return the entry and restore point."
(progn (forward-list 1) (point)))
(error (min (point-max) (+ 300 (point)))))))
+(defun reftex--query-search-regexps (default)
+ "Query for regexps for searching entries using DEFAULT as default.
+Return a list of regular expressions."
+ (split-string
+ (completing-read
+ (concat
+ "Regex { && Regex...}: "
+ "[" default "]: ")
+ ;; Ensure default is always in the completion list.
+ (let ((def (when default (list default)))
+ (coll (if reftex-mode
+ (if (fboundp 'LaTeX-bibitem-list)
+ (LaTeX-bibitem-list)
+ (cdr (assoc 'bibview-cache
+ (symbol-value reftex-docstruct-symbol))))
+ nil)))
+ (if (and def (member def coll))
+ coll
+ (cons def coll)))
+ nil nil nil 'reftex-cite-regexp-hist)
+ "[ \t]*&&[ \t]*"))
+
;;; Parse bibtex buffers
(defun reftex-extract-bib-entries (buffers)
"Extract bib entries which match regexps from BUFFERS.
@@ -184,20 +211,7 @@ Return list with entries."
;; Read a regexp, completing on known citation keys.
(setq default (regexp-quote (reftex-get-bibkey-default)))
- (setq re-list
- (split-string
- (completing-read
- (concat
- "Regex { && Regex...}: "
- "[" default "]: ")
- (if reftex-mode
- (if (fboundp 'LaTeX-bibitem-list)
- (LaTeX-bibitem-list)
- (cdr (assoc 'bibview-cache
- (symbol-value reftex-docstruct-symbol))))
- nil)
- nil nil nil 'reftex-cite-regexp-hist)
- "[ \t]*&&[ \t]*"))
+ (setq re-list (reftex--query-search-regexps default))
(if (or (null re-list ) (equal re-list '("")))
(setq re-list (list default)))
@@ -205,7 +219,9 @@ Return list with entries."
(setq first-re (car re-list) ; We'll use the first re to find things,
rest-re (cdr re-list)) ; the others to narrow down.
(if (string-match "\\`[ \t]*\\'" (or first-re ""))
- (error "Empty regular expression"))
+ (user-error "Empty regular expression"))
+ (if (string-match first-re "")
+ (user-error "Regular expression matches the empty string."))
(save-excursion
(save-window-excursion
@@ -223,11 +239,11 @@ Return list with entries."
(message "No such BibTeX file %s (ignored)" buffer)
(message "Scanning bibliography database %s" buffer1)
(unless (verify-visited-file-modtime buffer1)
- (when (y-or-n-p
- (format "File %s changed on disk. Reread from disk? "
- (file-name-nondirectory
- (buffer-file-name buffer1))))
- (with-current-buffer buffer1 (revert-buffer t t)))))
+ (when (y-or-n-p
+ (format "File %s changed on disk. Reread from disk? "
+ (file-name-nondirectory
+ (buffer-file-name buffer1))))
+ (with-current-buffer buffer1 (revert-buffer t t)))))
(set-buffer buffer1)
(reftex-with-special-syntax-for-bib
@@ -380,27 +396,14 @@ The environment should be located in FILES."
(buffer-substring-no-properties
start end)
"[ \t\n\r]*\\\\bibitem[ \t]*\
-\\(\\[[^]]*]\\)*\[ \t]*"))))))
+\\(\\[[^]]*]\\)*[ \t]*"))))))
(goto-char end))))))
(unless entries
(error "No bibitems found"))
;; Read a regexp, completing on known citation keys.
(setq default (regexp-quote (reftex-get-bibkey-default)))
- (setq re-list
- (split-string
- (completing-read
- (concat
- "Regex { && Regex...}: "
- "[" default "]: ")
- (if reftex-mode
- (if (fboundp 'LaTeX-bibitem-list)
- (LaTeX-bibitem-list)
- (cdr (assoc 'bibview-cache
- (symbol-value reftex-docstruct-symbol))))
- nil)
- nil nil nil 'reftex-cite-regexp-hist)
- "[ \t]*&&[ \t]*"))
+ (setq re-list (reftex--query-search-regexps default))
(if (or (null re-list ) (equal re-list '("")))
(setq re-list (list default)))
@@ -452,6 +455,7 @@ If FIELD is empty try \"editor\" field."
(setq names (replace-match " " nil t names)))
(split-string names "\n")))
+;;;###autoload
(defun reftex-parse-bibtex-entry (entry &optional from to raw)
"Parse BibTeX ENTRY.
If ENTRY is nil then parse the entry in current buffer between FROM and TO.
@@ -471,7 +475,7 @@ If RAW is non-nil, keep double quotes/curly braces delimiting fields."
(goto-char (point-min))
(if (re-search-forward "@\\(\\(?:\\w\\|\\s_\\)+\\)[ \t\n\r]*\
-\[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
+[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
(setq alist
(list
(cons "&type" (downcase (reftex-match-string 1)))
@@ -537,7 +541,14 @@ If FORMAT is non-nil `format' entry accordingly."
(extra
(cond
((equal type "article")
- (concat (reftex-get-bib-field "journal" entry) " "
+ (concat (let ((jt (reftex-get-bib-field "journal" entry)))
+ ;; biblatex prefers the alternative journaltitle
+ ;; field, so check if that exists in case journal
+ ;; is empty.
+ (if (zerop (length jt))
+ (reftex-get-bib-field "journaltitle" entry)
+ jt))
+ " "
(reftex-get-bib-field "volume" entry) ", "
(reftex-get-bib-field "pages" entry)))
((equal type "book")
@@ -604,6 +615,7 @@ If FORMAT is non-nil `format' entry accordingly."
;;; Make a citation
+;; NB this is a global autoload - see reftex.el.
;;;###autoload
(defun reftex-citation (&optional no-insert format-key)
"Make a citation using BibTeX database files.
@@ -787,11 +799,13 @@ in order to only add another reference in the same cite command."
(error "No citation format associated with key `%c'" key)))))
format))
+;;;###autoload
(defun reftex-citep ()
"Call `reftex-citation' with a format selector `?p'."
(interactive)
(reftex-citation nil ?p))
+;;;###autoload
(defun reftex-citet ()
"Call `reftex-citation' with a format selector `?t'."
(interactive)
@@ -1058,6 +1072,7 @@ in order to only add another reference in the same cite command."
(setq format (replace-match "" t t format)))
format)
+;;;###autoload
(defun reftex-make-cite-echo-string (entry docstruct-symbol)
"Format a bibtex ENTRY for the echo area and cache the result."
(let* ((key (reftex-get-bib-field "&key" entry))
@@ -1130,7 +1145,7 @@ recommended for follow mode. It works OK for individual lookups."
(save-restriction
(widen)
(goto-char (point-min))
- (while (re-search-forward "\\(?:^\\|\\=\\)[^%\n\r]*?\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t)
+ (while (re-search-forward "\\(?:^\\|\\=\\)[^%\n\r]*?\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^]]*\\]\\)?{\\([^}]+\\)}" nil t)
(setq kk (match-string-no-properties 3))
(while (string-match "%.*\n?" kk)
(setq kk (replace-match "" t t kk)))
@@ -1151,6 +1166,7 @@ recommended for follow mode. It works OK for individual lookups."
(string-match "^&" (car pair)))
alist))))
+;;;###autoload
(defun reftex-create-bibtex-file (bibfile)
"Create a new BibTeX database BIBFILE with all entries referenced in document.
The command prompts for a filename and writes the collected
@@ -1177,7 +1193,7 @@ created files in the variables `reftex-create-bibtex-header' or
(widen)
(goto-char (point-min))
(while (re-search-forward "^[ \t]*@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*\
-\[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
+[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
(setq key (match-string 1)
beg (match-beginning 0)
end (progn
@@ -1244,3 +1260,7 @@ created files in the variables `reftex-create-bibtex-header' or
(provide 'reftex-cite)
;;; reftex-cite.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index 12781f358eb..60cb1f65257 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -1,6 +1,6 @@
;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -30,6 +30,7 @@
(require 'reftex)
+;;;###autoload
(defun reftex-view-crossref (&optional arg auto-how fail-quietly)
"View cross reference of macro at point. Point must be on the KEY
argument. When at a `\\ref' macro, show corresponding `\\label'
@@ -220,6 +221,7 @@ to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'."
(when (equal arg 2)
(select-window pop-win)))))
+;;;###autoload
(defun reftex-mouse-view-crossref (ev)
"View cross reference of \\ref or \\cite macro where you click.
If the macro at point is a \\ref, show the corresponding label definition.
@@ -318,6 +320,7 @@ With argument, actually select the window showing the cross reference."
"Non-nil means use the idle timers in XEmacs for crossref display.
Currently, idle timer restart is broken and we use the post-command-hook.")
+;;;###autoload
(defun reftex-toggle-auto-view-crossref ()
"Toggle the automatic display of crossref information in the echo area.
When active, leaving point idle in the argument of a \\ref or \\cite macro
@@ -355,6 +358,7 @@ will display info in the echo area."
'reftex-view-crossref-when-idle
reftex-idle-time nil t))))
+;;;###autoload
(defun reftex-view-crossref-from-bibtex (&optional arg)
"View location in a LaTeX document which cites the BibTeX entry at point.
Since BibTeX files can be used by many LaTeX documents, this function
@@ -482,3 +486,7 @@ Calling this function several times find successive citation locations."
(provide 'reftex-dcr)
;;; reftex-dcr.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index 83a98891216..15d42fe7b02 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -1,6 +1,6 @@
;;; reftex-global.el --- operations on entire documents with RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -29,6 +29,7 @@
(require 'reftex)
;;;
+;;;###autoload
(defun reftex-create-tags-file ()
"Create TAGS file by running `etags' on the current document.
The TAGS file is also immediately visited with `visit-tags-table'."
@@ -48,6 +49,7 @@ The TAGS file is also immediately visited with `visit-tags-table'."
(defvar reftex-grep-command "grep -n "
"Last grep command used in \\[reftex-grep-document]; default for next grep.")
+;;;###autoload
(defun reftex-grep-document (grep-cmd)
"Run grep query through all files related to this document.
With prefix arg, force to rescan document.
@@ -64,6 +66,7 @@ No active TAGS table is required."
(mapconcat 'identity files " "))))
(grep cmd)))
+;;;###autoload
(defun reftex-search-document (&optional regexp)
"Regexp search through all files of the current document.
Starts always in the master file. Stops when a match is found.
@@ -79,6 +82,7 @@ No active TAGS table is required."
(reftex-access-scan-info current-prefix-arg)
(tags-search regexp (list 'reftex-all-document-files))))
+;;;###autoload
(defun reftex-query-replace-document (&optional from to delimited)
"Do `query-replace-regexp' of FROM with TO over the entire document.
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
@@ -100,6 +104,7 @@ No active TAGS table is required."
(defvar TeX-master)
(defvar isearch-next-buffer-function)
+;;;###autoload
(defun reftex-find-duplicate-labels ()
"Produce a list of all duplicate labels in the document."
@@ -158,6 +163,7 @@ No active TAGS table is required."
(delete-window)
(message "Document does not contain duplicate labels."))))
+;;;###autoload
(defun reftex-change-label (&optional from to)
"Run `query-replace-regexp' of FROM with TO in all macro arguments.
Works on the entire multifile document.
@@ -177,6 +183,7 @@ No active TAGS table is required."
(concat "{" (regexp-quote from) "}")
(format "{%s}" to))))
+;;;###autoload
(defun reftex-renumber-simple-labels ()
"Renumber all simple labels in the document to make them sequentially.
Simple labels are the ones created by RefTeX, consisting only of the
@@ -304,6 +311,7 @@ one with the `xr' package."
(t nil))))))))
n))
+;;;###autoload
(defun reftex-save-all-document-buffers ()
"Save all documents associated with the current document.
The function is useful after a global action like replacing or renumbering
@@ -414,6 +422,7 @@ Also checks if buffers visiting the files are in read-only mode."
(when flist
(find-file-noselect (car flist))))))
+;; NB this is a global autoload - see reftex.el.
;;;###autoload
(defun reftex-isearch-minor-mode (&optional arg)
"When on, isearch searches the whole document, not only the current file.
@@ -466,3 +475,7 @@ With no argument, this command toggles
'reftex-isearch-minor-mode)
;;; reftex-global.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index a8e712f4f49..7e961e83406 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1,6 +1,6 @@
;;; reftex-index.el --- index support with RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -35,6 +35,7 @@
(defvar TeX-master)
;; END remove for XEmacs release
+;;;###autoload
(defun reftex-index-selection-or-word (&optional arg phrase)
"Put selection or the word near point into the default index macro.
This uses the information in `reftex-index-default-macro' to make an index
@@ -87,6 +88,7 @@ which is part of AUCTeX, the string is first processed with the
(delete-region beg end)
(reftex-index def-char full-entry def-tag sel)))))
+;;;###autoload
(defun reftex-index (&optional char key tag sel no-insert)
"Query for an index macro and insert it along with its arguments.
The index macros available are those defined in `reftex-index-macro' or
@@ -156,6 +158,7 @@ will prompt for other arguments."
(member tag tag-list)))
(put reftex-docstruct-symbol 'default-index-tag tag)))
+;;;###autoload
(defun reftex-index-complete-tag (&optional itag opt-args)
;; Ask the user for a tag, completing on known tags.
;; ITAG is the argument number which contains the tag.
@@ -180,6 +183,7 @@ will prompt for other arguments."
(reftex-update-default-index tag)
tag))
+;;;###autoload
(defun reftex-index-select-tag ()
;; Have the user select an index tag.
;; FIXME: should we cache tag-alist, prompt and help?
@@ -249,6 +253,7 @@ will prompt for other arguments."
(error "No index tag associated with %c" rpl)))))
(t (error "This should not happen (reftex-index-select-tag)")))))
+;;;###autoload
(defun reftex-index-complete-key (&optional tag optional initial)
;; Read an index key, with completion.
;; Restrict completion table on index tag TAG.
@@ -434,6 +439,7 @@ _ ^ Add/Remove parent key (to make this item a subitem).
} / { Restrict Index to a single document section / Widen.
< / > When restricted, move restriction to previous/next section.")
+;;;###autoload
(defun reftex-index-show-entry (data &optional no-revisit)
;; Find an index entry associated with DATA and display it highlighted
;; in another window. NO-REVISIT means we are not allowed to visit
@@ -462,6 +468,7 @@ _ ^ Add/Remove parent key (to make this item a subitem).
(reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
match))
+;;;###autoload
(defun reftex-display-index (&optional tag overriding-restriction redo
&rest locations)
"Display a buffer with an index compiled from the current document.
@@ -537,18 +544,28 @@ With prefix 3, restrict index to region."
(setq buffer-read-only nil)
(insert (format
-"INDEX <%s> on %s
+ "INDEX <%s> on %s
Restriction: <%s>
SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
------------------------------------------------------------------------------
-" index-tag (abbreviate-file-name master)
-(if (eq (car (car reftex-index-restriction-data)) 'toc)
- (nth 2 (car reftex-index-restriction-data))
- reftex-index-restriction-indicator)))
+"
+ index-tag (abbreviate-file-name master)
+ (if (eq (car (car reftex-index-restriction-data)) 'toc)
+ (nth 2 (car reftex-index-restriction-data))
+ reftex-index-restriction-indicator)))
(if (reftex-use-fonts)
- (put-text-property 1 (point) 'face reftex-index-header-face))
- (put-text-property 1 (point) 'intangible t)
+ (put-text-property (point-min) (point)
+ 'face reftex-index-header-face))
+ (if (fboundp 'cursor-intangible-mode)
+ (cursor-intangible-mode 1)
+ ;; If `cursor-intangible' is not available, fallback on the old
+ ;; intrusive `intangible' property.
+ (put-text-property (point-min) (point) 'intangible t))
+ (add-text-properties (point-min) (point)
+ '(cursor-intangible t
+ front-sticky (cursor-intangible)
+ rear-nonsticky (cursor-intangible)))
(reftex-insert-index docstruct index-tag)
(goto-char (point-min))
@@ -690,9 +707,10 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
(defun reftex-index-post-command-hook ()
;; Used in the post-command-hook for the *Index* buffer
+ ;; FIXME: Lots of redundancy with reftex-toc-post-command-hook!
(when (get-text-property (point) :data)
- (and (> (point) 1)
- (not (get-text-property (point) 'intangible))
+ (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing?
+ (not (get-text-property (point) 'cursor-intangible))
(memq reftex-highlight-selection '(cursor both))
(reftex-highlight 1
(or (previous-single-property-change (1+ (point)) :data)
@@ -896,7 +914,7 @@ When index is restricted, select the previous section as restriction criterion."
;; If FINAL is t, stay there
;; If FINAL is 'hide, hide the *Index* window.
;; Otherwise, move cursor back into *Index* window.
- ;; NO-REVISIT means don't visit files, just use live biffers.
+ ;; NO-REVISIT means don't visit files, just use live buffers.
(let* ((data (get-text-property (point) :data))
(index-window (selected-window))
@@ -1244,6 +1262,7 @@ This gets refreshed in every phrases command.")
table)
"Syntax table for RefTeX Index Phrases mode.")
+;;;###autoload
(defun reftex-index-phrase-selection-or-word (arg)
"Add current selection or word at point to the phrases buffer.
When you are in transient-mark-mode and the region is active, the
@@ -1258,6 +1277,7 @@ You get a chance to edit the entry in the phrases buffer - finish with
(substitute-command-keys
"Return to LaTeX with \\[reftex-index-phrases-save-and-return]"))))
+;;;###autoload
(defun reftex-index-visit-phrases-buffer ()
"Switch to the phrases buffer, initialize if empty."
(interactive)
@@ -1345,6 +1365,7 @@ If the buffer is non-empty, delete the old header first."
(defvar reftex-index-phrases-menu)
(defvar reftex-index-phrases-marker)
(defvar reftex-index-phrases-restrict-file nil)
+;; NB this is a global autoload - see reftex.el.
;;;###autoload
(define-derived-mode reftex-index-phrases-mode fundamental-mode "Phrases"
"Major mode for managing the Index phrases of a LaTeX document.
@@ -2096,3 +2117,7 @@ Does not do a save-excursion."
(provide 'reftex-index)
;;; reftex-index.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index a99791e5427..f57113177c5 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -1,6 +1,6 @@
;;; reftex-parse.el --- parser functions for RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -37,17 +37,22 @@
,@body))
(set-syntax-table saved-syntax))))
+;;;###autoload
(defun reftex-parse-one ()
"Re-parse this file."
(interactive)
(let ((reftex-enable-partial-scans t))
(reftex-access-scan-info '(4))))
+;;;###autoload
(defun reftex-parse-all ()
"Re-parse entire document."
(interactive)
(reftex-access-scan-info '(16)))
+(defvar reftex--index-tags)
+
+;;;###autoload
(defun reftex-do-parse (rescan &optional file)
"Do a document rescan.
When allowed, do only a partial scan from FILE."
@@ -72,7 +77,7 @@ When allowed, do only a partial scan from FILE."
(file (or file (buffer-file-name)))
(true-file (file-truename file))
(bibview-cache (assq 'bibview-cache old-list))
- (index-tags (cdr (assq 'index-tags old-list)))
+ (reftex--index-tags (cdr (assq 'index-tags old-list)))
from-file appendix docstruct tmp)
;; Make sure replacement is really an option here
@@ -92,7 +97,7 @@ When allowed, do only a partial scan from FILE."
(t (error "This should not happen (reftex-do-parse)"))))
;; Reset index-tags if we scan everything
- (if (equal rescan 1) (setq index-tags nil))
+ (if (equal rescan 1) (setq reftex--index-tags nil))
;; Find active toc entry and initialize section-numbers
(setq reftex-active-toc (reftex-last-assoc-before-elt
@@ -137,11 +142,12 @@ When allowed, do only a partial scan from FILE."
(entry (or (assq 'is-multi docstruct)
(car (push (list 'is-multi is-multi) docstruct)))))
(setcdr entry (cons is-multi nil)))
- (and index-tags (setq index-tags (sort index-tags 'string<)))
+ (and reftex--index-tags
+ (setq reftex--index-tags (sort reftex--index-tags 'string<)))
(let ((index-tag-cell (assq 'index-tags docstruct)))
(if index-tag-cell
- (setcdr index-tag-cell index-tags)
- (push (cons 'index-tags index-tags) docstruct)))
+ (setcdr index-tag-cell reftex--index-tags)
+ (push (cons 'index-tags reftex--index-tags) docstruct)))
(unless (assq 'xr docstruct)
(let* ((allxr (reftex-all-assq 'xr-doc docstruct))
(alist (mapcar
@@ -165,11 +171,13 @@ When allowed, do only a partial scan from FILE."
(set reftex-docstruct-symbol docstruct)
(put reftex-docstruct-symbol 'modified t)))
+;;;###autoload
(defun reftex-everything-regexp ()
(if reftex-support-index
reftex-everything-regexp
reftex-everything-regexp-no-index))
+;; NB this is a global autoload - see reftex.el.
;;;###autoload
(defun reftex-all-document-files (&optional relative)
"Return a list of all files belonging to the current document.
@@ -189,8 +197,6 @@ of master file."
(nreverse file-list)))
;; Bound in the caller, reftex-do-parse.
-(defvar index-tags)
-
(defun reftex-parse-from-file (file docstruct master-dir)
"Scan the buffer for labels and save them in a list."
(let ((regexp (reftex-everything-regexp))
@@ -238,7 +244,7 @@ of master file."
(when (or (null reftex-label-ignored-macros-and-environments)
;; \label{} defs should always be honored,
;; just no keyval style [label=foo] defs.
- (string-equal "\label{" (substring (reftex-match-string 0) 0 7))
+ (string-equal "\\label{" (substring (reftex-match-string 0) 0 7))
(if (and (fboundp 'TeX-current-macro)
(fboundp 'LaTeX-current-environment))
(not (or (member (save-match-data (TeX-current-macro))
@@ -300,7 +306,7 @@ of master file."
(when reftex-support-index
(setq index-entry (reftex-index-info file))
(when index-entry
- (add-to-list 'index-tags (nth 1 index-entry))
+ (add-to-list 'reftex--index-tags (nth 1 index-entry))
(push index-entry docstruct))))
((match-end 11)
@@ -350,20 +356,39 @@ of master file."
;; Return the list
docstruct))
+(defun reftex-using-biblatex-p ()
+ "Return non-nil if we are using biblatex rather than bibtex."
+ (if (boundp 'TeX-active-styles)
+ ;; the sophisticated AUCTeX way
+ (member "biblatex" TeX-active-styles)
+ ;; poor-man's check...
+ (save-excursion
+ (re-search-forward "^[^%\n]*?\\\\usepackage.*{biblatex}" nil t))))
+
+;;;###autoload
(defun reftex-locate-bibliography-files (master-dir &optional files)
- "Scan buffer for bibliography macro and return file list."
+ "Scan buffer for bibliography macros and return file list."
(unless files
(save-excursion
(goto-char (point-min))
- (if (re-search-forward
- (concat
-; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
- "\\(^\\)[^%\n\r]*\\\\\\("
- (mapconcat 'identity reftex-bibliography-commands "\\|")
- "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t)
- (setq files
- (split-string (reftex-match-string 4)
- "[ \t\n\r]*,[ \t\n\r]*")))))
+ ;; when biblatex is used, multiple \bibliography or
+ ;; \addbibresource macros are allowed. With plain bibtex, only
+ ;; the first is used.
+ (let ((using-biblatex (reftex-using-biblatex-p))
+ (again t))
+ (while (and again
+ (re-search-forward
+ (concat
+ ;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+ "\\(^\\)[^%\n\r]*\\\\\\("
+ (mapconcat 'identity reftex-bibliography-commands "\\|")
+ "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t))
+ (setq files
+ (append files
+ (split-string (reftex-match-string 4)
+ "[ \t\n\r]*,[ \t\n\r]*")))
+ (unless using-biblatex
+ (setq again nil))))))
(when files
(setq files
(mapcar
@@ -403,6 +428,7 @@ This function also makes sure the old toc markers do not point anywhere."
(setcdr (nthcdr (1- (length new)) new) (cdr eof-list)))
new))))
+;;;###autoload
(defun reftex-section-info (file)
"Return a section entry for the current match.
Careful: This function expects the match-data to be still in place!"
@@ -439,6 +465,7 @@ Careful: This function expects the match-data to be still in place!"
(list 'toc "toc" text file marker level section-number
literal (marker-position marker))))
+;;;###autoload
(defun reftex-ensure-index-support (&optional abort)
"When index support is turned off, ask to turn it on and
set the current prefix argument so that `reftex-access-scan-info'
@@ -454,11 +481,13 @@ will rescan the entire document."
(ding)
(sit-for 1)))))
+;;;###autoload
(defun reftex-index-info-safe (file)
(reftex-with-special-syntax
(reftex-index-info file)))
(defvar test-dummy)
+;;;###autoload
(defun reftex-index-info (file)
"Return an index entry for the current match.
Careful: This function expects the match-data to be still in place!"
@@ -507,6 +536,7 @@ Careful: This function expects the match-data to be still in place!"
;; 0 1 2 3 4 5 6 7 8 9
(list 'index index-tag context file bom arg key showkey sortkey key-end))))
+;;;###autoload
(defun reftex-short-context (env parse &optional bound derive)
"Get about one line of useful context for the label definition at point."
@@ -567,6 +597,7 @@ Careful: This function expects the match-data to be still in place!"
(t
"INVALID VALUE OF PARSE"))))
+;;;###autoload
(defun reftex-where-am-I ()
"Return the docstruct entry above point.
Actually returns a cons cell in which the cdr is a flag indicating
@@ -665,6 +696,7 @@ if the information is exact (t) or approximate (nil)."
cnt 2))
(cons rtn (eq cnt 1))))
+;;;###autoload
(defun reftex-notice-new (&optional n force)
"Hook to handshake with RefTeX after something new has been inserted."
;; Add a new entry to the docstruct list. If it is a section, renumber
@@ -741,7 +773,7 @@ if the information is exact (t) or approximate (nil)."
;; Index entry
(and reftex-support-index
(setq entry (reftex-index-info-safe buffer-file-name))
- ;; FIXME: (add-to-list 'index-tags (nth 1 index-entry))
+ ;; FIXME: (add-to-list 'reftex--index-tags (nth 1 index-entry))
(push entry (cdr tail))))))))))
(error nil))
@@ -763,11 +795,13 @@ in TeX."
t)
(t nil)))
+;;;###autoload
(defun reftex-what-macro-safe (which &optional bound)
"Call `reftex-what-macro' with special syntax table."
(reftex-with-special-syntax
(reftex-what-macro which bound)))
+;;;###autoload
(defun reftex-what-macro (which &optional bound)
"Find out if point is within the arguments of any TeX-macro.
The return value is either (\"\\macro\" . (point)) or a list of them.
@@ -830,6 +864,7 @@ considered an argument of macro \\macro."
(goto-char pos)))
(nreverse cmd-list)))))
+;;;###autoload
(defun reftex-what-environment (which &optional bound)
"Find out if point is inside a LaTeX environment.
The return value is (e.g.) either (\"equation\" . (point)) or a list of
@@ -867,6 +902,7 @@ this point. If it is nil, limit to nearest \\section - like statement."
(throw 'exit (cons env (point))))))
(nreverse env-list)))))
+;;;###autoload
(defun reftex-what-special-env (which &optional bound)
"Run the special environment parsers and return the matches.
@@ -907,7 +943,7 @@ If WHICH is a list of environments, look only for those environments and
specials
(car specials))))))
-(defsubst reftex-move-to-next-arg (&optional ignore)
+(defsubst reftex-move-to-next-arg (&optional _ignore)
"Assuming that we are at the end of a macro name or a macro argument,
move forward to the opening parenthesis of the next argument.
This function understands the splitting of macros over several lines
@@ -926,6 +962,7 @@ in TeX."
(let ((entry (assoc key reftex-env-or-mac-alist)))
(reftex-nth-arg (nth 5 entry) (nth 6 entry))))
+;;;###autoload
(defun reftex-nth-arg (n &optional opt-args)
"Return the Nth following {} or [] parentheses content.
OPT-ARGS is a list of argument numbers which are optional."
@@ -964,6 +1001,7 @@ OPT-ARGS is a list of argument numbers which are optional."
(reftex-context-substring)
nil))))
+;;;###autoload
(defun reftex-move-over-touching-args ()
(condition-case nil
(while (memq (following-char) '(?\[ ?\{))
@@ -1003,6 +1041,7 @@ When point is just after a { or [, limit string to matching parenthesis"
;; Variable holding the vector with section numbers
(defvar reftex-section-numbers (make-vector reftex-max-section-depth 0))
+;;;###autoload
(defun reftex-init-section-numbers (&optional toc-entry appendix)
"Initialize the section numbers with zeros or with what is found in the TOC-ENTRY."
(let* ((level (or (nth 5 toc-entry) -1))
@@ -1021,6 +1060,7 @@ When point is just after a { or [, limit string to matching parenthesis"
(decf i)))
(put 'reftex-section-numbers 'appendix appendix))
+;;;###autoload
(defun reftex-section-number (&optional level star)
"Return a string with the current section number.
When LEVEL is non-nil, increase section numbers on that level."
@@ -1089,3 +1129,7 @@ When LEVEL is non-nil, increase section numbers on that level."
(provide 'reftex-parse)
;;; reftex-parse.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 575d885a322..df78447defb 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -1,6 +1,6 @@
;;; reftex-ref.el --- code to create labels and references with RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -29,6 +29,7 @@
(require 'reftex)
(require 'reftex-parse)
+;;;###autoload
(defun reftex-label-location (&optional bound)
"Return the environment or macro which determines the label type at point.
If optional BOUND is an integer, limit backward searches to that point."
@@ -62,6 +63,7 @@ If optional BOUND is an integer, limit backward searches to that point."
(t ;; This should not happen, I think?
"section"))))
+;;;###autoload
(defun reftex-label-info-update (cell)
;; Update information about just one label in a different file.
;; CELL contains the old info list
@@ -92,6 +94,7 @@ If optional BOUND is an integer, limit backward searches to that point."
(append (reftex-label-info label file) (list note)))
(list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
+;;;###autoload
(defun reftex-label-info (label &optional file bound derive env-or-mac)
;; Return info list on LABEL at point.
(let* ((prefix (if (string-match "^[a-zA-Z0-9]+:" label)
@@ -118,6 +121,7 @@ If optional BOUND is an integer, limit backward searches to that point."
;;; Creating labels ---------------------------------------------------------
+;;;###autoload
(defun reftex-label (&optional environment no-insert)
"Insert a unique label. Return the label.
If ENVIRONMENT is given, don't bother to find out yourself.
@@ -224,7 +228,7 @@ This function is controlled by the settings of reftex-insert-label-flags."
(symbol-value reftex-docstruct-symbol)))
(ding)
(if (y-or-n-p
- (format "Label '%s' exists. Use anyway? " label))
+` (format-message "Label `%s' exists. Use anyway? " label))
(setq valid t)))
;; Label is ok
@@ -398,6 +402,7 @@ also applies `reftex-translate-to-ascii-function' to the string."
a / A Put all marked entries into one/many \\ref commands.
q / RET Quit without referencing / Accept current label (also on mouse-2).")
+;;;###autoload
(defun reftex-reference (&optional type no-insert cut)
"Make a LaTeX reference. Look only for labels of a certain TYPE.
With prefix arg, force to rescan buffer for labels. This should only be
@@ -705,6 +710,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
(file (nth 3 data)))
(reftex-access-scan-info arg file)))))
+;;;###autoload
(defun reftex-query-label-type ()
;; Ask for label type
(let ((key (reftex-select-with-char
@@ -713,6 +719,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
(error "No such label type: %s" (char-to-string key)))
(char-to-string key)))
+;;;###autoload
(defun reftex-show-label-location (data forward no-revisit
&optional stay error)
;; View the definition site of a label in another window.
@@ -833,10 +840,14 @@ package.\n\nThis is a generated function."
Replace any occurrences of \"\\ref\" with REFSTYLE."
;; Replace instances of \ref in `fmt' with the special reference
;; style selected by the user.
- (while (string-match "\\(\\\\ref\\)[ \t]*{" fmt)
- (setq fmt (replace-match refstyle t t fmt 1)))
+ (cond
+ ((while (string-match "\\(\\\\ref\\)[ \t]*{" fmt)
+ (setq fmt (replace-match refstyle t t fmt 1))))
+ ((string-match "\\(\\\\[[:alpha:]]+\\)[ \t]*{" fmt)
+ (setq fmt (replace-match refstyle t t fmt 1))))
(format fmt label))
+;;;###autoload
(defun reftex-goto-label (&optional other-window)
"Prompt for a label (with completion) and jump to the location of this label.
Optional prefix argument OTHER-WINDOW goes to the label in another window."
@@ -846,7 +857,8 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window."
(docstruct (symbol-value reftex-docstruct-symbol))
;; If point is inside a \ref{} or \pageref{}, use that as
;; default value.
- (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*")
+ (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*"
+ (line-beginning-position))
(reftex-this-word "-a-zA-Z0-9_*.:")))
(label (completing-read (if default
(format "Label (default %s): " default)
@@ -867,3 +879,7 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window."
(provide 'reftex-ref)
;;; reftex-ref.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index af1d1945f39..643dbfb5a35 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -1,6 +1,6 @@
;;; reftex-sel.el --- the selection modes for RefTeX
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -102,7 +102,8 @@
This keymap can be used to configure the label selection process which is
started with the command \\[reftex-reference].")
-(define-derived-mode reftex-select-label-mode fundamental-mode "LSelect"
+;;;###autoload
+(define-derived-mode reftex-select-label-mode special-mode "LSelect"
"Major mode for selecting a label in a LaTeX document.
This buffer was created with RefTeX.
It only has a meaningful keymap when you are in the middle of a
@@ -147,7 +148,8 @@ During a selection process, these are the local bindings.
This keymap can be used to configure the BibTeX selection process which is
started with the command \\[reftex-citation].")
-(define-derived-mode reftex-select-bib-mode fundamental-mode "BSelect"
+;;;###autoload
+(define-derived-mode reftex-select-bib-mode special-mode "BSelect"
"Major mode for selecting a citation key in a LaTeX document.
This buffer was created with RefTeX.
It only has a meaningful keymap when you are in the middle of a
@@ -188,6 +190,7 @@ During a selection process, these are the local bindings.
;; (throw 'exit entry)))
;; nil))))
+;;;###autoload
(defun reftex-get-offset (buf here-am-I &optional typekey toc index file)
;; Find the correct offset data, like insert-docstruct would, but faster.
;; Buffer BUF knows the correct docstruct to use.
@@ -212,6 +215,7 @@ During a selection process, these are the local bindings.
(throw 'exit (or lastentry entry))))
nil))))
+;;;###autoload
(defun reftex-insert-docstruct
(buf toc labels index-entries files context counter show-commented
here-I-am xr-prefix toc-buffer)
@@ -292,7 +296,7 @@ During a selection process, these are the local bindings.
(setq to (point))
(when font
(put-text-property from to
- 'face reftex-file-boundary-face))
+ 'font-lock-face reftex-file-boundary-face))
(when toc-buffer
(if mouse-face
(put-text-property from (1- to)
@@ -310,7 +314,7 @@ During a selection process, these are the local bindings.
(setq to (point))
(when font
(put-text-property from to
- 'face reftex-section-heading-face))
+ 'font-lock-face reftex-section-heading-face))
(when toc-buffer
(if mouse-face
(put-text-property from (1- to)
@@ -349,7 +353,7 @@ During a selection process, these are the local bindings.
(setq to (point))
(put-text-property
(- (point) (length label)) to
- 'face (if comment
+ 'font-lock-face (if comment
'font-lock-comment-face
label-face))
(goto-char to))
@@ -379,14 +383,14 @@ During a selection process, these are the local bindings.
(setq index-tag (format "<%s>" (nth 1 cell)))
(and font
(put-text-property 0 (length index-tag)
- 'face reftex-index-tag-face index-tag))
+ 'font-lock-face reftex-index-tag-face index-tag))
(insert label-indent index-tag " " (nth 7 cell))
(when font
(setq to (point))
(put-text-property
(- (point) (length (nth 7 cell))) to
- 'face index-face)
+ 'font-lock-face index-face)
(goto-char to))
(insert "\n")
(setq to (point))
@@ -412,6 +416,7 @@ During a selection process, these are the local bindings.
(run-hooks 'reftex-display-copied-context-hook)
offset))
+;;;###autoload
(defun reftex-find-start-point (fallback &rest locations)
;; Set point to the first available LOCATION. When a LOCATION is a list,
;; search for such a :data text property. When it is an integer,
@@ -440,6 +445,7 @@ During a selection process, these are the local bindings.
(defvar reftex-last-line nil)
(defvar reftex-select-marked nil)
+;;;###autoload
(defun reftex-select-item (reftex-select-prompt help-string keymap
&optional offset
call-back cb-flag)
@@ -684,7 +690,7 @@ Cycle in reverse order if optional argument REVERSE is non-nil."
eoe (or (next-single-property-change (point) :data) (point-max)))
(setq ovl (reftex-make-overlay boe eoe))
(push (list data ovl separator) reftex-select-marked)
- (reftex-overlay-put ovl 'face reftex-select-mark-face)
+ (reftex-overlay-put ovl 'font-lock-face reftex-select-mark-face)
(reftex-overlay-put ovl 'before-string
(if separator
(format "*%c%d* " separator
@@ -737,3 +743,7 @@ Cycle in reverse order if optional argument REVERSE is non-nil."
(provide 'reftex-sel)
;;; reftex-sel.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index b7d57733467..bdae6e54ef3 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -1,6 +1,6 @@
;;; reftex-toc.el --- RefTeX's table of contents mode
-;; Copyright (C) 1997-2000, 2003-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2000, 2003-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -129,7 +129,7 @@
(defvar reftex-toc-include-index-indicator nil)
(defvar reftex-toc-max-level-indicator nil)
-(define-derived-mode reftex-toc-mode fundamental-mode "TOC"
+(define-derived-mode reftex-toc-mode special-mode "TOC"
"Major mode for managing Table of Contents for LaTeX files.
This buffer was created with RefTeX.
Press `?' for a summary of important key bindings.
@@ -190,7 +190,11 @@ M-% Global search and replace to rename label at point.
x Switch to TOC of external document (with LaTeX package `xr').
z Jump to a specific section (e.g. '3 z' goes to section 3).")
-(defun reftex-toc (&optional rebuild reuse)
+(defvar reftex--rebuilding-toc nil)
+
+;;;###autoload
+(defun reftex-toc (&optional _rebuild reuse)
+ ;; FIXME: Get rid of the `rebuild' argument.
"Show the table of contents for the current document.
When called with a raw C-u prefix, rescan the document first."
@@ -200,6 +204,9 @@ When called with a raw C-u prefix, rescan the document first."
(interactive)
(if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file)))
+ ;; FIXME: use (interactive "P") to receive current-prefix-arg as
+ ;; an argument instead of using the var here, which forces us to set
+ ;; current-prefix-arg in the callers.
current-prefix-arg)
(reftex-erase-buffer "*toc*"))
@@ -224,7 +231,7 @@ When called with a raw C-u prefix, rescan the document first."
(docstruct-symbol reftex-docstruct-symbol)
(xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
(xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
- (here-I-am (if (boundp 'reftex-rebuilding-toc)
+ (here-I-am (if reftex--rebuilding-toc
(get 'reftex-toc :reftex-data)
(car (reftex-where-am-I))))
(unsplittable (if (fboundp 'frame-property)
@@ -240,13 +247,13 @@ When called with a raw C-u prefix, rescan the document first."
(< (window-height) (* 2 window-min-height)))
(delete-other-windows))
- (setq reftex-last-window-width (window-width)
+ (setq reftex-last-window-width (window-total-width)
reftex-last-window-height (window-height)) ; remember
(unless unsplittable
(if reftex-toc-split-windows-horizontally
(split-window-right
- (floor (* (window-width)
+ (floor (* (window-total-width)
reftex-toc-split-windows-fraction)))
(split-window-below
(floor (* (window-height)
@@ -278,8 +285,16 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
" (abbreviate-file-name reftex-last-toc-master)))
(if (reftex-use-fonts)
- (put-text-property (point-min) (point) 'face reftex-toc-header-face))
- (put-text-property (point-min) (point) 'intangible t)
+ (put-text-property (point-min) (point) 'font-lock-face reftex-toc-header-face))
+ (if (fboundp 'cursor-intangible-mode)
+ (cursor-intangible-mode 1)
+ ;; If `cursor-intangible' is not available, fallback on the old
+ ;; intrusive `intangible' property.
+ (put-text-property (point-min) (point) 'intangible t))
+ (add-text-properties (point-min) (point)
+ '(cursor-intangible t
+ front-sticky (cursor-intangible)
+ rear-nonsticky (cursor-intangible)))
(put-text-property (point-min) (1+ (point-min)) 'xr-alist xr-alist)
(setq offset
@@ -319,6 +334,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(reftex-find-start-point (point) offset (get 'reftex-toc :reftex-line))
(setq reftex-last-follow-point (point))))
+;;;###autoload
(defun reftex-toc-recenter (&optional arg)
"Display the TOC window and highlight line corresponding to current position."
(interactive "P")
@@ -329,8 +345,8 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(let ((current-prefix-arg nil))
(select-window (get-buffer-window buf frame))
(reftex-toc nil t)))
- (and (> (point) 1)
- (not (get-text-property (point) 'intangible))
+ (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing?
+ (not (get-text-property (point) 'cursor-intangible))
(memq reftex-highlight-selection '(cursor both))
(reftex-highlight 2
(or (previous-single-property-change
@@ -347,10 +363,11 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(defun reftex-toc-post-command-hook ()
;; used in the post-command-hook for the *toc* buffer
+ ;; FIXME: Lots of redundancy with reftex-index-post-command-hook!
(when (get-text-property (point) :data)
(put 'reftex-toc :reftex-data (get-text-property (point) :data))
- (and (> (point) 1)
- (not (get-text-property (point) 'intangible))
+ (and (> (point) 1) ;FIXME: Is this point-min or do we care about narrowing?
+ (not (get-text-property (point) 'cursor-intangible))
(memq reftex-highlight-selection '(cursor both))
(reftex-highlight 2
(or (previous-single-property-change (1+ (point)) :data)
@@ -372,8 +389,8 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(defun reftex-re-enlarge ()
"Enlarge window to a remembered size."
(let ((count (if reftex-toc-split-windows-horizontally
- (- (or reftex-last-window-width (window-width))
- (window-width))
+ (- (or reftex-last-window-width (window-total-width))
+ (window-total-width))
(- (or reftex-last-window-height (window-height))
(window-height)))))
(when (> count 0)
@@ -403,17 +420,17 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
(if reftex-toc-follow-mode
(setq reftex-toc-follow-mode 1)))
-(defun reftex-toc-next (&optional arg)
+(defun reftex-toc-next (&optional _arg)
"Move to next selectable item."
- (interactive "p")
+ (interactive)
(when (featurep 'xemacs) (setq zmacs-region-stays t))
(setq reftex-callback-fwd t)
(or (eobp) (forward-char 1))
(goto-char (or (next-single-property-change (point) :data)
(point))))
-(defun reftex-toc-previous (&optional arg)
+(defun reftex-toc-previous (&optional _arg)
"Move to previous selectable item."
- (interactive "p")
+ (interactive)
(when (featurep 'xemacs) (setq zmacs-region-stays t))
(setq reftex-callback-fwd nil)
(goto-char (or (previous-single-property-change (point) :data)
@@ -547,7 +564,7 @@ With prefix arg 1, restrict index to the section at point."
(reftex-display-index (if restr nil arg) restr)))
;; Rescanning the document and rebuilding the TOC buffer.
-(defun reftex-toc-rescan (&rest ignore)
+(defun reftex-toc-rescan (&rest _)
"Regenerate the *toc* buffer by reparsing file of section at point."
(interactive)
(if (and reftex-enable-partial-scans
@@ -565,12 +582,12 @@ With prefix arg 1, restrict index to the section at point."
(switch-to-buffer-other-window
(reftex-get-file-buffer-force file))
(setq current-prefix-arg '(4))
- (let ((reftex-rebuilding-toc t))
+ (let ((reftex--rebuilding-toc t))
(reftex-toc))))
(reftex-toc-Rescan))
(reftex-kill-temporary-buffers))
-(defun reftex-toc-Rescan (&rest ignore)
+(defun reftex-toc-Rescan (&rest _)
"Regenerate the *toc* buffer by reparsing the entire document."
(interactive)
(let* ((line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
@@ -578,17 +595,17 @@ With prefix arg 1, restrict index to the section at point."
(switch-to-buffer-other-window
(reftex-get-file-buffer-force reftex-last-toc-file))
(setq current-prefix-arg '(16))
- (let ((reftex-rebuilding-toc t))
+ (let ((reftex--rebuilding-toc t))
(reftex-toc)))
-(defun reftex-toc-revert (&rest ignore)
+(defun reftex-toc-revert (&rest _)
"Regenerate the TOC from the internal lists."
(interactive)
(let ((unsplittable
(if (fboundp 'frame-property)
(frame-property (selected-frame) 'unsplittable)
(frame-parameter nil 'unsplittable)))
- (reftex-rebuilding-toc t))
+ (reftex--rebuilding-toc t))
(if unsplittable
(switch-to-buffer
(reftex-get-file-buffer-force reftex-last-toc-file))
@@ -596,9 +613,9 @@ With prefix arg 1, restrict index to the section at point."
(reftex-get-file-buffer-force reftex-last-toc-file))))
(reftex-erase-buffer "*toc*")
(setq current-prefix-arg nil)
- (reftex-toc t))
+ (reftex-toc t t))
-(defun reftex-toc-external (&rest ignore)
+(defun reftex-toc-external (&rest _)
"Switch to table of contents of an external document."
(interactive)
(reftex-toc-dframe-p nil 'error)
@@ -626,18 +643,17 @@ Useful for large TOCs."
;; Promotion/Demotion stuff
-(defvar pro-or-de)
-(defvar start-pos)
-(defvar start-line)
-(defvar mark-line)
+(defvar reftex--pro-or-de)
+(defvar reftex--start-line)
+(defvar reftex--mark-line)
-(defun reftex-toc-demote (&optional arg)
+(defun reftex-toc-demote (&optional _arg)
"Demote section at point. If region is active, apply to all in region."
- (interactive "p")
+ (interactive)
(reftex-toc-do-promote 1))
-(defun reftex-toc-promote (&optional arg)
+(defun reftex-toc-promote (&optional _arg)
"Promote section at point. If region is active, apply to all in region."
- (interactive "p")
+ (interactive)
(reftex-toc-do-promote -1))
(defun reftex-toc-do-promote (delta)
"Workhorse for `reftex-toc-promote' and `reftex-toc-demote'.
@@ -646,14 +662,15 @@ point."
;; We should not do anything unless we are sure this is going to work for
;; each section in the region. Therefore we first collect information and
;; test.
- (let* ((start-line (+ (count-lines (point-min) (point))
- (if (bolp) 1 0)))
- (mark-line (if (reftex-region-active-p)
- (save-excursion (goto-char (mark))
- (+ (count-lines (point-min) (point))
- (if (bolp) 1 0)))))
+ (let* ((reftex--start-line (+ (count-lines (point-min) (point))
+ (if (bolp) 1 0)))
+ (reftex--mark-line
+ (if (reftex-region-active-p)
+ (save-excursion (goto-char (mark))
+ (+ (count-lines (point-min) (point))
+ (if (bolp) 1 0)))))
(start-pos (point))
- (pro-or-de (if (> delta 0) "de" "pro"))
+ (reftex--pro-or-de (if (> delta 0) "de" "pro"))
beg end entries data sections nsec msg)
(setq msg
(catch 'exit
@@ -702,23 +719,23 @@ point."
;; Rescan the document and rebuilt the toc buffer
(save-window-excursion
(reftex-toc-Rescan))
- (reftex-toc-restore-region start-line mark-line)
+ (reftex-toc-restore-region reftex--start-line reftex--mark-line)
(message "%d section%s %smoted"
- nsec (if (= 1 nsec) "" "s") pro-or-de)
+ nsec (if (= 1 nsec) "" "s") reftex--pro-or-de)
nil))
(if msg (progn (ding) (message "%s" msg)))))
(defun reftex-toc-restore-region (point-line &optional mark-line)
- (let (mpos)
- (when mark-line
- (goto-char (point-min))
- (forward-line (1- mark-line))
- (setq mpos (point)))
+ (let ((mpos
+ (when mark-line
+ (goto-char (point-min))
+ (forward-line (1- mark-line))
+ (point))))
(when point-line
(goto-char (point-min))
(forward-line (1- point-line)))
- (when mark-line
+ (when mpos
(set-mark mpos)
(if (featurep 'xemacs)
(zmacs-activate-region)
@@ -738,7 +755,7 @@ promotion/demotion later. DELTA is the level change."
(name nil)
;; Here follows some paranoid code to make very sure we are not
;; going to break anything
- (name1 ; dummy
+ (_
(if (and (markerp marker) (marker-buffer marker))
;; Buffer is still live and we have the marker.
(progn
@@ -761,24 +778,24 @@ promotion/demotion later. DELTA is the level change."
;; We don't have a live marker: scan and load files.
(reftex-toc-load-all-files-for-promotion)))
(level (cdr (assoc name reftex-section-levels-all)))
- (dummy (if (not (integerp level))
- (progn
- (goto-char toc-point)
- (error "Cannot %smote special sections" pro-or-de))))
+ (_ (if (not (integerp level))
+ (progn
+ (goto-char toc-point)
+ (error "Cannot %smote special sections" reftex--pro-or-de))))
(newlevel (if (>= level 0) (+ delta level) (- level delta)))
- (dummy2 (if (or (and (>= level 0) (= newlevel -1))
- (and (< level 0) (= newlevel 0)))
- (error "Cannot %smote \\%s" pro-or-de name)))
+ (_ (if (or (and (>= level 0) (= newlevel -1))
+ (and (< level 0) (= newlevel 0)))
+ (error "Cannot %smote \\%s" reftex--pro-or-de name)))
(newname (reftex-toc-newhead-from-alist newlevel name
reftex-section-levels-all)))
(if (and name newname)
(list data name newname toc-point)
(goto-char toc-point)
- (error "Cannot %smote \\%s" pro-or-de name))))
+ (error "Cannot %smote \\%s" reftex--pro-or-de name))))
(defun reftex-toc-promote-action (x)
"Change the level of a TOC entry.
-PRO-OR-DE is assumed to be dynamically scoped into this function."
+`reftex--pro-or-de' is assumed to be dynamically scoped into this function."
(let* ((data (car x))
(name (nth 1 x))
(newname (nth 2 x))
@@ -787,7 +804,7 @@ PRO-OR-DE is assumed to be dynamically scoped into this function."
(goto-char (marker-position marker))
(if (looking-at (concat "\\([ \t]*" reftex-section-pre-regexp "\\)" (regexp-quote name)))
(replace-match (concat "\\1" newname))
- (error "Fatal error during %smotion" pro-or-de)))))
+ (error "Fatal error during %smotion" reftex--pro-or-de)))))
(defun reftex-toc-extract-section-number (entry)
"Get the numbering of a TOC entry, for message purposes."
@@ -837,11 +854,11 @@ if these sets are sorted blocks in the alist."
"Make sure all files of the document are being visited by buffers,
and that the scanning info is absolutely up to date.
We do this by rescanning with `reftex-keep-temporary-buffers' bound to t.
-The variable PRO-OR-DE is assumed to be dynamically scoped into this function.
+The variable `reftex--pro-or-de' is assumed to be dynamically scoped into this function.
When finished, we exit with an error message."
(let ((reftex-keep-temporary-buffers t))
(reftex-toc-Rescan)
- (reftex-toc-restore-region start-line mark-line)
+ (reftex-toc-restore-region reftex--start-line reftex--mark-line)
(throw 'exit
"TOC had to be updated first. Please check selection and repeat the command.")))
@@ -859,7 +876,7 @@ label prefix determines the wording of a reference."
(setq newlabel (read-string (format "Rename label \"%s\" to:" label)))
(if (assoc newlabel (symbol-value reftex-docstruct-symbol))
(if (not (y-or-n-p
- (format "Label '%s' exists. Use anyway? " label)))
+ (format-message "Label `%s' exists. Use anyway? " label)))
(error "Abort")))
(save-excursion
(save-window-excursion
@@ -884,7 +901,7 @@ label prefix determines the wording of a reference."
(let* ((toc (get-text-property (point) :data))
(toc-window (selected-window))
- show-window show-buffer match)
+ match)
(unless toc (error "Don't know which TOC line to visit"))
@@ -915,30 +932,33 @@ label prefix determines the wording of a reference."
(setq match (reftex-show-label-location toc reftex-callback-fwd
no-revisit t))))
- (setq show-window (selected-window)
- show-buffer (current-buffer))
-
(unless match
(select-window toc-window)
(error "Cannot find location"))
- (select-window toc-window)
-
- ;; use the `final' parameter to decide what to do next
+ ;; Use the `final' parameter to decide what to do next.
(cond
((eq final t)
- (reftex-unhighlight 0)
- (select-window show-window))
+ (with-selected-window toc-window
+ (reftex-unhighlight 0)))
((eq final 'hide)
- (reftex-unhighlight 0)
- (or (one-window-p) (delete-window))
- ;; If `show-window' is still live, show-buffer is already visible
- ;; so let's not make it visible in yet-another-window.
- (if (window-live-p show-window)
- (set-buffer show-buffer)
- (switch-to-buffer show-buffer))
- (reftex-re-enlarge))
- (t nil))))
+ (let ((show-window (selected-window))
+ (show-buffer (window-buffer)))
+ (unless (eq show-window toc-window) ;FIXME: Can this happen?
+ (with-selected-window toc-window
+ (reftex-unhighlight 0)
+ (or (one-window-p) (delete-window))))
+ ;; If `show-window' is still live, show-buffer is already visible
+ ;; so let's not make it visible in yet-another-window.
+ (unless (window-live-p show-window)
+ ;; FIXME: How could show-window not be live?
+ (switch-to-buffer show-buffer))
+ (reftex-re-enlarge)))
+ (t
+ (unless (eq (selected-frame) (window-frame toc-window))
+ ;; Make sure `toc-window' is not just selected but has focus.
+ (select-frame-set-input-focus (window-frame toc-window)))
+ (select-window toc-window)))))
(defun reftex-toc-find-section (toc &optional no-revisit)
(let* ((file (nth 3 toc))
@@ -1009,6 +1029,7 @@ label prefix determines the wording of a reference."
(let (current-prefix-arg)
(reftex-toc-recenter))))
+;;;###autoload
(defun reftex-toggle-auto-toc-recenter ()
"Toggle the automatic recentering of the TOC window.
When active, leaving point idle will make the TOC window jump to the correct
@@ -1088,3 +1109,7 @@ always show the current section in connection with the option
(reftex-toggle-auto-toc-recenter))))
;;; reftex-toc.el ends here
+
+;; Local Variables:
+;; generated-autoload-file: "reftex.el"
+;; End:
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index ce23a48dec6..97c8af365e8 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -1,6 +1,6 @@
;;; reftex-vars.el --- configuration variables for RefTeX
-;; Copyright (C) 1997-1999, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1999, 2001-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -85,11 +85,12 @@
(supertab "Supertabular environment"
(("supertabular" ?t nil nil "\\tablecaption{")))
- (wrapfig "The wrapfigure environment"
- (("wrapfigure" ?f nil nil caption)))
+ (wrapfig "The wrapfig package"
+ (("wrapfigure" ?f nil nil caption)
+ ("wraptable" ?t nil nil caption)))
(ctable "The ctable package"
- (("\\ctable[]{}{}{}" ?t "tab:" "\\ref{%s}" 1 ("table" "Tabelle"))))
+ (("\\ctable[]{}{}{}" ?t "tab:" "~\\ref{%s}" 1 ("table" "Tabelle"))))
(listings "The listings package"
(("lstlisting" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting"))))
@@ -127,7 +128,10 @@
;; The label macro is hard coded, but it *could* be defined like this:
;;("\\label{*}" nil nil nil nil)
- )))
+ ))
+
+ ;; Texinfo
+ (Texinfo "Texinfo default environments" nil))
"The default label environment descriptions.
Lower-case symbols correspond to a style file of the same name in the LaTeX
distribution. Mixed-case symbols are convenience aliases.")
@@ -260,6 +264,7 @@ distribution. Mixed-case symbols are convenience aliases.")
The file name is expected after the command, either in braces or separated
by whitespace."
:group 'reftex-table-of-contents-browser
+ :set 'reftex-set-dirty
:type '(repeat string))
(defcustom reftex-max-section-depth 12
@@ -649,7 +654,7 @@ Possible keys are sectioning macro names like `chapter', section levels
(string :tag "Prefix"))))
(defcustom reftex-default-context-regexps
- '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
+ '((caption . "\\\\\\(rot\\|bi\\)?\\(sub\\)?caption\\(box\\)?\\*?[[{]")
(item . "\\\\item\\(\\[[^]]*\\]\\)?")
(eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
(alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
@@ -863,13 +868,17 @@ DOWNCASE t: Downcase words before using them."
(string :tag ""))
(option (boolean :tag "Downcase words "))))
-(defcustom reftex-label-regexps
- '(;; Normal \\label{foo} labels
- "\\\\label{\\(?1:[^}]*\\)}"
- ;; keyvals [..., label = {foo}, ...] forms used by ctable,
- ;; listings, minted, ...
- "\\[[^]]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
- "List of regexps matching \\label definitions.
+(if (featurep 'xemacs)
+ ;; XEmacs 21.5 doesn't have explicitly numbered matching groups,
+ ;; so this list mustn't get any more items.
+ (defconst reftex-label-regexps '("\\\\label{\\([^}]*\\)}"))
+ (defcustom reftex-label-regexps
+ '(;; Normal \\label{foo} labels
+ "\\\\label{\\(?1:[^}]*\\)}"
+ ;; keyvals [..., label = {foo}, ...] forms used by ctable,
+ ;; listings, minted, ...
+ "\\[[^[]]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
+ "List of regexps matching \\label definitions.
The default value matches usual \\label{...} definitions and
keyval style [..., label = {...}, ...] label definitions. It is
assumed that the regexp group 1 matches the label text, so you
@@ -878,12 +887,13 @@ have to define it using \\(?1:...\\) when adding new regexps.
When changed from Lisp, make sure to call
`reftex-compile-variables' afterwards to make the change
effective."
- :set (lambda (symbol value)
- (set symbol value)
- (when (fboundp 'reftex-compile-variables)
- (reftex-compile-variables)))
- :group 'reftex-defining-label-environments
- :type '(repeat (regexp :tag "Regular Expression")))
+ :version "25.1"
+ :set (lambda (symbol value)
+ (set symbol value)
+ (when (fboundp 'reftex-compile-variables)
+ (reftex-compile-variables)))
+ :group 'reftex-defining-label-environments
+ :type '(repeat (regexp :tag "Regular Expression"))))
(defcustom reftex-label-ignored-macros-and-environments nil
"List of macros and environments to be ignored when searching for labels.
@@ -1144,9 +1154,9 @@ path."
"Sorting of the entries found in BibTeX databases by reftex-citation.
Possible values:
nil Do not sort entries.
-'author Sort entries by author name.
-'year Sort entries by increasing year.
-'reverse-year Sort entries by decreasing year."
+`author' Sort entries by author name.
+`year' Sort entries by increasing year.
+`reverse-year' Sort entries by decreasing year."
:group 'reftex-citation-support
:type '(choice (const :tag "not" nil)
(const :tag "by author" author)
@@ -1442,7 +1452,7 @@ last The last used index tag will be offered as default."
:group 'reftex-index-support
:type '(choice
(const :tag "no default" nil)
- (const :tag "last used " 'last)
+ (const :tag "last used " last)
(string :tag "index tag " "idx")))
(defcustom reftex-index-math-format "$%s$"
@@ -1982,7 +1992,8 @@ symbol indicating in what context the hook is called."
(defcustom reftex-extra-bindings nil
"Non-nil means, make additional key bindings on startup.
-These extra bindings are located in the users `C-c letter' map."
+These extra bindings are located in the users `C-c letter' map.
+Note that this variable needs to be set before reftex is loaded."
:group 'reftex-miscellaneous-configurations
:type 'boolean)
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index ae8f94fd063..84efa7a5b21 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1,5 +1,5 @@
;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
-;; Copyright (C) 1997-2000, 2003-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2000, 2003-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -70,139 +70,26 @@
(require 'reftex-vars)
-;;; Autoloads
-
-;; Parser functions
-(autoload 'reftex-parse-one "reftex-parse"
- "Re-parse this file." t)
-(autoload 'reftex-parse-all "reftex-parse"
- "Re-parse entire document." t)
-(autoload 'reftex-do-parse "reftex-parse")
-(autoload 'reftex-where-am-I "reftex-parse")
-(autoload 'reftex-init-section-numbers "reftex-parse")
-(autoload 'reftex-section-info "reftex-parse")
-(autoload 'reftex-section-number "reftex-parse")
-(autoload 'reftex-what-macro "reftex-parse")
-(autoload 'reftex-what-macro-safe "reftex-parse")
-(autoload 'reftex-index-info "reftex-parse")
-(autoload 'reftex-index-info-safe "reftex-parse")
-(autoload 'reftex-short-context "reftex-parse")
-(autoload 'reftex-what-environment "reftex-parse")
-(autoload 'reftex-what-special-env "reftex-parse")
-(autoload 'reftex-move-over-touching-args "reftex-parse")
-(autoload 'reftex-notice-new "reftex-parse")
-(autoload 'reftex-nth-arg "reftex-parse")
-(autoload 'reftex-locate-bibliography-files "reftex-parse")
-(autoload 'reftex-ensure-index-support "reftex-parse")
-(autoload 'reftex-everything-regexp "reftex-parse")
-
-;; Labels and References
-(autoload 'reftex-label-location "reftex-ref")
-(autoload 'reftex-label-info-update "reftex-ref")
-(autoload 'reftex-label-info "reftex-ref")
-(autoload 'reftex-label "reftex-ref"
- "Insert a unique label." t)
-(autoload 'reftex-reference "reftex-ref"
- "Make a LaTeX reference." t)
+;;; Autoloads - see end for automatic autoloads
+
+;; We autoload tons of functions from these files, but some have
+;; a single function that needs to be globally autoloaded.
+;; The alternative is to use a Makefile rule + distinct autoload
+;; cookie (eg ;;;###reftex-autoload) for internal autoloads,
+;; as eg calendar/ does. But that seemed like overkill for 4 functions.
+
+;;;###autoload(autoload 'reftex-citation "reftex-cite" nil t)
+;;;###autoload(autoload 'reftex-all-document-files "reftex-parse")
+;;;###autoload(autoload 'reftex-isearch-minor-mode "reftex-global" nil t)
+;;;###autoload(autoload 'reftex-index-phrases-mode "reftex-index" nil t)
+
+;; Generated functions.
(autoload 'reftex-varioref-vref "reftex-ref"
"Make a varioref reference." t)
(autoload 'reftex-fancyref-fref "reftex-ref"
"Make a fancyref \\fref reference." t)
(autoload 'reftex-fancyref-Fref "reftex-ref"
"Make a fancyref \\Fref reference." t)
-(autoload 'reftex-show-label-location "reftex-ref")
-(autoload 'reftex-query-label-type "reftex-ref")
-(autoload 'reftex-goto-label "reftex-ref"
- "Prompt for label name and go to that location." t)
-
-;; Table of contents
-(autoload 'reftex-toc "reftex-toc"
- "Show the table of contents for the current document." t)
-(autoload 'reftex-toc-recenter "reftex-toc"
- "Display the TOC window and highlight line corresponding to current position." t)
-(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc"
- "Toggle automatic recentering of TOC window." t)
-
-;; BibTeX citations.
-(autoload 'reftex-citep "reftex-cite")
-(autoload 'reftex-citet "reftex-cite")
-(autoload 'reftex-make-cite-echo-string "reftex-cite")
-(autoload 'reftex-get-bibfile-list "reftex-cite")
-(autoload 'reftex-pop-to-bibtex-entry "reftex-cite")
-(autoload 'reftex-end-of-bib-entry "reftex-cite")
-(autoload 'reftex-parse-bibtex-entry "reftex-cite")
-(autoload 'reftex-citation "reftex-cite"
- "Make a citation using BibTeX database files." t)
-(autoload 'reftex-default-bibliography "reftex-cite")
-(autoload 'reftex-bib-or-thebib "reftex-cite")
-(autoload 'reftex-create-bibtex-file "reftex-cite")
-
-;; Selection
-(autoload 'reftex-select-label-mode "reftex-sel")
-(autoload 'reftex-select-bib-mode "reftex-sel")
-(autoload 'reftex-find-start-point "reftex-sel")
-(autoload 'reftex-insert-docstruct "reftex-sel")
-(autoload 'reftex-get-offset "reftex-sel")
-(autoload 'reftex-select-item "reftex-sel")
-
-;; Index support
-(autoload 'reftex-index "reftex-index"
- "Query for an index macro and insert it along with its arguments." t)
-(autoload 'reftex-index-selection-or-word "reftex-index"
- "Put selection or the word near point into the default index macro." t)
-(autoload 'reftex-index-phrase-selection-or-word "reftex-index"
- "Put selection or the word near point into Index Phrases File." t)
-(autoload 'reftex-display-index "reftex-index"
- "Display a buffer with an index compiled from the current document." t)
-(autoload 'reftex-index-visit-phrases-buffer "reftex-index"
- "Visit the Index Phrases File." t)
-(autoload 'reftex-index-phrases-mode "reftex-index"
- "Major mode for managing the Index phrases of a LaTeX document." t)
-(autoload 'reftex-index-complete-tag "reftex-index")
-(autoload 'reftex-index-complete-key "reftex-index")
-(autoload 'reftex-index-show-entry "reftex-index")
-(autoload 'reftex-index-select-tag "reftex-index")
-
-;; View cross references
-(autoload 'reftex-view-crossref "reftex-dcr"
- "View cross reference of \\ref or \\cite macro at point." t)
-(autoload 'reftex-mouse-view-crossref "reftex-dcr"
- "View cross reference of \\ref or \\cite macro where you click." t)
-(autoload 'reftex-toggle-auto-view-crossref "reftex-dcr")
-(autoload 'reftex-view-crossref-from-bibtex "reftex-dcr"
- "View location in a LaTeX document which cites the BibTeX entry at point." t)
-
-;; Operations on entire Multifile documents
-(autoload 'reftex-create-tags-file "reftex-global"
- "Create TAGS file by running `etags' on the current document." t)
-(autoload 'reftex-grep-document "reftex-global"
- "Run grep query through all files related to this document." t)
-(autoload 'reftex-search-document "reftex-global"
- "Regexp search through all files of the current TeX document." t)
-(autoload 'reftex-query-replace-document "reftex-global"
- "Run a query-replace-regexp of FROM with TO over the entire TeX document." t)
-(autoload 'reftex-find-duplicate-labels "reftex-global"
- "Produce a list of all duplicate labels in the document." t)
-(autoload 'reftex-change-label "reftex-global"
- "Query replace FROM with TO in all \\label and \\ref commands." t)
-(autoload 'reftex-renumber-simple-labels "reftex-global"
- "Renumber all simple labels in the document to make them sequentially." t)
-(autoload 'reftex-save-all-document-buffers "reftex-global"
- "Save all documents associated with the current document." t)
-
-;; AUCTeX Interface
-(autoload 'reftex-arg-label "reftex-auc")
-(autoload 'reftex-arg-cite "reftex-auc")
-(autoload 'reftex-arg-index-tag "reftex-auc")
-(autoload 'reftex-arg-index "reftex-auc")
-(autoload 'reftex-plug-into-AUCTeX "reftex-auc")
-(autoload 'reftex-toggle-plug-into-AUCTeX "reftex-auc"
- "Toggle Interface between AUCTeX and RefTeX on and off." t)
-(autoload 'reftex-add-label-environments "reftex-auc")
-(autoload 'reftex-add-to-label-alist "reftex-auc")
-(autoload 'reftex-add-section-levels "reftex-auc")
-(autoload 'reftex-notice-new-section "reftex-auc")
-
;;; =========================================================================
;;;
@@ -219,17 +106,21 @@
(defvar reftex-syntax-table nil)
(defvar reftex-syntax-table-for-bib nil)
-(unless reftex-syntax-table
+(defun reftex--prepare-syntax-tables ()
(setq reftex-syntax-table (copy-syntax-table))
(modify-syntax-entry ?\( "." reftex-syntax-table)
- (modify-syntax-entry ?\) "." reftex-syntax-table))
+ (modify-syntax-entry ?\) "." reftex-syntax-table)
-(unless reftex-syntax-table-for-bib
(setq reftex-syntax-table-for-bib (copy-syntax-table))
(modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
(modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
(modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
- (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
+ (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)
+ (modify-syntax-entry ?\( "." reftex-syntax-table-for-bib)
+ (modify-syntax-entry ?\) "." reftex-syntax-table-for-bib))
+
+(unless (and reftex-syntax-table reftex-syntax-table-for-bib)
+ (reftex--prepare-syntax-tables))
;; The following definitions are out of place, but I need them here
;; to make the compilation of reftex-mode not complain.
@@ -293,15 +184,7 @@ on the menu bar.
(put 'reftex-auto-recenter-toc 'initialized t))
;; Prepare the special syntax tables.
- (setq reftex-syntax-table (copy-syntax-table (syntax-table)))
- (modify-syntax-entry ?\( "." reftex-syntax-table)
- (modify-syntax-entry ?\) "." reftex-syntax-table)
-
- (setq reftex-syntax-table-for-bib (copy-syntax-table))
- (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
- (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
- (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
- (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)
+ (reftex--prepare-syntax-tables)
(run-hooks 'reftex-mode-hook))
;; Mode was turned off
@@ -423,12 +306,28 @@ If the symbols for the current master file do not exist, they are created."
(let
((master
(cond
- ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
+ ;; Test if we're in a subfile using the subfiles document
+ ;; class, e.g., \documentclass[main.tex]{subfiles}. It's
+ ;; argument is the main file, however it's not really the
+ ;; master file in `TeX-master-file' or `tex-main-file's
+ ;; sense. It should be used for references but not for
+ ;; compilation, thus subfiles use a setting of
+ ;; `TeX-master'/`tex-main-file' being themselves.
+ ((save-excursion
+ (goto-char (point-min))
+ (re-search-forward
+ "^[[:space:]]*\\\\documentclass\\[\\([[:word:].]+\\)\\]{subfiles}"
+ nil t))
+ (match-string-no-properties 1))
+ ;; AUCTeX is loaded. Use its mechanism.
+ ((fboundp 'TeX-master-file)
(condition-case nil
(TeX-master-file t)
(error (buffer-file-name))))
- ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode
- ((boundp 'TeX-master) ; The variable is defined - let's use it.
+ ;; Emacs LaTeX mode
+ ((fboundp 'tex-main-file) (tex-main-file))
+ ;; Check the `TeX-master' variable.
+ ((boundp 'TeX-master)
(cond
((eq TeX-master t)
(buffer-file-name))
@@ -439,6 +338,7 @@ If the symbols for the current master file do not exist, they are created."
(t
(setq TeX-master (read-file-name "Master file: "
nil nil t nil)))))
+ ;; Check the `tex-main-file' variable.
((boundp 'tex-main-file)
;; This is the variable from the default TeX modes.
(cond
@@ -448,8 +348,9 @@ If the symbols for the current master file do not exist, they are created."
(t
;; In this case, the buffer is its own master.
(buffer-file-name))))
+ ;; We know nothing about master file. Assume this is a
+ ;; master file.
(t
- ;; Know nothing about master file. Assume this is a master file.
(buffer-file-name)))))
(cond
((null master)
@@ -1822,7 +1723,7 @@ When DIE is non-nil, throw an error if file not found."
(defvar message-stack)
(if (and (featurep 'xemacs)
(not (fboundp 'current-message)))
- (defun current-message (&optional frame)
+ (defun current-message (&optional _frame)
(cdr (car message-stack))))
(defun reftex-visited-files (list)
@@ -2164,7 +2065,7 @@ IGNORE-WORDS List of words which should be removed from the string."
(message "Sorry: cannot refontify RefTeX Select buffer."))))
(rename-buffer oldname))))
-(defun reftex-select-font-lock-fontify-region (beg end &optional loudly)
+(defun reftex-select-font-lock-fontify-region (beg end &optional _loudly)
;; Fontify a region, but only lines starting with a dot.
(let ((func (if (fboundp 'font-lock-default-fontify-region)
'font-lock-default-fontify-region
@@ -2176,7 +2077,7 @@ IGNORE-WORDS List of words which should be removed from the string."
(funcall func beg1 end1 nil)
(goto-char end1))))
-(defun reftex-select-font-lock-unfontify (&rest ignore) t)
+(defun reftex-select-font-lock-unfontify (&rest _ignore) t)
(defun reftex-verified-face (&rest faces)
;; Return the first valid face in FACES, or nil if none is valid.
@@ -2458,6 +2359,7 @@ output buffer into your mail program, as it gives us important
information about your RefTeX version and configuration."
(interactive)
(require 'reporter)
+ (defvar reporter-prompt-for-summary-p)
(let ((reporter-prompt-for-summary-p "Bug report subject: "))
(reporter-submit-bug-report
"bug-auctex@gnu.org, bug-gnu-emacs@gnu.org"
@@ -2471,7 +2373,7 @@ what in fact did happen.
Check if the bug is reproducible with an up-to-date version of
RefTeX available from http://www.gnu.org/software/auctex/.
-If the bug is triggered by a specific \(La\)TeX file, you should try
+If the bug is triggered by a specific \(La)TeX file, you should try
to produce a minimal sample file showing the problem and include it
in your report.
@@ -2491,6 +2393,703 @@ Your bug report will be posted to the AUCTeX bug reporting list.
;;; That's it! ----------------------------------------------------------------
(setq reftex-tables-dirty t) ; in case this file is evaluated by hand
+
+
+;;; Start of automatically extracted autoloads.
+
+;;;### (autoloads nil "reftex-auc" "reftex-auc.el" "cf606f7918831321cb46f254436dc66e")
+;;; Generated autoloads from reftex-auc.el
+
+(autoload 'reftex-arg-label "reftex-auc" "\
+Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
+What is being used depends upon `reftex-plug-into-AUCTeX'.
+
+\(fn OPTIONAL &optional PROMPT DEFINITION)" nil nil)
+
+(autoload 'reftex-arg-cite "reftex-auc" "\
+Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
+What is being used depends upon `reftex-plug-into-AUCTeX'.
+
+\(fn OPTIONAL &optional PROMPT DEFINITION)" nil nil)
+
+(autoload 'reftex-arg-index-tag "reftex-auc" "\
+Prompt for an index tag with completion.
+This is the name of an index, not the entry.
+
+\(fn OPTIONAL &optional PROMPT &rest ARGS)" nil nil)
+
+(autoload 'reftex-arg-index "reftex-auc" "\
+Prompt for an index entry completing with known entries.
+Completion is specific for just one index, if the macro or a tag
+argument identify one of multiple indices.
+
+\(fn OPTIONAL &optional PROMPT &rest ARGS)" nil nil)
+
+(autoload 'reftex-plug-into-AUCTeX "reftex-auc" "\
+
+
+\(fn)" nil nil)
+
+(autoload 'reftex-toggle-plug-into-AUCTeX "reftex-auc" "\
+Toggle Interface between AUCTeX and RefTeX on and off.
+
+\(fn)" t nil)
+
+(autoload 'reftex-add-label-environments "reftex-auc" "\
+Add label environment descriptions to `reftex-label-alist-style'.
+The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there
+for details.
+This function makes it possible to support RefTeX from AUCTeX style files.
+The entries in ENTRY-LIST will be processed after the user settings in
+`reftex-label-alist', and before the defaults (specified in
+`reftex-default-label-alist-entries'). Any changes made to
+`reftex-label-alist-style' will raise a flag to the effect that
+the label information is recompiled on next use.
+
+\(fn ENTRY-LIST)" nil nil)
+
+(defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
+
+(autoload 'reftex-add-section-levels "reftex-auc" "\
+Add entries to the value of `reftex-section-levels'.
+The added values are kept local to the current document. The format
+of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See
+`reftex-section-levels' for an example.
+
+\(fn ENTRY-LIST)" nil nil)
+
+(autoload 'reftex-notice-new-section "reftex-auc" "\
+
+
+\(fn)" nil nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-cite" "reftex-cite.el" "7eaa61c05a6578999ea68f1be0fbcf49")
+;;; Generated autoloads from reftex-cite.el
+
+(autoload 'reftex-default-bibliography "reftex-cite" "\
+Return the expanded value of variable `reftex-default-bibliography'.
+The expanded value is cached.
+
+\(fn)" nil nil)
+
+(autoload 'reftex-bib-or-thebib "reftex-cite" "\
+Test if BibTeX or egin{thebibliography} should be used for the citation.
+Find the bof of the current file
+
+\(fn)" nil nil)
+
+(autoload 'reftex-get-bibfile-list "reftex-cite" "\
+Return list of bibfiles for current document.
+When using the chapterbib or bibunits package you should either
+use the same database files everywhere, or separate parts using
+different databases into different files (included into the mater file).
+Then this function will return the applicable database files.
+
+\(fn)" nil nil)
+
+(autoload 'reftex-pop-to-bibtex-entry "reftex-cite" "\
+Find BibTeX KEY in any file in FILE-LIST in another window.
+If MARK-TO-KILL is non-nil, mark new buffer to kill.
+If HIGHLIGHT is non-nil, highlight the match.
+If ITEM in non-nil, search for bibitem instead of database entry.
+If RETURN is non-nil, just return the entry and restore point.
+
+\(fn KEY FILE-LIST &optional MARK-TO-KILL HIGHLIGHT ITEM RETURN)" nil nil)
+
+(autoload 'reftex-end-of-bib-entry "reftex-cite" "\
+
+
+\(fn ITEM)" nil nil)
+
+(autoload 'reftex-parse-bibtex-entry "reftex-cite" "\
+Parse BibTeX ENTRY.
+If ENTRY is nil then parse the entry in current buffer between FROM and TO.
+If RAW is non-nil, keep double quotes/curly braces delimiting fields.
+
+\(fn ENTRY &optional FROM TO RAW)" nil nil)
+
+(autoload 'reftex-citation "reftex-cite" "\
+Make a citation using BibTeX database files.
+After prompting for a regular expression, scans the buffers with
+bibtex entries (taken from the \\bibliography command) and offers the
+matching entries for selection. The selected entry is formatted according
+to `reftex-cite-format' and inserted into the buffer.
+
+If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
+
+FORMAT-KEY can be used to pre-select a citation format.
+
+When called with a `C-u' prefix, prompt for optional arguments in
+cite macros. When called with a numeric prefix, make that many
+citations. When called with point inside the braces of a `\\cite'
+command, it will add another key, ignoring the value of
+`reftex-cite-format'.
+
+The regular expression uses an expanded syntax: && is interpreted as `and'.
+Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
+While entering the regexp, completion on knows citation keys is possible.
+`=' is a good regular expression to match all entries in all files.
+
+\(fn &optional NO-INSERT FORMAT-KEY)" t nil)
+
+(autoload 'reftex-citep "reftex-cite" "\
+Call `reftex-citation' with a format selector `?p'.
+
+\(fn)" t nil)
+
+(autoload 'reftex-citet "reftex-cite" "\
+Call `reftex-citation' with a format selector `?t'.
+
+\(fn)" t nil)
+
+(autoload 'reftex-make-cite-echo-string "reftex-cite" "\
+Format a bibtex ENTRY for the echo area and cache the result.
+
+\(fn ENTRY DOCSTRUCT-SYMBOL)" nil nil)
+
+(autoload 'reftex-create-bibtex-file "reftex-cite" "\
+Create a new BibTeX database BIBFILE with all entries referenced in document.
+The command prompts for a filename and writes the collected
+entries to that file. Only entries referenced in the current
+document with any \\cite-like macros are used. The sequence in
+the new file is the same as it was in the old database.
+
+Entries referenced from other entries must appear after all
+referencing entries.
+
+You can define strings to be used as header or footer for the
+created files in the variables `reftex-create-bibtex-header' or
+`reftex-create-bibtex-footer' respectively.
+
+\(fn BIBFILE)" t nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-dcr" "reftex-dcr.el" "08fc5bd6c35f9d6ab4a6ad336d3769c0")
+;;; Generated autoloads from reftex-dcr.el
+
+(autoload 'reftex-view-crossref "reftex-dcr" "\
+View cross reference of macro at point. Point must be on the KEY
+argument. When at a `\\ref' macro, show corresponding `\\label'
+definition, also in external documents (`xr'). When on a label, show
+a locations where KEY is referenced. Subsequent calls find additional
+locations. When on a `\\cite', show the associated `\\bibitem' macro or
+the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro
+which uses this KEY. When on an `\\index', show other locations marked
+by the same index entry.
+To define additional cross referencing items, use the option
+`reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'.
+With one or two C-u prefixes, enforce rescanning of the document.
+With argument 2, select the window showing the cross reference.
+AUTO-HOW is only for the automatic crossref display and is handed through
+to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'.
+
+\(fn &optional ARG AUTO-HOW FAIL-QUIETLY)" t nil)
+
+(autoload 'reftex-mouse-view-crossref "reftex-dcr" "\
+View cross reference of \\ref or \\cite macro where you click.
+If the macro at point is a \\ref, show the corresponding label definition.
+If it is a \\cite, show the BibTeX database entry.
+If there is no such macro at point, search forward to find one.
+With argument, actually select the window showing the cross reference.
+
+\(fn EV)" t nil)
+
+(autoload 'reftex-toggle-auto-view-crossref "reftex-dcr" "\
+Toggle the automatic display of crossref information in the echo area.
+When active, leaving point idle in the argument of a \\ref or \\cite macro
+will display info in the echo area.
+
+\(fn)" t nil)
+
+(autoload 'reftex-view-crossref-from-bibtex "reftex-dcr" "\
+View location in a LaTeX document which cites the BibTeX entry at point.
+Since BibTeX files can be used by many LaTeX documents, this function
+prompts upon first use for a buffer in RefTeX mode. To reset this
+link to a document, call the function with a prefix arg.
+Calling this function several times find successive citation locations.
+
+\(fn &optional ARG)" t nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-global" "reftex-global.el" "5fdd9c2edced0882471f86baf4b4b234")
+;;; Generated autoloads from reftex-global.el
+
+(autoload 'reftex-create-tags-file "reftex-global" "\
+Create TAGS file by running `etags' on the current document.
+The TAGS file is also immediately visited with `visit-tags-table'.
+
+\(fn)" t nil)
+
+(autoload 'reftex-grep-document "reftex-global" "\
+Run grep query through all files related to this document.
+With prefix arg, force to rescan document.
+No active TAGS table is required.
+
+\(fn GREP-CMD)" t nil)
+
+(autoload 'reftex-search-document "reftex-global" "\
+Regexp search through all files of the current document.
+Starts always in the master file. Stops when a match is found.
+To continue searching for next match, use command \\[tags-loop-continue].
+No active TAGS table is required.
+
+\(fn &optional REGEXP)" t nil)
+
+(autoload 'reftex-query-replace-document "reftex-global" "\
+Do `query-replace-regexp' of FROM with TO over the entire document.
+Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
+If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
+with the command \\[tags-loop-continue].
+No active TAGS table is required.
+
+\(fn &optional FROM TO DELIMITED)" t nil)
+
+(autoload 'reftex-find-duplicate-labels "reftex-global" "\
+Produce a list of all duplicate labels in the document.
+
+\(fn)" t nil)
+
+(autoload 'reftex-change-label "reftex-global" "\
+Run `query-replace-regexp' of FROM with TO in all macro arguments.
+Works on the entire multifile document.
+If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
+with the command \\[tags-loop-continue].
+No active TAGS table is required.
+
+\(fn &optional FROM TO)" t nil)
+
+(autoload 'reftex-renumber-simple-labels "reftex-global" "\
+Renumber all simple labels in the document to make them sequentially.
+Simple labels are the ones created by RefTeX, consisting only of the
+prefix and a number. After the command completes, all these labels will
+have sequential numbers throughout the document. Any references to
+the labels will be changed as well. For this, RefTeX looks at the
+arguments of any macros which either start or end in the string `ref'.
+This command should be used with care, in particular in multifile
+documents. You should not use it if another document refers to this
+one with the `xr' package.
+
+\(fn)" t nil)
+
+(autoload 'reftex-save-all-document-buffers "reftex-global" "\
+Save all documents associated with the current document.
+The function is useful after a global action like replacing or renumbering
+labels.
+
+\(fn)" t nil)
+
+(autoload 'reftex-isearch-minor-mode "reftex-global" "\
+When on, isearch searches the whole document, not only the current file.
+This minor mode allows isearch to search through all the files of
+the current TeX document.
+
+With no argument, this command toggles
+`reftex-isearch-minor-mode'. With a prefix argument ARG, turn
+`reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off.
+
+\(fn &optional ARG)" t nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-index" "reftex-index.el" "29cb6e91c2e06592053e9d543f30f0ea")
+;;; Generated autoloads from reftex-index.el
+
+(autoload 'reftex-index-selection-or-word "reftex-index" "\
+Put selection or the word near point into the default index macro.
+This uses the information in `reftex-index-default-macro' to make an index
+entry. The phrase indexed is the current selection or the word near point.
+When called with one `C-u' prefix, let the user have a chance to edit the
+index entry. When called with 2 `C-u' as prefix, also ask for the index
+macro and other stuff.
+When called inside TeX math mode as determined by the `texmathp.el' library
+which is part of AUCTeX, the string is first processed with the
+`reftex-index-math-format', which see.
+
+\(fn &optional ARG PHRASE)" t nil)
+
+(autoload 'reftex-index "reftex-index" "\
+Query for an index macro and insert it along with its arguments.
+The index macros available are those defined in `reftex-index-macro' or
+by a call to `reftex-add-index-macros', typically from an AUCTeX style file.
+RefteX provides completion for the index tag and the index key, and
+will prompt for other arguments.
+
+\(fn &optional CHAR KEY TAG SEL NO-INSERT)" t nil)
+
+(autoload 'reftex-index-complete-tag "reftex-index" "\
+
+
+\(fn &optional ITAG OPT-ARGS)" nil nil)
+
+(autoload 'reftex-index-select-tag "reftex-index" "\
+
+
+\(fn)" nil nil)
+
+(autoload 'reftex-index-complete-key "reftex-index" "\
+
+
+\(fn &optional TAG OPTIONAL INITIAL)" nil nil)
+
+(autoload 'reftex-index-show-entry "reftex-index" "\
+
+
+\(fn DATA &optional NO-REVISIT)" nil nil)
+
+(autoload 'reftex-display-index "reftex-index" "\
+Display a buffer with an index compiled from the current document.
+When the document has multiple indices, first prompts for the correct one.
+When index support is turned off, offer to turn it on.
+With one or two `C-u' prefixes, rescan document first.
+With prefix 2, restrict index to current document section.
+With prefix 3, restrict index to region.
+
+\(fn &optional TAG OVERRIDING-RESTRICTION REDO &rest LOCATIONS)" t nil)
+
+(autoload 'reftex-index-phrase-selection-or-word "reftex-index" "\
+Add current selection or word at point to the phrases buffer.
+When you are in transient-mark-mode and the region is active, the
+selection will be used - otherwise the word at point.
+You get a chance to edit the entry in the phrases buffer - finish with
+`C-c C-c'.
+
+\(fn ARG)" t nil)
+
+(autoload 'reftex-index-visit-phrases-buffer "reftex-index" "\
+Switch to the phrases buffer, initialize if empty.
+
+\(fn)" t nil)
+
+(autoload 'reftex-index-phrases-mode "reftex-index" "\
+Major mode for managing the Index phrases of a LaTeX document.
+This buffer was created with RefTeX.
+
+To insert new phrases, use
+ - `C-c \\' in the LaTeX document to copy selection or word
+ - `\\[reftex-index-new-phrase]' in the phrases buffer.
+
+To index phrases use one of:
+
+\\[reftex-index-this-phrase] index current phrase
+\\[reftex-index-next-phrase] index next phrase (or N with prefix arg)
+\\[reftex-index-all-phrases] index all phrases
+\\[reftex-index-remaining-phrases] index current and following phrases
+\\[reftex-index-region-phrases] index the phrases in the region
+
+You can sort the phrases in this buffer with \\[reftex-index-sort-phrases].
+To display information about the phrase at point, use \\[reftex-index-phrases-info].
+
+For more information see the RefTeX User Manual.
+
+Here are all local bindings.
+
+\\{reftex-index-phrases-mode-map}
+
+\(fn)" t nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-parse" "reftex-parse.el" "7bfdcb2f040dbe9a08d2c38c005c8f21")
+;;; Generated autoloads from reftex-parse.el
+
+(autoload 'reftex-parse-one "reftex-parse" "\
+Re-parse this file.
+
+\(fn)" t nil)
+
+(autoload 'reftex-parse-all "reftex-parse" "\
+Re-parse entire document.
+
+\(fn)" t nil)
+
+(autoload 'reftex-do-parse "reftex-parse" "\
+Do a document rescan.
+When allowed, do only a partial scan from FILE.
+
+\(fn RESCAN &optional FILE)" nil nil)
+
+(autoload 'reftex-everything-regexp "reftex-parse" "\
+
+
+\(fn)" nil nil)
+
+(autoload 'reftex-all-document-files "reftex-parse" "\
+Return a list of all files belonging to the current document.
+When RELATIVE is non-nil, give file names relative to directory
+of master file.
+
+\(fn &optional RELATIVE)" nil nil)
+
+(autoload 'reftex-locate-bibliography-files "reftex-parse" "\
+Scan buffer for bibliography macros and return file list.
+
+\(fn MASTER-DIR &optional FILES)" nil nil)
+
+(autoload 'reftex-section-info "reftex-parse" "\
+Return a section entry for the current match.
+Careful: This function expects the match-data to be still in place!
+
+\(fn FILE)" nil nil)
+
+(autoload 'reftex-ensure-index-support "reftex-parse" "\
+When index support is turned off, ask to turn it on and
+set the current prefix argument so that `reftex-access-scan-info'
+will rescan the entire document.
+
+\(fn &optional ABORT)" nil nil)
+
+(autoload 'reftex-index-info-safe "reftex-parse" "\
+
+
+\(fn FILE)" nil nil)
+
+(autoload 'reftex-index-info "reftex-parse" "\
+Return an index entry for the current match.
+Careful: This function expects the match-data to be still in place!
+
+\(fn FILE)" nil nil)
+
+(autoload 'reftex-short-context "reftex-parse" "\
+Get about one line of useful context for the label definition at point.
+
+\(fn ENV PARSE &optional BOUND DERIVE)" nil nil)
+
+(autoload 'reftex-where-am-I "reftex-parse" "\
+Return the docstruct entry above point.
+Actually returns a cons cell in which the cdr is a flag indicating
+if the information is exact (t) or approximate (nil).
+
+\(fn)" nil nil)
+
+(autoload 'reftex-notice-new "reftex-parse" "\
+Hook to handshake with RefTeX after something new has been inserted.
+
+\(fn &optional N FORCE)" nil nil)
+
+(autoload 'reftex-what-macro-safe "reftex-parse" "\
+Call `reftex-what-macro' with special syntax table.
+
+\(fn WHICH &optional BOUND)" nil nil)
+
+(autoload 'reftex-what-macro "reftex-parse" "\
+Find out if point is within the arguments of any TeX-macro.
+The return value is either (\"\\macro\" . (point)) or a list of them.
+
+If WHICH is nil, immediately return nil.
+If WHICH is 1, return innermost enclosing macro.
+If WHICH is t, return list of all macros enclosing point.
+If WHICH is a list of macros, look only for those macros and return the
+ name of the first macro in this list found to enclose point.
+If the optional BOUND is an integer, bound backwards directed
+ searches to this point. If it is nil, limit to nearest \\section -
+ like statement.
+
+This function is pretty stable, but can be fooled if the text contains
+things like \\macro{aa}{bb} where \\macro is defined to take only one
+argument. As RefTeX cannot know this, the string \"bb\" would still be
+considered an argument of macro \\macro.
+
+\(fn WHICH &optional BOUND)" nil nil)
+
+(autoload 'reftex-what-environment "reftex-parse" "\
+Find out if point is inside a LaTeX environment.
+The return value is (e.g.) either (\"equation\" . (point)) or a list of
+them.
+
+If WHICH is nil, immediately return nil.
+If WHICH is 1, return innermost enclosing environment.
+If WHICH is t, return list of all environments enclosing point.
+If WHICH is a list of environments, look only for those environments and
+ return the name of the first environment in this list found to enclose
+ point.
+
+If the optional BOUND is an integer, bound backwards directed searches to
+this point. If it is nil, limit to nearest \\section - like statement.
+
+\(fn WHICH &optional BOUND)" nil nil)
+
+(autoload 'reftex-what-special-env "reftex-parse" "\
+Run the special environment parsers and return the matches.
+
+The return value is (e.g.) either (\"my-parser-function\" . (point))
+or a list of them.
+
+If WHICH is nil, immediately return nil.
+If WHICH is 1, return innermost enclosing environment.
+If WHICH is t, return list of all environments enclosing point.
+If WHICH is a list of environments, look only for those environments and
+ return the name of the first environment in this list found to enclose
+ point.
+
+\(fn WHICH &optional BOUND)" nil nil)
+
+(autoload 'reftex-nth-arg "reftex-parse" "\
+Return the Nth following {} or [] parentheses content.
+OPT-ARGS is a list of argument numbers which are optional.
+
+\(fn N &optional OPT-ARGS)" nil nil)
+
+(autoload 'reftex-move-over-touching-args "reftex-parse" "\
+
+
+\(fn)" nil nil)
+
+(autoload 'reftex-init-section-numbers "reftex-parse" "\
+Initialize the section numbers with zeros or with what is found in the TOC-ENTRY.
+
+\(fn &optional TOC-ENTRY APPENDIX)" nil nil)
+
+(autoload 'reftex-section-number "reftex-parse" "\
+Return a string with the current section number.
+When LEVEL is non-nil, increase section numbers on that level.
+
+\(fn &optional LEVEL STAR)" nil nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-ref" "reftex-ref.el" "86c0a243e49d55bb33a32ddac613e189")
+;;; Generated autoloads from reftex-ref.el
+
+(autoload 'reftex-label-location "reftex-ref" "\
+Return the environment or macro which determines the label type at point.
+If optional BOUND is an integer, limit backward searches to that point.
+
+\(fn &optional BOUND)" nil nil)
+
+(autoload 'reftex-label-info-update "reftex-ref" "\
+
+
+\(fn CELL)" nil nil)
+
+(autoload 'reftex-label-info "reftex-ref" "\
+
+
+\(fn LABEL &optional FILE BOUND DERIVE ENV-OR-MAC)" nil nil)
+
+(autoload 'reftex-label "reftex-ref" "\
+Insert a unique label. Return the label.
+If ENVIRONMENT is given, don't bother to find out yourself.
+If NO-INSERT is non-nil, do not insert label into buffer.
+With prefix arg, force to rescan document first.
+When you are prompted to enter or confirm a label, and you reply with
+just the prefix or an empty string, no label at all will be inserted.
+A new label is also recorded into the label list.
+This function is controlled by the settings of reftex-insert-label-flags.
+
+\(fn &optional ENVIRONMENT NO-INSERT)" t nil)
+
+(autoload 'reftex-reference "reftex-ref" "\
+Make a LaTeX reference. Look only for labels of a certain TYPE.
+With prefix arg, force to rescan buffer for labels. This should only be
+necessary if you have recently entered labels yourself without using
+reftex-label. Rescanning of the buffer can also be requested from the
+label selection menu.
+The function returns the selected label or nil.
+If NO-INSERT is non-nil, do not insert \\ref command, just return label.
+When called with 2 C-u prefix args, disable magic word recognition.
+
+\(fn &optional TYPE NO-INSERT CUT)" t nil)
+
+(autoload 'reftex-query-label-type "reftex-ref" "\
+
+
+\(fn)" nil nil)
+
+(autoload 'reftex-show-label-location "reftex-ref" "\
+
+
+\(fn DATA FORWARD NO-REVISIT &optional STAY ERROR)" nil nil)
+
+(autoload 'reftex-goto-label "reftex-ref" "\
+Prompt for a label (with completion) and jump to the location of this label.
+Optional prefix argument OTHER-WINDOW goes to the label in another window.
+
+\(fn &optional OTHER-WINDOW)" t nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-sel" "reftex-sel.el" "faea36cbe37033efd3f9063187eef7ee")
+;;; Generated autoloads from reftex-sel.el
+
+(autoload 'reftex-select-label-mode "reftex-sel" "\
+Major mode for selecting a label in a LaTeX document.
+This buffer was created with RefTeX.
+It only has a meaningful keymap when you are in the middle of a
+selection process.
+To select a label, move the cursor to it and press RET.
+Press `?' for a summary of important key bindings.
+
+During a selection process, these are the local bindings.
+
+\\{reftex-select-label-mode-map}
+
+\(fn)" t nil)
+
+(autoload 'reftex-select-bib-mode "reftex-sel" "\
+Major mode for selecting a citation key in a LaTeX document.
+This buffer was created with RefTeX.
+It only has a meaningful keymap when you are in the middle of a
+selection process.
+In order to select a citation, move the cursor to it and press RET.
+Press `?' for a summary of important key bindings.
+
+During a selection process, these are the local bindings.
+
+\\{reftex-select-label-mode-map}
+
+\(fn)" t nil)
+
+(autoload 'reftex-get-offset "reftex-sel" "\
+
+
+\(fn BUF HERE-AM-I &optional TYPEKEY TOC INDEX FILE)" nil nil)
+
+(autoload 'reftex-insert-docstruct "reftex-sel" "\
+
+
+\(fn BUF TOC LABELS INDEX-ENTRIES FILES CONTEXT COUNTER SHOW-COMMENTED HERE-I-AM XR-PREFIX TOC-BUFFER)" nil nil)
+
+(autoload 'reftex-find-start-point "reftex-sel" "\
+
+
+\(fn FALLBACK &rest LOCATIONS)" nil nil)
+
+(autoload 'reftex-select-item "reftex-sel" "\
+
+
+\(fn REFTEX-SELECT-PROMPT HELP-STRING KEYMAP &optional OFFSET CALL-BACK CB-FLAG)" nil nil)
+
+;;;***
+
+;;;### (autoloads nil "reftex-toc" "reftex-toc.el" "db9b727d89e2a6ff01986e7c6aff1058")
+;;; Generated autoloads from reftex-toc.el
+
+(autoload 'reftex-toc "reftex-toc" "\
+Show the table of contents for the current document.
+When called with a raw C-u prefix, rescan the document first.
+
+\(fn &optional REBUILD REUSE)" t nil)
+
+(autoload 'reftex-toc-recenter "reftex-toc" "\
+Display the TOC window and highlight line corresponding to current position.
+
+\(fn &optional ARG)" t nil)
+
+(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" "\
+Toggle the automatic recentering of the TOC window.
+When active, leaving point idle will make the TOC window jump to the correct
+section.
+
+\(fn)" t nil)
+
+;;;***
+
+;;; End of automatically extracted autoloads.
+
(provide 'reftex)
;;; reftex.el ends here
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 39f3acd2c4c..35eaffa9284 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -1,8 +1,9 @@
;;; remember --- a mode for quickly jotting down things to remember
-;; Copyright (C) 1999-2001, 2003-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2001, 2003-2015 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
+;; Maintainer: emacs-devel@gnu.org
;; Created: 29 Mar 1999
;; Version: 2.0
;; Keywords: data memory todo pim
@@ -118,7 +119,7 @@
;;
;; * Using "remember"
;;
-;; As a rough beginning, what I do is to keep my .notes file in
+;; As a rough beginning, what I do is to keep my `remember-data-file' in
;; outline-mode format, with a final entry called "* Raw data". Then,
;; at intervals, I can move the data that gets appended there into
;; other places. But certainly this should evolve into an intuitive
@@ -178,8 +179,6 @@
;;; Code:
-(provide 'remember)
-
(defconst remember-version "2.0"
"This version of remember.")
@@ -230,6 +229,8 @@ recorded somewhere by that function."
:type 'boolean
:group 'remember)
+;; See below for more user variables.
+
;;; Internal Variables:
(defvar remember-buffer "*Remember*"
@@ -276,7 +277,7 @@ With a prefix or a visible region, use the region as INITIAL."
transient-mark-mode))
(buffer-substring (region-beginning) (region-end)))))
(funcall (if remember-in-new-frame
- #'frame-configuration-to-register
+ #'frameset-to-register
#'window-configuration-to-register) remember-register)
(let* ((annotation
(if remember-run-all-annotation-functions-flag
@@ -294,6 +295,7 @@ With a prefix or a visible region, use the region as INITIAL."
(if remember-in-new-frame
(set-window-dedicated-p
(get-buffer-window (current-buffer) (selected-frame)) t))
+ (setq buffer-offer-save t)
(remember-mode)
(when (= (point-max) (point-min))
(when initial (insert initial))
@@ -317,9 +319,7 @@ With a prefix or a visible region, use the region as INITIAL."
(defsubst remember-mail-date (&optional rfc822-p)
"Return a simple date. Nothing fancy."
- (if rfc822-p
- (format-time-string "%a, %e %b %Y %T %z" (current-time))
- (format-time-string "%a %b %e %T %Y" (current-time))))
+ (format-time-string (if rfc822-p "%a, %e %b %Y %T %z" "%a %b %e %T %Y")))
(defun remember-buffer-desc ()
"Using the first line of the current buffer, create a short description."
@@ -385,6 +385,7 @@ Subject: %s\n\n"
"The file in which to store unprocessed data.
When set via customize, visited file of the notes buffer (if it
exists) might be changed."
+ :version "24.4" ; added locate-user-emacs-file
:type 'file
:set (lambda (symbol value)
(let ((buf (find-buffer-visiting (default-value symbol))))
@@ -440,23 +441,25 @@ If you want to remember a region, supply a universal prefix to
(remember-destroy))))
(defcustom remember-data-directory "~/remember"
- "The directory in which to store remember data as files."
+ "The directory in which to store remember data as files.
+Used by `remember-store-in-files'."
:type 'directory
:version "24.4"
:group 'remember)
(defcustom remember-directory-file-name-format "%Y-%m-%d_%T-%z"
- "Format string for the file name in which to store unprocessed data."
+ "Format string for the file name in which to store unprocessed data.
+This is passed to `format-time-string'.
+Used by `remember-store-in-files'."
:type 'string
:version "24.4"
:group 'remember)
(defun remember-store-in-files ()
"Store remember data in a file in `remember-data-directory'.
-The file is named after `remember-directory-file-name-format' fed through
-`format-time-string'."
- (let ((name (format-time-string
- remember-directory-file-name-format (current-time)))
+The file is named by calling `format-time-string' using
+`remember-directory-file-name-format' as the format string."
+ (let ((name (format-time-string remember-directory-file-name-format))
(text (buffer-string)))
(with-temp-buffer
(insert text)
@@ -493,6 +496,8 @@ If this is nil, then `diary-file' will be used instead."
:type '(choice (const :tag "diary-file" nil) file)
:group 'remember)
+(defvar calendar-date-style) ; calendar.el
+
(defun remember-diary-convert-entry (entry)
"Translate MSG to an entry readable by diary."
(save-match-data
@@ -505,23 +510,17 @@ If this is nil, then `diary-file' will be used instead."
;; which requires calendar.
(require 'calendar)
(replace-match
- (let ((style (if (boundp 'calendar-date-style)
- calendar-date-style
- ;; Don't complain about obsolescence.
- (if (with-no-warnings european-calendar-style)
- 'european
- 'american))))
- (cond ((eq style 'european)
- (concat (match-string 3 entry) "/"
- (match-string 2 entry) "/"
- (match-string 1 entry)))
- ((eq style 'iso)
- (concat (match-string 1 entry) "-"
+ (cond ((eq calendar-date-style 'european)
+ (concat (match-string 3 entry) "/"
+ (match-string 2 entry) "/"
+ (match-string 1 entry)))
+ ((eq calendar-date-style 'iso)
+ (concat (match-string 1 entry) "-"
(match-string 2 entry) "-"
(match-string 3 entry)))
- (t (concat (match-string 2 entry) "/"
- (match-string 3 entry) "/"
- (match-string 1 entry)))))
+ (t (concat (match-string 2 entry) "/"
+ (match-string 3 entry) "/"
+ (match-string 1 entry))))
t t entry))
entry)))
@@ -534,7 +533,7 @@ If this is nil, then `diary-file' will be used instead."
(goto-char (point-min))
(let (list)
(while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
- (add-to-list 'list (remember-diary-convert-entry (match-string 1))))
+ (push (remember-diary-convert-entry (match-string 1)) list))
(when list
(diary-make-entry (mapconcat 'identity list "\n")
nil remember-diary-file))
@@ -548,7 +547,7 @@ If this is nil, then `diary-file' will be used instead."
(define-key map "\C-c\C-c" 'remember-finalize)
(define-key map "\C-c\C-k" 'remember-destroy)
map)
- "Keymap used in Remember mode.")
+ "Keymap used in `remember-mode'.")
(define-derived-mode remember-mode indented-text-mode "Remember"
"Major mode for output from \\[remember].
@@ -570,20 +569,19 @@ purpose of storing notes."
:version "24.4")
(defcustom remember-notes-initial-major-mode nil
- "Major mode to set to notes buffer when it's created.
-If set to nil will use the same mode as `initial-major-mode'."
- :type '(choice (const :tag "Same as `initial-major-mode'" nil)
+ "Major mode to use in the notes buffer when it's created.
+If this is nil, use `initial-major-mode'."
+ :type '(choice (const :tag "Use `initial-major-mode'" nil)
(function :tag "Major mode" text-mode))
:version "24.4")
(defcustom remember-notes-bury-on-kill t
- "Whether to bury notes buffer instead of killing."
+ "Non-nil means `kill-buffer' will bury the notes buffer instead of killing."
:type 'boolean
:version "24.4")
(defun remember-notes-save-and-bury-buffer ()
- "Saves and buries current buffer.
-Buffer is saved only if `buffer-modified-p' returns non-nil."
+ "Save (if it is modified) and bury the current buffer."
(interactive)
(when (buffer-modified-p)
(save-buffer))
@@ -595,10 +593,14 @@ Buffer is saved only if `buffer-modified-p' returns non-nil."
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'remember-notes-save-and-bury-buffer)
map)
- "Keymap used in remember-notes mode.")
+ "Keymap used in `remember-notes-mode'.")
(define-minor-mode remember-notes-mode
- "Minor mode for the `remember-notes' buffer."
+ "Minor mode for the `remember-notes' buffer.
+This sets `buffer-save-without-query' so that `save-some-buffers' will
+save the notes buffer without asking.
+
+\\{remember-notes-mode-map}"
nil nil nil
(cond
(remember-notes-mode
@@ -608,29 +610,25 @@ Buffer is saved only if `buffer-modified-p' returns non-nil."
;;;###autoload
(defun remember-notes (&optional switch-to)
- "Creates notes buffer and switches to it if called interactively.
-
-If a notes buffer created by a previous invocation of this
-function already exist, it will be returned. Otherwise a new
-buffer will be created whose content will be read from file
-pointed by `remember-data-file'. If a buffer visiting this file
-already exist, that buffer will be used instead of creating a new
-one (see `find-file-noselect' function for more details).
-
-Name of the created buffer is taken from `remember-notes-buffer-name'
-variable and if a buffer with that name already exist (but was not
-created by this function), it will be first killed.
-\\<remember-notes-mode-map>
-`remember-notes-mode' is active in the notes buffer which by default
-contains only one \\[save-and-bury-buffer] binding which saves and
-buries the buffer.
-
-Function returns notes buffer. When called interactively,
-switches to it as well.
-
-Notes buffer is meant for keeping random notes which you'd like to
-preserve across Emacs restarts. The notes will be stored in the
-`remember-data-file'."
+ "Return the notes buffer, creating it if needed, and maybe switch to it.
+This buffer is for notes that you want to preserve across Emacs sessions.
+The notes are saved in `remember-data-file'.
+
+If a buffer is already visiting that file, just return it.
+
+Otherwise, create the buffer, and rename it to `remember-notes-buffer-name',
+unless a buffer of that name already exists. Set the major mode according
+to `remember-notes-initial-major-mode', and enable `remember-notes-mode'
+minor mode.
+
+Use \\<remember-notes-mode-map>\\[remember-notes-save-and-bury-buffer] to save and bury the notes buffer.
+
+Interactively, or if SWITCH-TO is non-nil, switch to the buffer.
+Return the buffer.
+
+Set `initial-buffer-choice' to `remember-notes' to visit your notes buffer
+when Emacs starts. Set `remember-notes-buffer-name' to \"*scratch*\"
+to turn the *scratch* buffer into your notes buffer."
(interactive "p")
(let ((buf (or (find-buffer-visiting remember-data-file)
(with-current-buffer (find-file-noselect remember-data-file)
@@ -646,10 +644,18 @@ preserve across Emacs restarts. The notes will be stored in the
buf))
(defun remember-notes--kill-buffer-query ()
+ "Function that `remember-notes-mode' adds to `kill-buffer-query-functions'.
+Save the current buffer if modified. If `remember-notes-bury-on-kill'
+is non-nil, bury it and return nil; otherwise return t."
(when (buffer-modified-p)
(save-buffer))
(if remember-notes-bury-on-kill
- (bury-buffer)
+ (progn
+ ;; bury-buffer always returns nil, but let's be explicit.
+ (bury-buffer)
+ nil)
t))
+(provide 'remember)
+
;;; remember.el ends here
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el
index a841ec39314..7b2aabd7ea5 100644
--- a/lisp/textmodes/rst.el
+++ b/lisp/textmodes/rst.el
@@ -1,6 +1,6 @@
;;; rst.el --- Mode for viewing and editing reStructuredText-documents.
-;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2015 Free Software Foundation, Inc.
;; Maintainer: Stefan Merten <smerten@oekonux.de>
;; Author: Stefan Merten <smerten@oekonux.de>,
@@ -218,7 +218,7 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match."
;; Use CVSHeader to really get information from CVS and not other version
;; control systems.
(defconst rst-cvs-header
- "$CVSHeader: sm/rst_el/rst.el,v 1.327.2.6 2012-10-07 13:05:50 stefan Exp $")
+ "$CVSHeader: sm/rst_el/rst.el,v 1.327.2.26 2015/10/04 09:26:04 stefan Exp $")
(defconst rst-cvs-rev
(rst-extract-version "\\$" "CVSHeader: \\S + " "[0-9]+\\(?:\\.[0-9]+\\)+"
" .*" rst-cvs-header "0.0")
@@ -232,22 +232,22 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no match."
;; Use LastChanged... to really get information from SVN.
(defconst rst-svn-rev
(rst-extract-version "\\$" "LastChangedRevision: " "[0-9]+" " "
- "$LastChangedRevision: 7515 $")
+ "$LastChangedRevision: 7925 $")
"The SVN revision of this file.
SVN revision is the upstream (docutils) revision.")
(defconst rst-svn-timestamp
(rst-extract-version "\\$" "LastChangedDate: " ".+?+" " "
- "$LastChangedDate: 2012-09-20 23:28:53 +0200 (Thu, 20 Sep 2012) $")
+ "$LastChangedDate: 2015-10-04 11:21:35 +0200 (Sun, 04 Oct 2015) $")
"The SVN time stamp of this file.")
;; Maintained by the release process.
(defconst rst-official-version
(rst-extract-version "%" "OfficialVersion: " "[0-9]+\\(?:\\.[0-9]+\\)+" " "
- "%OfficialVersion: 1.4.0 %")
+ "%OfficialVersion: 1.4.1 %")
"Official version of the package.")
(defconst rst-official-cvs-rev
(rst-extract-version "[%$]" "Revision: " "[0-9]+\\(?:\\.[0-9]+\\)+" " "
- "%Revision: 1.327 %")
+ "%Revision: 1.327.2.25 %")
"CVS revision of this file in the official version.")
(defconst rst-version
@@ -267,6 +267,7 @@ in parentheses follows the development revision and the time stamp.")
("1.3.0" . "24.3")
("1.3.1" . "24.3")
("1.4.0" . "24.3")
+ ("1.4.1" . "24.5")
))
(unless (assoc rst-official-version rst-package-emacs-version-alist)
@@ -296,7 +297,7 @@ in parentheses follows the development revision and the time stamp.")
;; syntax.
(defconst rst-bullets
;; Sorted so they can form a character class when concatenated.
- '(?- ?* ?+ ?\u2022 ?\u2023 ?\u2043)
+ '(?- ?* ?+ ?• ?‣ ?⁃)
"List of all possible bullet characters for bulleted lists.")
(defconst rst-uri-schemes
@@ -392,8 +393,8 @@ in parentheses follows the development revision and the time stamp.")
; item tag.
;; Inline markup (`ilm')
- (ilm-pfx (:alt "^" hws-prt "[-'\"([{<\u2018\u201c\u00ab\u2019/:]"))
- (ilm-sfx (:alt "$" hws-prt "[]-'\")}>\u2019\u201d\u00bb/:.,;!?\\]"))
+ (ilm-pfx (:alt "^" hws-prt "[-'\"([{<‘“«’/:]"))
+ (ilm-sfx (:alt "$" hws-prt "[]-'\")}>’”»/:.,;!?\\]"))
;; Inline markup content (`ilc')
(ilcsgl-tag "\\S ") ; A single non-white character.
@@ -442,7 +443,7 @@ in parentheses follows the development revision and the time stamp.")
(opt-tag (:shy optsta-tag optnam-tag optarg-tag "?")) ; A complete option.
;; Footnotes and citations (`fnc')
- (fncnam-prt "[^\]\n]") ; Part of a footnote or citation name.
+ (fncnam-prt "[^]\n]") ; Part of a footnote or citation name.
(fncnam-tag fncnam-prt "+") ; A footnote or citation name.
(fnc-tag "\\[" fncnam-tag "]") ; A complete footnote or citation tag.
(fncdef-tag-2 (:grp exm-sta)
@@ -512,7 +513,7 @@ in parentheses follows the development revision and the time stamp.")
; colon tag.
;; Comments (`cmt')
- (cmt-sta-1 (:grp exm-sta) "[^\[|_\n]"
+ (cmt-sta-1 (:grp exm-sta) "[^[|_\n]"
(:alt "[^:\n]" (:seq ":" (:alt "[^:\n]" "$")))
"*$") ; Start of a comment block; first group is explicit markup
; start.
@@ -528,7 +529,7 @@ argument list for `rst-re'.")
(defvar rst-re-alist) ; Forward declare to use it in `rst-re'.
-;; FIXME: Use `sregex` or `rx` instead of re-inventing the wheel.
+;; FIXME: Use `sregex' or `rx' instead of re-inventing the wheel.
(rst-testcover-add-compose 'rst-re)
;; testcover: ok.
(defun rst-re (&rest args)
@@ -608,20 +609,31 @@ After interpretation of ARGS the results are concatenated as for
(defun rst-define-key (keymap key def &rest deprecated)
"Bind like `define-key' but add deprecated key definitions.
KEYMAP, KEY, and DEF are as in `define-key'. DEPRECATED key
-definitions should be in vector notation. These are defined as
-well but give an additional message."
+definitions should be in vector notation. These are defined
+as well but give an additional message."
(define-key keymap key def)
- (dolist (dep-key deprecated)
- (define-key keymap dep-key
- `(lambda ()
- ,(format "Deprecated binding for %s, use \\[%s] instead." def def)
- (interactive)
- (call-interactively ',def)
- (message "[Deprecated use of key %s; use key %s instead]"
- (key-description (this-command-keys))
- (key-description ,key))))))
-
-;; Key bindings.
+ (when deprecated
+ (let* ((command-name (symbol-name def))
+ (forwarder-function-name
+ (if (string-match "^rst-\\(.*\\)$" command-name)
+ (concat "rst-deprecated-"
+ (match-string 1 command-name))
+ (error "not an RST command: %s" command-name)))
+ (forwarder-function (intern forwarder-function-name)))
+ (unless (fboundp forwarder-function)
+ (defalias forwarder-function
+ (lexical-let ((key key) (def def))
+ (lambda ()
+ (interactive)
+ (call-interactively def)
+ (message "[Deprecated use of key %s; use key %s instead]"
+ (key-description (this-command-keys))
+ (key-description key))))
+ (format "Deprecated binding for %s, use \\[%s] instead."
+ def def)))
+ (dolist (dep-key deprecated)
+ (define-key keymap dep-key forwarder-function)))))
+ ;; Key bindings.
(defvar rst-mode-map
(let ((map (make-sparse-keymap)))
@@ -767,17 +779,15 @@ This inherits from Text mode.")
(modify-syntax-entry ?\\ "\\" st)
(modify-syntax-entry ?_ "." st)
(modify-syntax-entry ?| "." st)
- (modify-syntax-entry ?\u00ab "." st)
- (modify-syntax-entry ?\u00bb "." st)
- (modify-syntax-entry ?\u2018 "." st)
- (modify-syntax-entry ?\u2019 "." st)
- (modify-syntax-entry ?\u201c "." st)
- (modify-syntax-entry ?\u201d "." st)
-
+ (modify-syntax-entry ?« "." st)
+ (modify-syntax-entry ?» "." st)
+ (modify-syntax-entry ?‘ "." st)
+ (modify-syntax-entry ?’ "." st)
+ (modify-syntax-entry ?“ "." st)
+ (modify-syntax-entry ?” "." st)
st)
"Syntax table used while in `rst-mode'.")
-
(defcustom rst-mode-hook nil
"Hook run when `rst-mode' is turned on.
The hook for `text-mode' is run before this one."
@@ -788,6 +798,8 @@ The hook for `text-mode' is run before this one."
;; Pull in variable definitions silencing byte-compiler.
(require 'newcomment)
+(defvar electric-pair-pairs)
+
;; Use rst-mode for *.rst and *.rest files. Many ReStructured-Text files
;; use *.txt, but this is too generic to be set as a default.
;;;###autoload (add-to-list 'auto-mode-alist (purecopy '("\\.re?st\\'" . rst-mode)))
@@ -849,6 +861,9 @@ highlighting.
(set (make-local-variable 'uncomment-region-function)
'rst-uncomment-region)
+ (set (make-local-variable 'electric-pair-pairs)
+ '((?\" . ?\") (?\* . ?\*) (?\` . ?\`)))
+
;; Imenu and which function.
;; FIXME: Check documentation of `which-function' for alternative ways to
;; determine the current function name.
@@ -864,7 +879,10 @@ highlighting.
(add-hook 'font-lock-extend-region-functions 'rst-font-lock-extend-region t)
;; Text after a changed line may need new fontification.
- (set (make-local-variable 'jit-lock-contextually) t))
+ (set (make-local-variable 'jit-lock-contextually) t)
+
+ ;; Indentation is not deterministic.
+ (setq electric-indent-inhibit t))
;;;###autoload
(define-minor-mode rst-minor-mode
@@ -980,10 +998,10 @@ for modes derived from Text mode, like Mail mode."
A list consisting of lists of the form (CHARACTER STYLE INDENT).
CHARACTER is the character used. STYLE is one of the symbols
-OVER-AND-UNDER or SIMPLE. INDENT is an integer giving the wanted
-indentation for STYLE OVER-AND-UNDER. CHARACTER and STYLE are
-always used when a section adornment is described. In other
-places t instead of a list stands for a transition.
+`over-and-under' or `simple'. INDENT is an integer giving the
+wanted indentation for STYLE `over-and-under'. CHARACTER and
+STYLE are always used when a section adornment is described.
+In other places, t instead of a list stands for a transition.
This sequence is consulted to offer a new adornment suggestion
when we rotate the underlines at the end of the existing
@@ -1020,8 +1038,8 @@ style."
(defun rst-compare-adornments (ado1 ado2)
"Compare adornments.
Return true if both ADO1 and ADO2 adornments are equal,
-according to restructured text semantics (only the character and
-the style are compared, the indentation does not matter)."
+according to restructured text semantics (only the character
+and the style are compared, the indentation does not matter)."
(and (eq (car ado1) (car ado2))
(eq (cadr ado1) (cadr ado2))))
@@ -1077,9 +1095,9 @@ better match."
(defun rst-update-section (char style &optional indent)
"Unconditionally update the style of a section adornment.
-Do this using the given character CHAR, with STYLE 'simple
-or 'over-and-under, and with indent INDENT. If the STYLE
-is 'simple, whitespace before the title is removed (indent
+Do this using the given character CHAR, with STYLE `simple'
+or `over-and-under', and with indent INDENT. If the STYLE
+is `simple', whitespace before the title is removed (indent
is always assumed to be 0).
If there are existing overline and/or underline from the
@@ -1256,8 +1274,8 @@ point is on a suitable title line use it.
If no title line is found return nil.
Otherwise return as `rst-classify-adornment' does. However, if
-the title line has no syntactically valid adornment STYLE is nil
-in the first element. If there is no adornment around the title
+the title line has no syntactically valid adornment, STYLE is nil
+in the first element. If there is no adornment around the title,
CHARACTER is also nil and match groups for overline and underline
are nil."
(save-excursion
@@ -1311,15 +1329,15 @@ are nil."
(defvar rst-all-sections nil
"All section adornments in the buffer as found by `rst-find-all-adornments'.
-t when no section adornments were found.")
+Set to t when no section adornments were found.")
(make-variable-buffer-local 'rst-all-sections)
;; FIXME: If this variable is set to a different value font-locking of section
;; headers is wrong.
(defvar rst-section-hierarchy nil
"Section hierarchy in the buffer as determined by `rst-get-hierarchy'.
-t when no section adornments were found. Value depends on
-`rst-all-sections'.")
+Set to t when no section adornments were found.
+Value depends on `rst-all-sections'.")
(make-variable-buffer-local 'rst-section-hierarchy)
(rst-testcover-add-1value 'rst-reset-section-caches)
@@ -1488,15 +1506,15 @@ REVERSE-DIRECTION is used to reverse the cycling order."
Adjust/rotate the section adornment for the section title around
point or promote/demote the adornments inside the region,
-depending on if the region is active. This function is meant to
-be invoked possibly multiple times, and can vary its behavior
+depending on whether the region is active. This function is meant
+to be invoked possibly multiple times, and can vary its behavior
with a positive PFXARG (toggle style), or with a negative
PFXARG (alternate behavior).
This function is a bit of a swiss knife. It is meant to adjust
the adornments of a section title in reStructuredText. It tries
-to deal with all the possible cases gracefully and to do `the
-right thing' in all cases.
+to deal with all the possible cases gracefully and to do \"the
+right thing\" in all cases.
See the documentations of `rst-adjust-adornment-work' and
`rst-promote-region' for full details.
@@ -1595,7 +1613,7 @@ The adornments consist in
1. a CHARACTER
-2. a STYLE which can be either of 'simple' or 'over-and-under'.
+2. a STYLE which can be either `simple' or `over-and-under'.
3. an INDENT (meaningful for the over-and-under style only)
which determines how many characters and over-and-under
@@ -1638,8 +1656,8 @@ Case 2: Incomplete Adornment
If the current line does have an existing adornment, but the
adornment is incomplete, that is, the underline/overline does
-not extend to exactly the end of the title line (it is either too
-short or too long), we simply extend the length of the
+not extend to exactly the end of the title line (it is either
+too short or too long), we simply extend the length of the
underlines/overlines to fit exactly the section title.
If TOGGLE-STYLE we toggle the style of the adornment as well.
@@ -1908,7 +1926,7 @@ in order to adapt it to our preferred style."
Obviously, NUM must be greater than zero. Don't blame me, blame the
Romans, I mean \"what have the Romans ever _done_ for /us/?\" (with
apologies to Monty Python).
-If optional prefix ARG is non-nil, insert in current buffer."
+If optional ARG is non-nil, insert in current buffer."
(let ((map rst-arabic-to-roman)
res)
(while (and map (> num 0))
@@ -1917,13 +1935,13 @@ If optional prefix ARG is non-nil, insert in current buffer."
(setq res (concat res (cdar map))
num (- num (caar map)))
(setq map (cdr map))))
- res))
+ (if arg (insert (or res "")) res)))
(defun rst-roman-to-arabic (string &optional arg)
"Convert STRING of Roman numerals to an Arabic number.
-If STRING contains a letter which isn't a valid Roman numeral, the rest
-of the string from that point onwards is ignored.
+If STRING contains a letter which isn't a valid Roman numeral,
+the rest of the string from that point onwards is ignored.
Hence:
MMD == 2500
@@ -1937,7 +1955,7 @@ If optional ARG is non-nil, insert in current buffer."
(setq res (+ res (caar map))
string (replace-match "" nil t string))
(setq map (cdr map))))
- res))
+ (if arg (insert res) res)))
;=================================================
(defun rst-find-pfx-in-region (beg end pfx-re)
@@ -2006,20 +2024,20 @@ Other situations are just ignored and left to users themselves."
;; FIXME: Isn't this a `defconst'?
(defvar rst-initial-items
(append (mapcar 'char-to-string rst-bullets) rst-initial-enums)
- "List of initial items. It's collection of bullets and enumerations.")
+ "List of initial items. It's a collection of bullets and enumerations.")
(defun rst-insert-list-new-item ()
"Insert a new list item.
-User is asked to select the item style first, for example (a), i), +. Use TAB
-for completion and choices.
+User is asked to select the item style first, for example (a), i), +.
+Use TAB for completion and choices.
If user selects bullets or #, it's just added with position arranged by
`rst-insert-list-pos'.
-If user selects enumerations, a further prompt is given. User need to input a
-starting item, for example 'e' for 'A)' style. The position is also arranged by
-`rst-insert-list-pos'."
+If user selects enumerations, a further prompt is given. User need to
+input a starting item, for example 'e' for 'A)' style. The position is
+also arranged by `rst-insert-list-pos'."
(interactive)
;; FIXME: Make this comply to `interactive' standards.
(let* ((itemstyle (completing-read
@@ -2121,15 +2139,15 @@ for completion and choices.
(a) If user selects bullets or #, it's just added.
(b) If user selects enumerations, a further prompt is given. User needs to
- input a starting item, for example 'e' for 'A)' style.
+ input a starting item, for example `e' for `A)' style.
The position of the new list is arranged according to whether or not the
current line and the previous line are blank lines.
-2. When continuing a list, one thing need to be noticed:
+2. When continuing a list, one thing needs to be noticed:
-List style alphabetical list, such as 'a.', and roman numerical list, such as
-'i.', have some overlapping items, for example 'v.' The function can deal with
+List style alphabetical list, such as `a.', and roman numerical list, such as
+`i.', have some overlapping items, for example `v.' The function can deal with
the problem elegantly in most situations. But when those overlapped list are
preceded by a blank line, it is hard to determine which type to use
automatically. The function uses alphabetical list by default. If you want
@@ -2257,13 +2275,11 @@ without UNPROCESSED."
"Return section containing POINT by returning the closest node in TREE.
TREE is a section tree as returned by `rst-section-tree'
consisting of (NODE CHILD...) entries. POINT defaults to the
-current point. A NODE must have the structure (IGNORED MARKER
-...).
+current point. A NODE must have the structure (IGNORED MARKER...).
Return (PATH NODE CHILD...). NODE is the node where POINT is in
if any. PATH is a list of nodes from the top of the tree down to
-and including NODE. List of CHILD are the children of NODE if
-any."
+and including NODE. List of CHILD are the children of NODE if any."
(setq point (or point (point)))
(let ((cur (car tree))
(children (cdr tree)))
@@ -2296,6 +2312,7 @@ any."
(defcustom rst-toc-indent 2
"Indentation for table-of-contents display.
Also used for formatting insertion, when numbering is disabled."
+ :type 'integer
:group 'rst-toc)
(rst-testcover-defcustom)
@@ -2303,15 +2320,20 @@ Also used for formatting insertion, when numbering is disabled."
"Insertion style for table-of-contents.
Set this to one of the following values to determine numbering and
indentation style:
-- plain: no numbering (fixed indentation)
-- fixed: numbering, but fixed indentation
-- aligned: numbering, titles aligned under each other
-- listed: numbering, with dashes like list items (EXPERIMENTAL)"
+- `plain': no numbering (fixed indentation)
+- `fixed': numbering, but fixed indentation
+- `aligned': numbering, titles aligned under each other
+- `listed': numbering, with dashes like list items (EXPERIMENTAL)"
+ :type '(choice (const plain)
+ (const fixed)
+ (const aligned)
+ (const listed))
:group 'rst-toc)
(rst-testcover-defcustom)
(defcustom rst-toc-insert-number-separator " "
"Separator that goes between the TOC number and the title."
+ :type 'string
:group 'rst-toc)
(rst-testcover-defcustom)
@@ -2324,6 +2346,7 @@ indentation style:
(defcustom rst-toc-insert-max-level nil
"If non-nil, maximum depth of the inserted TOC."
+ :type '(choice (const nil) integer)
:group 'rst-toc)
(rst-testcover-defcustom)
@@ -2363,7 +2386,7 @@ The TOC is inserted indented at the current column."
(defun rst-toc-insert-node (node level indent pfx)
"Insert tree node NODE in table-of-contents.
-Recursive function that does printing of the inserted toc.
+Recursive function that does printing of the inserted TOC.
LEVEL is the depth level of the sections in the tree.
INDENT is the indentation string. PFX is the prefix numbering,
that includes the alignment necessary for all the children of
@@ -2590,7 +2613,7 @@ brings the cursor in that section."
;; paragraph.
(defun rst-goto-section (&optional kill)
"Go to the section the current line describes.
-If KILL a toc buffer is destroyed."
+If KILL a TOC buffer is destroyed."
(interactive)
(let ((pos (rst-toc-mode-find-section)))
(when kill
@@ -2661,8 +2684,8 @@ EVENT is the input event."
(defun rst-forward-section (&optional offset)
"Skip to the next reStructuredText section title.
-OFFSET specifies how many titles to skip. Use a negative OFFSET to move
-backwards in the file (default is to use 1)."
+OFFSET specifies how many titles to skip. Use a negative OFFSET
+to move backwards in the file (default is to use 1)."
(interactive)
(rst-reset-section-caches)
(let* (;; Default value for offset.
@@ -2827,10 +2850,9 @@ first of a paragraph."
(defgroup rst-indent nil "Settings for indentation in reStructuredText.
In reStructuredText indentation points are usually determined by
-preceding lines. Sometimes the syntax allows arbitrary
-indentation points such as where to start the first line
-following a directive. These indentation widths can be customized
-here."
+preceding lines. Sometimes the syntax allows arbitrary indentation
+points such as where to start the first line following a directive.
+These indentation widths can be customized here."
:group 'rst
:package-version '(rst . "1.1.0"))
@@ -2936,11 +2958,11 @@ and not from inner alignment points."
(defun rst-compute-tabs (pt)
"Build the list of possible tabs for all lines above.
-Search backwards from point PT to build the list of possible
-tabs. Return a list of tabs sorted by likeliness to continue
-writing like `rst-line-tabs'. Nearer lines have generally a
-higher likeliness than farther lines. Return nil if no tab is found
-in the text above."
+Search backwards from point PT to build the list of possible tabs.
+Return a list of tabs sorted by likeliness to continue writing
+like `rst-line-tabs'. Nearer lines have generally a higher
+likeliness than farther lines. Return nil if no tab is found in
+the text above."
(save-excursion
(goto-char pt)
(let (leftmost ; Leftmost column found so far.
@@ -3100,7 +3122,7 @@ newlines as mandated by `comment-line-break-function'."
(defun rst-comment-region (beg end &optional arg)
"Comment or uncomment the current region.
-Region is from from BEG to END. Uncomment if ARG."
+Region is from BEG to END. Uncomment if ARG."
(save-excursion
(if (consp arg)
(rst-uncomment-region beg end arg)
@@ -3115,7 +3137,7 @@ Region is from from BEG to END. Uncomment if ARG."
(indent-line-to ind)
(insert (comment-string-strip comment-start t t))))))
-(defun rst-uncomment-region (beg end &optional arg)
+(defun rst-uncomment-region (beg end &optional _arg)
"Uncomment the current region.
Region is from BEG to END. ARG is ignored"
(save-excursion
@@ -3550,8 +3572,8 @@ of your own."
;; properties on comments and literal blocks so they are *not*
;; inline fontified. See (elisp)Search-based Fontification.
- ;; FIXME: And / or use `syntax-propertize` functions as in `octave-mod.el`
- ;; and other V24 modes. May make `font-lock-extend-region`
+ ;; FIXME: And / or use `syntax-propertize' functions as in `octave-mod.el'
+ ;; and other V24 modes. May make `font-lock-extend-region'
;; superfluous.
;; `Comments`_
@@ -3753,8 +3775,7 @@ point is not moved."
(defvar rst-font-lock-find-unindented-line-end nil
"End of the match as determined by `rst-font-lock-find-unindented-line-limit'.
-Also used as a trigger for
-`rst-font-lock-find-unindented-line-match'.")
+Also used as a trigger for `rst-font-lock-find-unindented-line-match'.")
(defun rst-font-lock-find-unindented-line-limit (ind-pnt)
"Find the next unindented line relative to indentation at IND-PNT.
@@ -3762,8 +3783,7 @@ Return this point, the end of the buffer or nil if nothing found.
If IND-PNT is `next' take the indentation from the next line if
this is not empty and indented more than the current one. If
IND-PNT is non-nil but not a number take the indentation from the
-next non-empty line if this is indented more than the current
-one."
+next non-empty line if this is indented more than the current one."
(setq rst-font-lock-find-unindented-line-begin ind-pnt)
(setq rst-font-lock-find-unindented-line-end
(save-excursion
@@ -3803,12 +3823,11 @@ one."
(or (rst-forward-indented-block nil (point-max))
(point-max))))))
-(defun rst-font-lock-find-unindented-line-match (limit)
+(defun rst-font-lock-find-unindented-line-match (_limit)
"Set the match found earlier if match were found.
-Match has been found by
-`rst-font-lock-find-unindented-line-limit' the first time called
-or no match is found. Return non-nil if match was found. LIMIT
-is not used but mandated by the caller."
+Match has been found by `rst-font-lock-find-unindented-line-limit'
+the first time called or no match is found. Return non-nil if
+match was found. LIMIT is not used but mandated by the caller."
(when rst-font-lock-find-unindented-line-end
(set-match-data
(list rst-font-lock-find-unindented-line-begin
@@ -3829,10 +3848,9 @@ Either section level of the current adornment or t for a transition.")
(defun rst-adornment-level (key)
"Return section level for adornment KEY.
-KEY is the first element of the return list of
-`rst-classify-adornment'. If KEY is not a cons return it. If KEY is found
-in the hierarchy return its level. Otherwise return a level one
-beyond the existing hierarchy."
+KEY is the first element of the return list of `rst-classify-adornment'.
+If KEY is not a cons return it. If KEY is found in the hierarchy return
+its level. Otherwise return a level one beyond the existing hierarchy."
(if (not (consp key))
key
(let* ((hier (rst-get-hierarchy))
@@ -3854,9 +3872,8 @@ as a trigger for `rst-font-lock-handle-adornment-matcher'.")
(defun rst-font-lock-handle-adornment-pre-match-form (ado ado-end)
"Determine limit for adornments.
Determine all things necessary for font-locking section titles
-and transitions and put the result to
-`rst-font-lock-adornment-match' and
-`rst-font-lock-adornment-level'. ADO is the complete adornment
+and transitions and put the result to `rst-font-lock-adornment-match'
+and `rst-font-lock-adornment-level'. ADO is the complete adornment
matched. ADO-END is the point where ADO ends. Return the point
where the whole adorned construct ends.
@@ -3871,7 +3888,7 @@ Called as a PRE-MATCH-FORM in the sense of `font-lock-keywords'."
(goto-char (nth 1 ado-data)) ; Beginning of construct.
(nth 2 ado-data)))) ; End of construct.
-(defun rst-font-lock-handle-adornment-matcher (limit)
+(defun rst-font-lock-handle-adornment-matcher (_limit)
"Set the match found earlier if match were found.
Match has been found by
`rst-font-lock-handle-adornment-pre-match-form' the first time
@@ -3936,11 +3953,11 @@ string)) to be used for converting the document."
:package-version "1.2.0")
(rst-testcover-defcustom)
-;; FIXME: Must be `defcustom`.
+;; FIXME: Must be defcustom.
(defvar rst-compile-primary-toolset 'html
"The default tool-set for `rst-compile'.")
-;; FIXME: Must be `defcustom`.
+;; FIXME: Must be defcustom.
(defvar rst-compile-secondary-toolset 'latex
"The default tool-set for `rst-compile' with a prefix argument.")
@@ -3968,7 +3985,7 @@ string)) to be used for converting the document."
(defun rst-compile (&optional use-alt)
"Compile command to convert reST document into some output file.
Attempts to find configuration file, if it can, overrides the
-options. There are two commands to choose from, with USE-ALT,
+options. There are two commands to choose from; with USE-ALT,
select the alternative tool-set."
(interactive "P")
;; Note: maybe we want to check if there is a Makefile too and not do anything
@@ -4019,7 +4036,7 @@ buffer, if the region is not selected."
(cadr (assq 'pseudoxml rst-compile-toolsets))
standard-output)))
-;; FIXME: Should be `defcustom`.
+;; FIXME: Should be defcustom.
(defvar rst-pdf-program "xpdf"
"Program used to preview PDF files.")
@@ -4036,7 +4053,7 @@ buffer, if the region is not selected."
;; output.
))
-;; FIXME: Should be `defcustom` or use something like `browse-url`.
+;; FIXME: Should be defcustom or use something like `browse-url'.
(defvar rst-slides-program "firefox"
"Program used to preview S5 slides.")
@@ -4073,7 +4090,7 @@ buffer, if the region is not selected."
a))
(defun rst-imenu-convert-cell (elt adornments)
- "Convert a cell ELT in a tree returned from `rst-section-tree' to imenu index.
+ "Convert a cell ELT in a tree returned from `rst-section-tree' to Imenu index.
ADORNMENTS is used as hint information for conversion."
(let* ((kar (car elt))
(kdr (cdr elt))
@@ -4107,7 +4124,7 @@ ADORNMENTS is used as hint information for conversion."
;; FIXME: Document title and subtitle need to be handled properly. They should
;; get an own "Document" top level entry.
(defun rst-imenu-create-index ()
- "Create index for imenu.
+ "Create index for Imenu.
Return as described for `imenu--index-alist'."
(rst-reset-section-caches)
(let ((tree (rst-section-tree))
@@ -4145,7 +4162,7 @@ cand replace with char: ")
(let ((width (current-column)))
(rst-delete-entire-line)
(insert-char tochar width)))
- (message (format "%d lines replaced." found)))))
+ (message "%d lines replaced." found))))
;; FIXME: Unbound command - should be bound or removed.
(defun rst-join-paragraph ()
@@ -4169,8 +4186,8 @@ This is useful for filling list item paragraphs."
;; be useful for creating separators.
(defun rst-repeat-last-character (use-next)
"Fill the current line using the last character on the current line.
-Fill up to the length of the preceding line or up to
-`fill-column' if preceding line is empty.
+Fill up to the length of the preceding line or up to `fill-column' if preceding
+line is empty.
If USE-NEXT, use the next line rather than the preceding line.
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 33dfa277330..55a1e6d26db 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1,10 +1,10 @@
-;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: utf-8 -*-
+;;; sgml-mode.el --- SGML- and HTML-editing modes -*- lexical-binding:t -*-
-;; Copyright (C) 1992, 1995-1996, 1998, 2001-2013 Free Software
+;; Copyright (C) 1992, 1995-1996, 1998, 2001-2015 Free Software
;; Foundation, Inc.
;; Author: James Clark <jjc@jclark.com>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Adapted-By: ESR, Daniel Pfeiffer <occitan@esperanto.org>,
;; F.Potorti@cnuce.cnr.it
;; Keywords: wp, hypermedia, comm, languages
@@ -46,6 +46,25 @@
:type 'integer
:group 'sgml)
+(defcustom sgml-attribute-offset 0
+ "Specifies a delta for attribute indentation in `sgml-indent-line'.
+
+When 0, attribute indentation looks like this:
+
+ <element
+ attribute=\"value\">
+ </element>
+
+When 2, attribute indentation looks like this:
+
+ <element
+ attribute=\"value\">
+ </element>"
+ :version "25.1"
+ :type 'integer
+ :safe 'integerp
+ :group 'sgml)
+
(defcustom sgml-xml-mode nil
"When non-nil, tag insertion functions will be XML-compliant.
It is set to be buffer-local when the file has
@@ -87,10 +106,10 @@ This list is used when first loading the `sgml-mode' library.
The supported characters and potential disadvantages are:
?\\\" Makes \" in text start a string.
- ?' Makes ' in text start a string.
+ ?\\=' Makes \\=' in text start a string.
?- Makes -- in text start a comment.
-When only one of ?\\\" or ?' are included, \"'\" or '\"', as can be found in
+When only one of ?\\\" or ?\\=' are included, \"\\='\" or \\='\"\\=', as can be found in
DTDs, start a string. To partially avoid this problem this also makes these
self insert as named entities depending on `sgml-quick-keys'.
@@ -240,12 +259,21 @@ This takes effect when first loading the `sgml-mode' library.")
"A table for mapping non-ASCII characters into SGML entity names.
Currently, only Latin-1 characters are supported.")
-;; nsgmls is a free SGML parser in the SP suite available from
-;; ftp.jclark.com and otherwise packaged for GNU systems.
-;; Its error messages can be parsed by next-error.
-;; The -s option suppresses output.
-
-(defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
+(defcustom sgml-validate-command
+ ;; prefer tidy because (o)nsgmls is often built without --enable-http
+ ;; which makes it next to useless
+ (cond ((executable-find "tidy")
+ ;; tidy is available from http://tidy.sourceforge.net/
+ "tidy --gnu-emacs yes -utf8 -e -q")
+ ((executable-find "nsgmls")
+ ;; nsgmls is a free SGML parser in the SP suite available from
+ ;; ftp.jclark.com, replaced old `sgmls'.
+ "nsgmls -s")
+ ((executable-find "onsgmls")
+ ;; onsgmls is the community version of `nsgmls'
+ ;; hosted on http://openjade.sourceforge.net/
+ "onsgmls -s")
+ (t "Install (o)nsgmls, tidy, or some other SGML validator, and set `sgml-validate-command'"))
"The command to validate an SGML document.
The file name of current buffer file name will be appended to this,
separated by a space."
@@ -414,7 +442,7 @@ an optional alist of possible values."
(comment-style 'plain))
(comment-indent-new-line soft)))
-(defun sgml-mode-facemenu-add-face-function (face end)
+(defun sgml-mode-facemenu-add-face-function (face _end)
(let ((tag-face (cdr (assq face sgml-face-tag-alist))))
(cond (tag-face
(setq tag-face (funcall skeleton-transformation-function tag-face))
@@ -447,18 +475,21 @@ This function is designed for use in `fill-nobreak-predicate'.
(skip-chars-backward "/?!")
(eq (char-before) ?<))))
+(defvar tildify-space-string)
+(defvar tildify-foreach-region-function)
+
;;;###autoload
(define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")
"Major mode for editing SGML documents.
Makes > match <.
-Keys <, &, SPC within <>, \", / and ' can be electric depending on
+Keys <, &, SPC within <>, \", / and \\=' can be electric depending on
`sgml-quick-keys'.
An argument of N to a tag-inserting command means to wrap it around
the next N words. In Transient Mark mode, when the mark is active,
N defaults to -1, which means to wrap it around the current region.
-If you like upcased tags, put (setq sgml-transformation-function 'upcase)
+If you like upcased tags, put (setq sgml-transformation-function \\='upcase)
in your init file.
Use \\[sgml-validate] to validate your document with an SGML parser.
@@ -468,12 +499,33 @@ Do \\[describe-key] on the following bindings to discover what they do.
\\{sgml-mode-map}"
(make-local-variable 'sgml-saved-validate-command)
(make-local-variable 'facemenu-end-add-face)
+ ;; If encoding does not allow non-break space character, use reference.
+ ;; FIXME: Perhaps use &nbsp; if possible (e.g. when we know its HTML)?
+ (setq-local tildify-space-string
+ (if (equal (decode-coding-string
+ (encode-coding-string " " buffer-file-coding-system)
+ buffer-file-coding-system) " ")
+ " " "&#160;"))
+ ;; FIXME: Use the fact that we're parsing the document already
+ ;; rather than using regex-based filtering.
+ (setq-local tildify-foreach-region-function
+ (apply-partially
+ 'tildify-foreach-ignore-environments
+ `((,(eval-when-compile
+ (concat
+ "<\\("
+ (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var"
+ "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR"))
+ "\\)\\>[^>]*>"))
+ . ("</" 1 ">"))
+ ("<! *--" . "-- *>")
+ ("<" . ">"))))
;;(make-local-variable 'facemenu-remove-face-function)
;; A start or end tag by itself on a line separates a paragraph.
;; This is desirable because SGML discards a newline that appears
;; immediately after a start tag or immediately before an end tag.
(setq-local paragraph-start (concat "[ \t]*$\\|\
-\[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
+[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
(setq-local paragraph-separate (concat paragraph-start "$"))
(setq-local adaptive-fill-regexp "[ \t]*")
(add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t)
@@ -707,9 +759,10 @@ If QUIET, do not print a message when there are no attributes for TAG."
(insert ?\s)
(insert (funcall skeleton-transformation-function
(setq attribute
- (skeleton-read '(completing-read
- "Attribute: "
- alist)))))
+ (skeleton-read (lambda ()
+ (completing-read
+ "Attribute: "
+ alist))))))
(if (string= "" attribute)
(setq i 0)
(sgml-value (assoc (downcase attribute) alist))
@@ -792,7 +845,7 @@ Return non-nil if we skipped over matched tags."
(defvar sgml-electric-tag-pair-overlays nil)
(defvar sgml-electric-tag-pair-timer nil)
-(defun sgml-electric-tag-pair-before-change-function (beg end)
+(defun sgml-electric-tag-pair-before-change-function (_beg end)
(condition-case err
(save-excursion
(goto-char end)
@@ -960,7 +1013,7 @@ With prefix argument ARG, repeat this ARG times."
(or (get 'sgml-tag 'invisible)
(setplist 'sgml-tag
(append '(invisible t
- point-entered sgml-point-entered
+ cursor-sensor-functions (sgml-cursor-sensor)
rear-nonsticky t
read-only t)
(symbol-plist 'sgml-tag))))
@@ -968,63 +1021,59 @@ With prefix argument ARG, repeat this ARG times."
(defun sgml-tags-invisible (arg)
"Toggle visibility of existing tags."
(interactive "P")
- (let ((modified (buffer-modified-p))
- (inhibit-read-only t)
- (inhibit-modification-hooks t)
- ;; Avoid spurious the `file-locked' checks.
- (buffer-file-name nil)
- ;; This is needed in case font lock gets called,
- ;; since it moves point and might call sgml-point-entered.
- ;; How could it get called? -stef
- (inhibit-point-motion-hooks t)
+ (let ((inhibit-read-only t)
string)
- (unwind-protect
- (save-excursion
- (goto-char (point-min))
- (if (setq-local sgml-tags-invisible
- (if arg
- (>= (prefix-numeric-value arg) 0)
- (not sgml-tags-invisible)))
- (while (re-search-forward sgml-tag-name-re nil t)
- (setq string
- (cdr (assq (intern-soft (downcase (match-string 1)))
- sgml-display-text)))
- (goto-char (match-beginning 0))
- (and (stringp string)
- (not (overlays-at (point)))
- (let ((ol (make-overlay (point) (match-beginning 1))))
- (overlay-put ol 'before-string string)
- (overlay-put ol 'sgml-tag t)))
- (put-text-property (point)
- (progn (forward-list) (point))
- 'category 'sgml-tag))
- (let ((pos (point-min)))
- (while (< (setq pos (next-overlay-change pos)) (point-max))
- (dolist (ol (overlays-at pos))
- (if (overlay-get ol 'sgml-tag)
- (delete-overlay ol)))))
- (remove-text-properties (point-min) (point-max) '(category nil))))
- (restore-buffer-modified-p modified))
+ (with-silent-modifications
+ (save-excursion
+ (goto-char (point-min))
+ (if (setq-local sgml-tags-invisible
+ (if arg
+ (>= (prefix-numeric-value arg) 0)
+ (not sgml-tags-invisible)))
+ (while (re-search-forward sgml-tag-name-re nil t)
+ (setq string
+ (cdr (assq (intern-soft (downcase (match-string 1)))
+ sgml-display-text)))
+ (goto-char (match-beginning 0))
+ (and (stringp string)
+ (not (overlays-at (point)))
+ (let ((ol (make-overlay (point) (match-beginning 1))))
+ (overlay-put ol 'before-string string)
+ (overlay-put ol 'sgml-tag t)))
+ (put-text-property (point)
+ (progn (forward-list) (point))
+ 'category 'sgml-tag))
+ (let ((pos (point-min)))
+ (while (< (setq pos (next-overlay-change pos)) (point-max))
+ (dolist (ol (overlays-at pos))
+ (if (overlay-get ol 'sgml-tag)
+ (delete-overlay ol)))))
+ (remove-text-properties (point-min) (point-max) '(category nil)))))
+ (cursor-sensor-mode (if sgml-tags-invisible 1 -1))
(run-hooks 'sgml-tags-invisible-hook)
(message "")))
-(defun sgml-point-entered (x y)
- ;; Show preceding or following hidden tag, depending of cursor direction.
- (let ((inhibit-point-motion-hooks t))
- (save-excursion
- (condition-case nil
- (message "Invisible tag: %s"
- ;; Strip properties, otherwise, the text is invisible.
- (buffer-substring-no-properties
- (point)
- (if (or (and (> x y)
- (not (eq (following-char) ?<)))
- (and (< x y)
- (eq (preceding-char) ?>)))
- (backward-list)
- (forward-list))))
- (error nil)))))
-
+(defun sgml-cursor-sensor (window x dir)
+ ;; Show preceding or following hidden tag, depending of cursor direction (and
+ ;; `dir' is not the direction in this sense).
+ (when (eq dir 'entered)
+ (ignore-errors
+ (let* ((y (window-point window))
+ (otherend
+ (save-excursion
+ (goto-char y)
+ (cond
+ ((and (eq (char-before) ?>)
+ (or (not (eq (char-after) ?<))
+ (> x y)))
+ (backward-sexp))
+ ((eq (char-after y) ?<)
+ (forward-sexp)))
+ (point))))
+ (message "Invisible tag: %s"
+ ;; Strip properties, otherwise, the text is invisible.
+ (buffer-substring-no-properties
+ y otherend))))))
(defun sgml-validate (command)
@@ -1106,7 +1155,7 @@ If nil, start from a preceding tag at indentation."
((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
(t (cons 'text text-start))))))
-(defun sgml-beginning-of-tag (&optional top-level)
+(defun sgml-beginning-of-tag (&optional only-immediate)
"Skip to beginning of tag and return its name.
If this can't be done, return nil."
(let ((context (sgml-lexical-context)))
@@ -1115,7 +1164,7 @@ If this can't be done, return nil."
(goto-char (cdr context))
(when (looking-at sgml-tag-name-re)
(match-string-no-properties 1)))
- (if top-level nil
+ (if only-immediate nil
(when (not (eq (car context) 'text))
(goto-char (cdr context))
(sgml-beginning-of-tag t))))))
@@ -1129,13 +1178,16 @@ See `sgml-tag-alist' for info about attribute rules."
(if (and (eq (car alist) t) (not sgml-xml-mode))
(when (cdr alist)
(insert "=\"")
- (setq alist (skeleton-read '(completing-read "Value: " (cdr alist))))
+ (setq alist (skeleton-read (lambda ()
+ (completing-read
+ "Value: " (cdr alist)))))
(if (string< "" alist)
(insert alist ?\")
(delete-char -2)))
(insert "=\"")
(if (cdr alist)
- (insert (skeleton-read '(completing-read "Value: " alist)))
+ (insert (skeleton-read (lambda ()
+ (completing-read "Value: " alist))))
(when (null alist)
(insert (skeleton-read '(read-string "Value: ")))))
(insert ?\"))))
@@ -1477,13 +1529,13 @@ LCON is the lexical context, if any."
(`pi nil)
(`tag
- (goto-char (1+ (cdr lcon)))
+ (goto-char (+ (cdr lcon) sgml-attribute-offset))
(skip-chars-forward "^ \t\n") ;Skip tag name.
(skip-chars-forward " \t")
(if (not (eolp))
(current-column)
;; This is the first attribute: indent.
- (goto-char (1+ (cdr lcon)))
+ (goto-char (+ (cdr lcon) sgml-attribute-offset))
(+ (current-column) sgml-basic-offset)))
(`text
@@ -1529,6 +1581,19 @@ LCON is the lexical context, if any."
(skip-chars-forward " \t\n")
(< (point) here) (sgml-at-indentation-p))
(current-column))
+ ;; ;; If the parsing failed, try to recover.
+ ;; ((and (null context) (bobp)
+ ;; (not (eq (char-after here) ?<)))
+ ;; (goto-char here)
+ ;; (if (and (looking-at "--[ \t\n]*>")
+ ;; (re-search-backward "<!--" nil t))
+ ;; ;; No wonder parsing failed: we're in a comment.
+ ;; (sgml-calculate-indent (prog2 (goto-char (match-end 0))
+ ;; (sgml-lexical-context)
+ ;; (goto-char here)))
+ ;; ;; We have no clue what's going on, let's be honest about it.
+ ;; nil))
+ ;; Otherwise, just follow the rules.
(t
(goto-char there)
(+ (current-column)
@@ -1767,6 +1832,8 @@ This takes effect when first loading the library.")
("array" (nil \n
("Item: " "<item>" str (if sgml-xml-mode "</item>") \n))
"align")
+ ("article" \n)
+ ("aside" \n)
("au")
("b")
("big")
@@ -1792,7 +1859,10 @@ This takes effect when first loading the library.")
"<dd>" (if sgml-xml-mode "</dd>") \n))
("em")
("fn" "id" "fn") ;; Footnotes were deprecated in HTML 3.2
+ ("footer" \n)
("head" \n)
+ ("header" \n)
+ ("hgroup" \n)
("html" (\n
"<head>\n"
"<title>" (setq str (read-input "Title: ")) "</title>\n"
@@ -1810,6 +1880,7 @@ This takes effect when first loading the library.")
("lang")
("li" ,(not sgml-xml-mode))
("math" \n)
+ ("nav" \n)
("nobr")
("option" t ("value") ("label") ("selected" t))
("over" t)
@@ -1819,6 +1890,7 @@ This takes effect when first loading the library.")
("rev")
("s")
("samp")
+ ("section" \n)
("small")
("span" nil
("class"
@@ -1849,6 +1921,8 @@ This takes effect when first loading the library.")
("acronym" . "Acronym")
("address" . "Formatted mail address")
("array" . "Math array")
+ ("article" . "An independent part of document or site")
+ ("aside" . "Secondary content related to surrounding content (e.g. page or article)")
("au" . "Author")
("b" . "Bold face")
("base" . "Base address for URLs")
@@ -1878,6 +1952,7 @@ This takes effect when first loading the library.")
("figt" . "Figure text")
("fn" . "Footnote") ;; No one supports special footnote rendering.
("font" . "Font size")
+ ("footer" . "Footer of a section")
("form" . "Form with input fields")
("group" . "Document grouping")
("h1" . "Most important section headline")
@@ -1887,6 +1962,8 @@ This takes effect when first loading the library.")
("h5" . "Unimportant section headline")
("h6" . "Least important section headline")
("head" . "Document header")
+ ("header" . "Header of a section")
+ ("hgroup" . "Group of headings - h1-h6 elements")
("hr" . "Horizontal rule")
("html" . "HTML Document")
("i" . "Italic face")
@@ -1899,8 +1976,9 @@ This takes effect when first loading the library.")
("li" . "List item")
("link" . "Link relationship")
("math" . "Math formula")
- ("menu" . "Menu list (obsolete)")
+ ("menu" . "List of commands")
("mh" . "Form mail header")
+ ("nav" . "Group of navigational links")
("nextid" . "Allocate new id")
("nobr" . "Text without line break")
("ol" . "Ordered list")
@@ -1914,6 +1992,7 @@ This takes effect when first loading the library.")
("rev" . "Reverse video")
("s" . "Strikeout")
("samp" . "Sample text")
+ ("section" . "Section of a document")
("select" . "Selection list")
("small" . "Font size")
("sp" . "Nobreak space")
@@ -1987,7 +2066,7 @@ Images in many formats can be inlined with <img src=\"URL\">.
If you mainly create your own documents, `sgml-specials' might be
interesting. But note that some HTML 2 browsers can't handle `&apos;'.
To work around that, do:
- (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
+ (eval-after-load \"sgml-mode\" \\='(aset sgml-char-names ?\\=' nil))
\\{html-mode-map}"
(setq-local sgml-display-text html-display-text)
@@ -2181,6 +2260,33 @@ HTML Autoview mode is a buffer-local minor mode for use with
"")))
\n))
+(define-skeleton html-navigational-links
+ "Group of navigational links."
+ nil
+ "<nav>" \n
+ "<ul>" \n
+ "<li><a href=\"" (skeleton-read "URL: " "#") "\">"
+ (skeleton-read "Title: ") "</a>"
+ (if sgml-xml-mode (if sgml-xml-mode "</li>")) \n
+ "</ul>" \n
+ "</nav>")
+
+(define-skeleton html-html5-template
+ "Initial HTML5 template"
+ nil
+ "<!DOCTYPE html>" \n
+ "<html lang=\"en\">" \n
+ "<head>" \n
+ "<meta charset=\"utf-8\">" \n
+ "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">" \n
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">" \n
+ "<title>" (skeleton-read "Page Title: ") "</title>" \n
+ "</head>" \n
+ "<body>" \n
+ "<div id=\"app\"></div>" \n
+ "</body>" \n
+ "</html>")
+
(provide 'sgml-mode)
;;; sgml-mode.el ends here
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 4d8a74323c7..151d64808af 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -1,6 +1,6 @@
;;; table.el --- create and edit WYSIWYG text based embedded tables -*- lexical-binding: t -*-
-;; Copyright (C) 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
;; Keywords: wp, convenience
;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
@@ -559,7 +559,7 @@
;; Todo: (in the order of priority, some are just possibility)
;; -----
;;
-;; Fix compatibilities with other input method than quail
+;; Fix incompatibilities with input methods other than quail
;; Resolve conflict with flyspell
;; Use mouse for resizing cells
;; A mechanism to link cells internally
@@ -770,7 +770,6 @@ the cell contents dynamically."
:type 'integer
:group 'table)
-;;;###autoload
(defcustom table-cell-map-hook nil
"Normal hooks run when finishing construction of `table-cell-map'.
User can modify `table-cell-map' by adding custom functions here."
@@ -794,19 +793,16 @@ simply by any key input."
:type 'boolean
:group 'table)
-;;;###autoload
(defcustom table-load-hook nil
"List of functions to be called after the table is first loaded."
:type 'hook
:group 'table-hooks)
-;;;###autoload
(defcustom table-point-entered-cell-hook nil
"List of functions to be called after point entered a table cell."
:type 'hook
:group 'table-hooks)
-;;;###autoload
(defcustom table-point-left-cell-hook nil
"List of functions to be called after point left a table cell."
:type 'hook
@@ -865,8 +861,6 @@ time.")
"Cache point coordinate based from the cell origin.")
(defvar table-cell-cache-mark-coordinate nil
"Cache mark coordinate based from the cell origin.")
-(defvar table-cell-entered-state nil
- "Records the state whether currently in a cell or nor.")
(defvar table-update-timer nil
"Timer id for deferred cell update.")
(defvar table-widen-timer nil
@@ -1216,14 +1210,14 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu
;; does not cause a problem in the old implementation. Sigh...
(when (featurep 'xemacs)
(defun table--tweak-menu-for-xemacs (menu)
- (cond
- ((listp menu)
- (mapcar #'table--tweak-menu-for-xemacs menu))
- ((vectorp menu)
- (let ((len (length menu)))
- (dotimes (i len)
- ;; replace :help with something harmless.
- (if (eq (aref menu i) :help) (aset menu i :included)))))))
+ (cond
+ ((listp menu)
+ (mapcar #'table--tweak-menu-for-xemacs menu))
+ ((vectorp menu)
+ (let ((len (length menu)))
+ (dotimes (i len)
+ ;; replace :help with something harmless.
+ (if (eq (aref menu i) :help) (aset menu i :included)))))))
(mapcar #'table--tweak-menu-for-xemacs
(list table-global-menu table-cell-menu))
(defvar mark-active t))
@@ -1899,7 +1893,9 @@ all the table specific features."
(while (and (re-search-forward border3 (point-max) t)
(not (and (input-pending-p)
table-abort-recognition-when-input-pending)))
- (message "Recognizing tables...(%d%%)" (/ (* 100 (match-beginning 0)) (- (point-max) (point-min))))
+ (message "Recognizing tables...(%d%%)"
+ (floor (* 100.0 (match-beginning 0))
+ (- (point-max) (point-min))))
(let ((beg (match-beginning 0))
end)
(if (re-search-forward non-border (point-max) t)
@@ -2810,8 +2806,8 @@ ORIENTATION is a symbol either horizontally or vertically."
;;;###autoload
(defun table-justify (what justify)
"Justify contents of a cell, a row of cells or a column of cells.
-WHAT is a symbol 'cell, 'row or 'column. JUSTIFY is a symbol 'left,
-'center, 'right, 'top, 'middle, 'bottom or 'none."
+WHAT is a symbol `cell', `row' or `column'. JUSTIFY is a symbol
+`left', `center', `right', `top', `middle', `bottom' or `none'."
(interactive
(list (let* ((_ (barf-if-buffer-read-only))
(completion-ignore-case t)
@@ -2826,8 +2822,8 @@ WHAT is a symbol 'cell, 'row or 'column. JUSTIFY is a symbol 'left,
;;;###autoload
(defun table-justify-cell (justify &optional paragraph)
"Justify cell contents.
-JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or 'top,
-'middle, 'bottom or 'none for vertical. When optional PARAGRAPH is
+JUSTIFY is a symbol `left', `center' or `right' for horizontal, or `top',
+`middle', `bottom' or `none' for vertical. When optional PARAGRAPH is
non-nil the justify operation is limited to the current paragraph,
otherwise the entire cell contents is justified."
(interactive
@@ -2839,8 +2835,8 @@ otherwise the entire cell contents is justified."
;;;###autoload
(defun table-justify-row (justify)
"Justify cells of a row.
-JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
-'middle, 'bottom or 'none for vertical."
+JUSTIFY is a symbol `left', `center' or `right' for horizontal,
+or `top', `middle', `bottom' or `none' for vertical."
(interactive
(list (table--query-justification)))
(let((cell-list (table--horizontal-cell-list nil nil 'top)))
@@ -2856,8 +2852,8 @@ JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
;;;###autoload
(defun table-justify-column (justify)
"Justify cells of a column.
-JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
-'middle, 'bottom or 'none for vertical."
+JUSTIFY is a symbol `left', `center' or `right' for horizontal,
+or `top', `middle', `bottom' or `none' for vertical."
(interactive
(list (table--query-justification)))
(let((cell-list (table--vertical-cell-list nil nil 'left)))
@@ -3345,25 +3341,25 @@ INTERVAL is the number of cells to travel between sequence element
insertion which is normally 1. When zero or less is given for
INTERVAL it is interpreted as number of cells per row so that sequence
is placed straight down vertically as long as the table's cell
-structure is uniform. JUSTIFY is one of the symbol 'left, 'center or
-'right, that specifies justification of the inserted string.
+structure is uniform. JUSTIFY is a symbol `left', `center' or
+`right' that specifies justification of the inserted string.
Example:
(progn
(table-insert 16 3 5 1)
(table-forward-cell 15)
- (table-insert-sequence \"D0\" -16 1 1 'center)
+ (table-insert-sequence \"D0\" -16 1 1 \\='center)
(table-forward-cell 16)
- (table-insert-sequence \"A[0]\" -16 1 1 'center)
+ (table-insert-sequence \"A[0]\" -16 1 1 \\='center)
(table-forward-cell 1)
- (table-insert-sequence \"-\" 16 0 1 'center))
+ (table-insert-sequence \"-\" 16 0 1 \\='center))
(progn
(table-insert 16 8 5 1)
- (table-insert-sequence \"@\" 0 1 2 'right)
+ (table-insert-sequence \"@\" 0 1 2 \\='right)
(table-forward-cell 1)
- (table-insert-sequence \"64\" 0 1 2 'left))"
+ (table-insert-sequence \"64\" 0 1 2 \\='left))"
(interactive
(progn
(barf-if-buffer-read-only)
@@ -4465,8 +4461,8 @@ looking at the appearance of the CELL contents."
(defun table--justify-cell-contents (justify &optional paragraph)
"Justify the current cell contents.
-JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or 'top,
-'middle, 'bottom or 'none for vertical. When PARAGRAPH is non-nil the
+JUSTIFY is a symbol `left', `center' or `right' for horizontal, or `top',
+`middle', `bottom' or `none' for vertical. When PARAGRAPH is non-nil the
justify operation is limited to the current paragraph."
(table-with-cache-buffer
(let ((beg (point-min))
@@ -5187,8 +5183,8 @@ and the right cell border character."
(defun table--put-cell-point-entered/left-property (beg end &optional object)
"Put point-entered/left property."
- (put-text-property beg end 'point-entered 'table--point-entered-cell-function object)
- (put-text-property beg end 'point-left 'table--point-left-cell-function object))
+ (put-text-property beg end 'cursor-sensor-functions
+ '(table--point-entered/left-cell-function) object))
(defun table--remove-cell-properties (beg end &optional object)
"Remove all cell properties.
@@ -5204,8 +5200,7 @@ instead of the current buffer and returns the OBJECT."
'table-valign nil
'face nil
'rear-nonsticky nil
- 'point-entered nil
- 'point-left nil
+ 'cursor-sensor-functions nil
'keymap nil)
object))
(setq beg next)))
@@ -5247,28 +5242,20 @@ instead of the current buffer and returns the OBJECT."
"Put cell's vertical alignment property."
(table--put-property cell 'table-valign valign))
-(defun table--point-entered-cell-function (&optional _old-point _new-point)
+(defun table--point-entered/left-cell-function (_window _oldpos dir)
"Point has entered a cell.
Refresh the menu bar."
;; Avoid calling point-motion-hooks recursively.
(let ((inhibit-point-motion-hooks t))
- (unless table-cell-entered-state
- (setq table-cell-entered-state t)
+ (force-mode-line-update)
+ (pcase dir
+ ('left
+ (setq table-mode-indicator nil)
+ (run-hooks 'table-point-left-cell-hook))
+ ('entered
(setq table-mode-indicator t)
- (force-mode-line-update)
(table--warn-incompatibility)
- (run-hooks 'table-point-entered-cell-hook))))
-
-(defun table--point-left-cell-function (&optional _old-point _new-point)
- "Point has left a cell.
-Refresh the menu bar."
- ;; Avoid calling point-motion-hooks recursively.
- (let ((inhibit-point-motion-hooks t))
- (when table-cell-entered-state
- (setq table-cell-entered-state nil)
- (setq table-mode-indicator nil)
- (force-mode-line-update)
- (run-hooks 'table-point-left-cell-hook))))
+ (run-hooks 'table-point-entered-cell-hook)))))
(defun table--warn-incompatibility ()
"If called from interactive operation warn the know incompatibilities.
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 7b16262233d..0b13759b9bc 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1,9 +1,9 @@
-;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*-
+;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- lexical-binding:t -*-
-;; Copyright (C) 1985-1986, 1989, 1992, 1994-1999, 2001-2013 Free
+;; Copyright (C) 1985-1986, 1989, 1992, 1994-1999, 2001-2015 Free
;; Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: tex
;; Contributions over the years by William F. Schelter, Dick King,
@@ -135,8 +135,8 @@ If nil, TeX runs with no options. See the documentation of `tex-command'."
"TeX commands to use when starting TeX.
They are shell-quoted and precede the input file name, with a separating space.
If nil, no commands are used. See the documentation of `tex-command'."
- :type '(radio (const :tag "Interactive \(nil\)" nil)
- (const :tag "Nonstop \(\"\\nonstopmode\\input\"\)"
+ :type '(radio (const :tag "Interactive (nil)" nil)
+ (const :tag "Nonstop (\"\\nonstopmode\\input\")"
"\\nonstopmode\\input")
(string :tag "String at your choice"))
:group 'tex-run
@@ -266,8 +266,8 @@ tex shell terminates.")
(defvar tex-command "tex"
"Command to run TeX.
-If this string contains an asterisk \(`*'\), that is replaced by the file name;
-otherwise the value of `tex-start-options', the \(shell-quoted\)
+If this string contains an asterisk \(`*'), that is replaced by the file name;
+otherwise the value of `tex-start-options', the \(shell-quoted)
value of `tex-start-commands', and the file name are added at the end
with blanks as separators.
@@ -368,7 +368,7 @@ An alternative value is \" . \", if you use a font with a narrow period."
(match-end 1))
latex-section-alist))))
(backward-char 1)
- (condition-case err
+ (condition-case nil
(progn
;; Using sexps allows some use of matching {...} inside
;; titles.
@@ -387,7 +387,7 @@ An alternative value is \" . \", if you use a font with a narrow period."
(goto-char (point-min))
(while (search-forward-regexp
"\\\\\\(include\\|input\\|verbatiminput\\|bibliography\\)\
-\[ \t]*{\\([^}\n]+\\)}"
+[ \t]*{\\([^}\n]+\\)}"
nil t)
(push (cons (concat "<<" (buffer-substring-no-properties
(match-beginning 2)
@@ -808,7 +808,7 @@ Not smaller than the value set by `tex-suscript-height-minimum'."
(defvar tex-verbatim-face 'tex-verbatim)
(defun tex-font-lock-verb (start delim)
- "Place syntax table properties on the \verb construct.
+ "Place syntax table properties on the \\verb construct.
START is the position of the \\ and DELIM is the delimiter char."
;; Do nothing if the \verb construct is itself inside a comment or
;; verbatim env.
@@ -937,7 +937,7 @@ Inherits `shell-mode-map' with a few additions.")
,@tex-face-alist)
"Alist of face and LaTeX font name for facemenu.")
-(defun tex-facemenu-add-face-function (face end)
+(defun tex-facemenu-add-face-function (face _end)
(or (cdr (assq face tex-face-alist))
(or (and (consp face)
(consp (car face))
@@ -1034,8 +1034,8 @@ says which mode to use."
(define-derived-mode plain-tex-mode tex-mode "TeX"
"Major mode for editing files of input for plain TeX.
Makes $ and } display the characters they match.
-Makes \" insert `` when it seems to be the beginning of a quotation,
-and '' when it appears to be the end; it inserts \" only after a \\.
+Makes \" insert \\=`\\=` when it seems to be the beginning of a quotation,
+and \\='\\=' when it appears to be the end; it inserts \" only after a \\.
Use \\[tex-region] to run TeX on the current region, plus a \"header\"
copied from the top of the file (containing macro definitions, etc.),
@@ -1080,8 +1080,8 @@ special subshell is initiated, the hook `tex-shell-hook' is run."
(define-derived-mode latex-mode tex-mode "LaTeX"
"Major mode for editing files of input for LaTeX.
Makes $ and } display the characters they match.
-Makes \" insert `` when it seems to be the beginning of a quotation,
-and '' when it appears to be the end; it inserts \" only after a \\.
+Makes \" insert \\=`\\=` when it seems to be the beginning of a quotation,
+and \\='\\=' when it appears to be the end; it inserts \" only after a \\.
Use \\[tex-region] to run LaTeX on the current region, plus the preamble
copied from the top of the file (containing \\documentstyle, etc.),
@@ -1162,8 +1162,8 @@ subshell is initiated, `tex-shell-hook' is run."
(define-derived-mode slitex-mode latex-mode "SliTeX"
"Major mode for editing files of input for SliTeX.
Makes $ and } display the characters they match.
-Makes \" insert `` when it seems to be the beginning of a quotation,
-and '' when it appears to be the end; it inserts \" only after a \\.
+Makes \" insert \\=`\\=` when it seems to be the beginning of a quotation,
+and \\='\\=' when it appears to be the end; it inserts \" only after a \\.
Use \\[tex-region] to run SliTeX on the current region, plus the preamble
copied from the top of the file (containing \\documentstyle, etc.),
@@ -1203,9 +1203,33 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
(setq tex-command slitex-run-command)
(setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}"))
+(defvar tildify-space-string)
+(defvar tildify-foreach-region-function)
+(defvar tex--prettify-symbols-alist)
+
(defun tex-common-initialization ()
;; Regexp isearch should accept newline and formfeed as whitespace.
(setq-local search-whitespace-regexp "[ \t\r\n\f]+")
+ ;; Use tilde as hard-space character in tildify package.
+ (setq-local tildify-space-string "~")
+ ;; FIXME: Use the fact that we're parsing the document already
+ ;; rather than using regex-based filtering.
+ (setq-local tildify-foreach-region-function
+ (apply-partially
+ 'tildify-foreach-ignore-environments
+ `(("\\\\\\\\" . "") ; do not remove this
+ (,(eval-when-compile
+ (concat "\\\\begin{\\("
+ (regexp-opt '("verbatim" "math" "displaymath"
+ "equation" "eqnarray" "eqnarray*"))
+ "\\)}"))
+ . ("\\\\end{" 1 "}"))
+ ("\\\\verb\\*?\\(.\\)" . (1))
+ ("\\$\\$?" . (0))
+ ("\\\\(" . "\\\\)")
+ ("\\\\[[]" . "\\\\[]]")
+ ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "")
+ ("%" . "$"))))
;; A line containing just $$ is treated as a paragraph separator.
(setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$")
;; A line starting with $$ starts a paragraph,
@@ -1223,7 +1247,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
(setq-local facemenu-remove-face-function t)
(setq-local font-lock-defaults
'((tex-font-lock-keywords tex-font-lock-keywords-1
- tex-font-lock-keywords-2 tex-font-lock-keywords-3)
+ tex-font-lock-keywords-2 tex-font-lock-keywords-3)
nil nil nil nil
;; Who ever uses that anyway ???
(font-lock-mark-block-function . mark-paragraph)
@@ -1231,6 +1255,9 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
. tex-font-lock-syntactic-face-function)
(font-lock-unfontify-region-function
. tex-font-lock-unfontify-region)))
+ (setq-local prettify-symbols-alist tex--prettify-symbols-alist)
+ (add-function :override (local 'prettify-symbols-compose-predicate)
+ #'tex--prettify-symbols-compose-p)
(setq-local syntax-propertize-function
(syntax-propertize-rules latex-syntax-propertize-rules))
;; TABs in verbatim environments don't do what you think.
@@ -1273,22 +1300,56 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
(defun tex-insert-quote (arg)
"Insert the appropriate quote marks for TeX.
-Inserts the value of `tex-open-quote' (normally ``) or `tex-close-quote'
-\(normally '') depending on the context. With prefix argument, always
+Inserts the value of `tex-open-quote' (normally \\=`\\=`) or `tex-close-quote'
+\(normally \\='\\=') depending on the context. With prefix argument, always
inserts \" characters."
(interactive "*P")
+ ;; Discover if we'll be inserting normal double quotes.
+ ;;
(if (or arg (memq (char-syntax (preceding-char)) '(?/ ?\\))
- (eq (get-text-property (point) 'face) 'tex-verbatim)
- (save-excursion
- (backward-char (length tex-open-quote))
- (when (or (looking-at (regexp-quote tex-open-quote))
- (looking-at (regexp-quote tex-close-quote)))
- (delete-char (length tex-open-quote))
- t)))
+ (eq (get-text-property (point) 'face) 'tex-verbatim)
+ ;; Discover if a preceding occurrence of `tex-open-quote'
+ ;; should be morphed to a normal double quote.
+ ;;
+ (and (>= (point) (+ (point-min) (length tex-open-quote)))
+ (save-excursion
+ (backward-char (length tex-open-quote))
+ (when (or (looking-at (regexp-quote tex-open-quote))
+ (looking-at (regexp-quote tex-close-quote)))
+ (delete-char (length tex-open-quote))
+ (when (looking-at (regexp-quote tex-close-quote))
+ (delete-char (length tex-close-quote)))
+ t))))
+ ;; Insert the normal quote (eventually letting
+ ;; `electric-pair-mode' do its thing).
+ ;;
(self-insert-command (prefix-numeric-value arg))
- (insert (if (or (memq (char-syntax (preceding-char)) '(?\( ?> ?\s))
- (memq (preceding-char) '(?~)))
- tex-open-quote tex-close-quote))))
+ ;; We'll be inserting fancy TeX quotes, but consider and imitate
+ ;; `electric-pair-mode''s two behaviors: pair-insertion and
+ ;; region wrapping.
+ ;;
+ (if (and electric-pair-mode (use-region-p))
+ (let* ((saved (point-marker)))
+ (goto-char (mark))
+ (insert (if (> saved (mark)) tex-open-quote tex-close-quote))
+ (goto-char saved)
+ (insert (if (> saved (mark)) tex-close-quote tex-open-quote)))
+ (if (or (memq (char-syntax (preceding-char)) '(?\( ?> ?\s))
+ (memq (preceding-char) '(?~ ?')))
+ ;; We're in an "opening" context
+ ;;
+ (if electric-pair-mode
+ (if (looking-at (regexp-quote tex-close-quote))
+ (forward-char (length tex-close-quote))
+ (insert tex-open-quote)
+ (insert tex-close-quote)
+ (backward-char (length tex-close-quote)))
+ (insert tex-open-quote))
+ ;; We're in a "closing" context.
+ ;;
+ (if (looking-at (regexp-quote tex-close-quote))
+ (forward-char (length tex-close-quote))
+ (insert tex-close-quote))))))
(defun tex-validate-buffer ()
"Check current buffer for paragraphs containing mismatched braces or $s.
@@ -1489,7 +1550,7 @@ Puts point on a blank line between them."
"\\end{" str "}" > \n)
(define-skeleton latex-insert-item
- "Insert a \item macro."
+ "Insert an \\item macro."
nil
\n "\\item " >)
@@ -1708,13 +1769,13 @@ Mark is left at original location."
;; A better way to handle this, \( .. \) etc, is probably to
;; temporarily change the syntax of the \ in \( to punctuation.
((and latex-handle-escaped-parens
- (looking-back "\\\\[])}]"))
+ (looking-back "\\\\[])}]" (- (point) 2)))
(signal 'scan-error
(list "Containing expression ends prematurely"
(- (point) 2) (prog1 (point)
(goto-char pos)))))
((and latex-handle-escaped-parens
- (looking-back "\\\\\\([({[]\\)"))
+ (looking-back "\\\\\\([({[]\\)" (- (point) 2)))
(tex-next-unmatched-eparen (match-string 1)))
(t (goto-char newpos))))))
@@ -1921,7 +1982,7 @@ In the tex shell buffer this command behaves like `comint-send-input'."
(display-buffer (tex-shell-buf))
(tex-recenter-output-buffer nil))
-(defun tex-shell-sentinel (proc msg)
+(defun tex-shell-sentinel (proc _msg)
(cond ((null (buffer-name (process-buffer proc)))
;; buffer killed
(set-process-buffer proc nil)
@@ -2573,18 +2634,28 @@ line LINE of the window, or centered if LINE is nil."
(prefix-numeric-value linenum)
(/ (window-height) 2)))))))
+(defcustom tex-print-file-extension ".dvi"
+ "The TeX-compiled file extension for viewing and printing.
+If you use pdflatex instead of latex, set this to \".pdf\" and modify
+ `tex-dvi-view-command' and `tex-dvi-print-command' appropriately."
+ :type 'string
+ :group 'tex-view
+ :version "25.1")
+
(defun tex-print (&optional alt)
"Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file].
Runs the shell command defined by `tex-dvi-print-command'. If prefix argument
is provided, use the alternative command, `tex-alt-dvi-print-command'."
(interactive "P")
- (let ((print-file-name-dvi (tex-append tex-print-file ".dvi"))
+ (let ((print-file-name-dvi (tex-append tex-print-file
+ tex-print-file-extension))
test-name)
(if (and (not (equal (current-buffer) tex-last-buffer-texed))
(buffer-file-name)
;; Check that this buffer's printed file is up to date.
(file-newer-than-file-p
- (setq test-name (tex-append (buffer-file-name) ".dvi"))
+ (setq test-name (tex-append (buffer-file-name)
+ tex-print-file-extension))
(buffer-file-name)))
(setq print-file-name-dvi test-name))
(if (not (file-exists-p print-file-name-dvi))
@@ -2680,6 +2751,8 @@ Runs the shell command defined by `tex-show-queue-command'."
(defvar tex-indent-item tex-indent-basic)
(defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
(defvar latex-noindent-environments '("document"))
+(put 'latex-noindent-environments 'safe-local-variable
+ (lambda (x) (null (delq t (mapcar 'stringp x)))))
(defvar tex-latex-indent-syntax-table
(let ((st (make-syntax-table tex-mode-syntax-table)))
@@ -2689,10 +2762,11 @@ Runs the shell command defined by `tex-show-queue-command'."
st)
"Syntax table used while computing indentation.")
-(defun latex-indent (&optional arg)
+(defun latex-indent (&optional _arg)
(if (and (eq (get-text-property (if (and (eobp) (bolp))
(max (point-min) (1- (point)))
- (line-beginning-position)) 'face)
+ (line-beginning-position))
+ 'face)
'tex-verbatim))
'noindent
(with-syntax-table tex-latex-indent-syntax-table
@@ -2801,7 +2875,7 @@ There might be text before point."
(t
(let ((col (current-column)))
(if (or (not (eq (char-syntax (or (char-after pos) ?\s)) ?\())
- ;; Can't be an arg if there's an empty line inbetween.
+ ;; Can't be an arg if there's an empty line in between.
(save-excursion (re-search-forward "^[ \t]*$" pos t)))
;; If the first char was not an open-paren, there's
;; a risk that this is really not an argument to the
@@ -2874,6 +2948,487 @@ There might be text before point."
(setq-local syntax-propertize-function
(syntax-propertize-rules doctex-syntax-propertize-rules)))
+;;; Prettify Symbols Support
+
+(defvar tex--prettify-symbols-alist
+ '( ;; Lowercase Greek letters.
+ ("\\alpha" . ?α)
+ ("\\beta" . ?β)
+ ("\\gamma" . ?γ)
+ ("\\delta" . ?δ)
+ ("\\epsilon" . ?ϵ)
+ ("\\zeta" . ?ζ)
+ ("\\eta" . ?η)
+ ("\\theta" . ?θ)
+ ("\\iota" . ?ι)
+ ("\\kappa" . ?κ)
+ ("\\lambda" . ?λ)
+ ("\\mu" . ?μ)
+ ("\\nu" . ?ν)
+ ("\\xi" . ?ξ)
+ ;; There is no \omicron because it looks like a latin o.
+ ("\\pi" . ?π)
+ ("\\rho" . ?ρ)
+ ("\\sigma" . ?σ)
+ ("\\tau" . ?τ)
+ ("\\upsilon" . ?υ)
+ ("\\phi" . ?φ)
+ ("\\chi" . ?χ)
+ ("\\psi" . ?ψ)
+ ("\\omega" . ?ω)
+ ;; Uppercase Greek letters.
+ ("\\Gamma" . ?Γ)
+ ("\\Delta" . ?Δ)
+ ("\\Lambda" . ?Λ)
+ ("\\Phi" . ?Φ)
+ ("\\Pi" . ?Π)
+ ("\\Psi" . ?Ψ)
+ ("\\Sigma" . ?Σ)
+ ("\\Theta" . ?Θ)
+ ("\\Upsilon" . ?Υ)
+ ("\\Xi" . ?Ξ)
+ ("\\Omega" . ?Ω)
+
+ ;; Other math symbols (taken from leim/quail/latin-ltx.el).
+ ("\\Box" . ?□)
+ ("\\Bumpeq" . ?≎)
+ ("\\Cap" . ?⋒)
+ ("\\Cup" . ?⋓)
+ ("\\Diamond" . ?◇)
+ ("\\Downarrow" . ?⇓)
+ ("\\H{o}" . ?ő)
+ ("\\Im" . ?ℑ)
+ ("\\Join" . ?⋈)
+ ("\\Leftarrow" . ?⇐)
+ ("\\Leftrightarrow" . ?⇔)
+ ("\\Ll" . ?⋘)
+ ("\\Lleftarrow" . ?⇚)
+ ("\\Longleftarrow" . ?⇐)
+ ("\\Longleftrightarrow" . ?⇔)
+ ("\\Longrightarrow" . ?⇒)
+ ("\\Lsh" . ?↰)
+ ("\\Re" . ?ℜ)
+ ("\\Rightarrow" . ?⇒)
+ ("\\Rrightarrow" . ?⇛)
+ ("\\Rsh" . ?↱)
+ ("\\Subset" . ?⋐)
+ ("\\Supset" . ?⋑)
+ ("\\Uparrow" . ?⇑)
+ ("\\Updownarrow" . ?⇕)
+ ("\\Vdash" . ?⊩)
+ ("\\Vert" . ?‖)
+ ("\\Vvdash" . ?⊪)
+ ("\\aleph" . ?ℵ)
+ ("\\amalg" . ?∐)
+ ("\\angle" . ?∠)
+ ("\\approx" . ?≈)
+ ("\\approxeq" . ?≊)
+ ("\\ast" . ?∗)
+ ("\\asymp" . ?≍)
+ ("\\backcong" . ?≌)
+ ("\\backepsilon" . ?∍)
+ ("\\backprime" . ?‵)
+ ("\\backsim" . ?∽)
+ ("\\backsimeq" . ?⋍)
+ ("\\backslash" . ?\\)
+ ("\\barwedge" . ?⊼)
+ ("\\because" . ?∵)
+ ("\\beth" . ?ℶ)
+ ("\\between" . ?≬)
+ ("\\bigcap" . ?⋂)
+ ("\\bigcirc" . ?◯)
+ ("\\bigcup" . ?⋃)
+ ("\\bigstar" . ?★)
+ ("\\bigtriangledown" . ?▽)
+ ("\\bigtriangleup" . ?△)
+ ("\\bigvee" . ?⋁)
+ ("\\bigwedge" . ?⋀)
+ ("\\blacklozenge" . ?✦)
+ ("\\blacksquare" . ?▪)
+ ("\\blacktriangle" . ?▴)
+ ("\\blacktriangledown" . ?▾)
+ ("\\blacktriangleleft" . ?◂)
+ ("\\blacktriangleright" . ?▸)
+ ("\\bot" . ?⊥)
+ ("\\bowtie" . ?⋈)
+ ("\\boxminus" . ?⊟)
+ ("\\boxplus" . ?⊞)
+ ("\\boxtimes" . ?⊠)
+ ("\\bullet" . ?•)
+ ("\\bumpeq" . ?≏)
+ ("\\cap" . ?∩)
+ ("\\cdots" . ?⋯)
+ ("\\centerdot" . ?·)
+ ("\\checkmark" . ?✓)
+ ("\\chi" . ?χ)
+ ("\\cdot" . ?⋅)
+ ("\\cdots" . ?⋯)
+ ("\\circ" . ?∘)
+ ("\\circeq" . ?≗)
+ ("\\circlearrowleft" . ?↺)
+ ("\\circlearrowright" . ?↻)
+ ("\\circledR" . ?®)
+ ("\\circledS" . ?Ⓢ)
+ ("\\circledast" . ?⊛)
+ ("\\circledcirc" . ?⊚)
+ ("\\circleddash" . ?⊝)
+ ("\\clubsuit" . ?♣)
+ ("\\coloneq" . ?≔)
+ ("\\complement" . ?∁)
+ ("\\cong" . ?≅)
+ ("\\coprod" . ?∐)
+ ("\\cup" . ?∪)
+ ("\\curlyeqprec" . ?⋞)
+ ("\\curlyeqsucc" . ?⋟)
+ ("\\curlypreceq" . ?≼)
+ ("\\curlyvee" . ?⋎)
+ ("\\curlywedge" . ?⋏)
+ ("\\curvearrowleft" . ?↶)
+ ("\\curvearrowright" . ?↷)
+ ("\\dag" . ?†)
+ ("\\dagger" . ?†)
+ ("\\daleth" . ?ℸ)
+ ("\\dashv" . ?⊣)
+ ("\\ddag" . ?‡)
+ ("\\ddagger" . ?‡)
+ ("\\ddots" . ?⋱)
+ ("\\diamond" . ?⋄)
+ ("\\diamondsuit" . ?♢)
+ ("\\divideontimes" . ?⋇)
+ ("\\doteq" . ?≐)
+ ("\\doteqdot" . ?≑)
+ ("\\dotplus" . ?∔)
+ ("\\dotsquare" . ?⊡)
+ ("\\downarrow" . ?↓)
+ ("\\downdownarrows" . ?⇊)
+ ("\\downleftharpoon" . ?⇃)
+ ("\\downrightharpoon" . ?⇂)
+ ("\\ell" . ?ℓ)
+ ("\\emptyset" . ?∅)
+ ("\\eqcirc" . ?≖)
+ ("\\eqcolon" . ?≕)
+ ("\\eqslantgtr" . ?⋝)
+ ("\\eqslantless" . ?⋜)
+ ("\\equiv" . ?≡)
+ ("\\exists" . ?∃)
+ ("\\fallingdotseq" . ?≒)
+ ("\\flat" . ?♭)
+ ("\\forall" . ?∀)
+ ("\\frown" . ?⌢)
+ ("\\ge" . ?≥)
+ ("\\geq" . ?≥)
+ ("\\geqq" . ?≧)
+ ("\\geqslant" . ?≥)
+ ("\\gets" . ?←)
+ ("\\gg" . ?≫)
+ ("\\ggg" . ?⋙)
+ ("\\gimel" . ?ℷ)
+ ("\\gnapprox" . ?⋧)
+ ("\\gneq" . ?≩)
+ ("\\gneqq" . ?≩)
+ ("\\gnsim" . ?⋧)
+ ("\\gtrapprox" . ?≳)
+ ("\\gtrdot" . ?⋗)
+ ("\\gtreqless" . ?⋛)
+ ("\\gtreqqless" . ?⋛)
+ ("\\gtrless" . ?≷)
+ ("\\gtrsim" . ?≳)
+ ("\\gvertneqq" . ?≩)
+ ("\\hbar" . ?ℏ)
+ ("\\heartsuit" . ?♥)
+ ("\\hookleftarrow" . ?↩)
+ ("\\hookrightarrow" . ?↪)
+ ("\\iff" . ?⇔)
+ ("\\imath" . ?ı)
+ ("\\in" . ?∈)
+ ("\\infty" . ?∞)
+ ("\\int" . ?∫)
+ ("\\intercal" . ?⊺)
+ ("\\langle" . 10216) ; Literal ?⟨ breaks indentation.
+ ("\\lbrace" . ?{)
+ ("\\lbrack" . ?\[)
+ ("\\lceil" . ?⌈)
+ ("\\ldots" . ?…)
+ ("\\le" . ?≤)
+ ("\\leadsto" . ?↝)
+ ("\\leftarrow" . ?←)
+ ("\\leftarrowtail" . ?↢)
+ ("\\leftharpoondown" . ?↽)
+ ("\\leftharpoonup" . ?↼)
+ ("\\leftleftarrows" . ?⇇)
+ ;; ("\\leftparengtr" ?〈), see bug#12948.
+ ("\\leftrightarrow" . ?↔)
+ ("\\leftrightarrows" . ?⇆)
+ ("\\leftrightharpoons" . ?⇋)
+ ("\\leftrightsquigarrow" . ?↭)
+ ("\\leftthreetimes" . ?⋋)
+ ("\\leq" . ?≤)
+ ("\\leqq" . ?≦)
+ ("\\leqslant" . ?≤)
+ ("\\lessapprox" . ?≲)
+ ("\\lessdot" . ?⋖)
+ ("\\lesseqgtr" . ?⋚)
+ ("\\lesseqqgtr" . ?⋚)
+ ("\\lessgtr" . ?≶)
+ ("\\lesssim" . ?≲)
+ ("\\lfloor" . ?⌊)
+ ("\\lhd" . ?◁)
+ ("\\rhd" . ?▷)
+ ("\\ll" . ?≪)
+ ("\\llcorner" . ?⌞)
+ ("\\lnapprox" . ?⋦)
+ ("\\lneq" . ?≨)
+ ("\\lneqq" . ?≨)
+ ("\\lnsim" . ?⋦)
+ ("\\longleftarrow" . ?←)
+ ("\\longleftrightarrow" . ?↔)
+ ("\\longmapsto" . ?↦)
+ ("\\longrightarrow" . ?→)
+ ("\\looparrowleft" . ?↫)
+ ("\\looparrowright" . ?↬)
+ ("\\lozenge" . ?✧)
+ ("\\lq" . ?‘)
+ ("\\lrcorner" . ?⌟)
+ ("\\ltimes" . ?⋉)
+ ("\\lvertneqq" . ?≨)
+ ("\\maltese" . ?✠)
+ ("\\mapsto" . ?↦)
+ ("\\measuredangle" . ?∡)
+ ("\\mho" . ?℧)
+ ("\\mid" . ?∣)
+ ("\\models" . ?⊧)
+ ("\\mp" . ?∓)
+ ("\\multimap" . ?⊸)
+ ("\\nLeftarrow" . ?⇍)
+ ("\\nLeftrightarrow" . ?⇎)
+ ("\\nRightarrow" . ?⇏)
+ ("\\nVDash" . ?⊯)
+ ("\\nVdash" . ?⊮)
+ ("\\nabla" . ?∇)
+ ("\\napprox" . ?≉)
+ ("\\natural" . ?♮)
+ ("\\ncong" . ?≇)
+ ("\\ne" . ?≠)
+ ("\\nearrow" . ?↗)
+ ("\\neg" . ?¬)
+ ("\\neq" . ?≠)
+ ("\\nequiv" . ?≢)
+ ("\\newline" . ?
)
+ ("\\nexists" . ?∄)
+ ("\\ngeq" . ?≱)
+ ("\\ngeqq" . ?≱)
+ ("\\ngeqslant" . ?≱)
+ ("\\ngtr" . ?≯)
+ ("\\ni" . ?∋)
+ ("\\nleftarrow" . ?↚)
+ ("\\nleftrightarrow" . ?↮)
+ ("\\nleq" . ?≰)
+ ("\\nleqq" . ?≰)
+ ("\\nleqslant" . ?≰)
+ ("\\nless" . ?≮)
+ ("\\nmid" . ?∤)
+ ;; ("\\not" ?̸) ;FIXME: conflict with "NOT SIGN" ¬.
+ ("\\notin" . ?∉)
+ ("\\nparallel" . ?∦)
+ ("\\nprec" . ?⊀)
+ ("\\npreceq" . ?⋠)
+ ("\\nrightarrow" . ?↛)
+ ("\\nshortmid" . ?∤)
+ ("\\nshortparallel" . ?∦)
+ ("\\nsim" . ?≁)
+ ("\\nsimeq" . ?≄)
+ ("\\nsubset" . ?⊄)
+ ("\\nsubseteq" . ?⊈)
+ ("\\nsubseteqq" . ?⊈)
+ ("\\nsucc" . ?⊁)
+ ("\\nsucceq" . ?⋡)
+ ("\\nsupset" . ?⊅)
+ ("\\nsupseteq" . ?⊉)
+ ("\\nsupseteqq" . ?⊉)
+ ("\\ntriangleleft" . ?⋪)
+ ("\\ntrianglelefteq" . ?⋬)
+ ("\\ntriangleright" . ?⋫)
+ ("\\ntrianglerighteq" . ?⋭)
+ ("\\nvDash" . ?⊭)
+ ("\\nvdash" . ?⊬)
+ ("\\nwarrow" . ?↖)
+ ("\\odot" . ?⊙)
+ ("\\oint" . ?∮)
+ ("\\ominus" . ?⊖)
+ ("\\oplus" . ?⊕)
+ ("\\oslash" . ?⊘)
+ ("\\otimes" . ?⊗)
+ ("\\par" . ?
)
+ ("\\parallel" . ?∥)
+ ("\\partial" . ?∂)
+ ("\\perp" . ?⊥)
+ ("\\pitchfork" . ?⋔)
+ ("\\prec" . ?≺)
+ ("\\precapprox" . ?≾)
+ ("\\preceq" . ?≼)
+ ("\\precnapprox" . ?⋨)
+ ("\\precnsim" . ?⋨)
+ ("\\precsim" . ?≾)
+ ("\\prime" . ?′)
+ ("\\prod" . ?∏)
+ ("\\propto" . ?∝)
+ ("\\qed" . ?∎)
+ ("\\qquad" . ?⧢)
+ ("\\quad" . ?␣)
+ ("\\rangle" . 10217) ; Literal ?⟩ breaks indentation.
+ ("\\rbrace" . ?})
+ ("\\rbrack" . ?\])
+ ("\\rceil" . ?⌉)
+ ("\\rfloor" . ?⌋)
+ ("\\rightarrow" . ?→)
+ ("\\rightarrowtail" . ?↣)
+ ("\\rightharpoondown" . ?⇁)
+ ("\\rightharpoonup" . ?⇀)
+ ("\\rightleftarrows" . ?⇄)
+ ("\\rightleftharpoons" . ?⇌)
+ ;; ("\\rightparengtr" ?⦔) ;; Was ?〉, see bug#12948.
+ ("\\rightrightarrows" . ?⇉)
+ ("\\rightthreetimes" . ?⋌)
+ ("\\risingdotseq" . ?≓)
+ ("\\rtimes" . ?⋊)
+ ("\\sbs" . ?﹨)
+ ("\\searrow" . ?↘)
+ ("\\setminus" . ?∖)
+ ("\\sharp" . ?♯)
+ ("\\shortmid" . ?∣)
+ ("\\shortparallel" . ?∥)
+ ("\\sim" . ?∼)
+ ("\\simeq" . ?≃)
+ ("\\smallamalg" . ?∐)
+ ("\\smallsetminus" . ?∖)
+ ("\\smallsmile" . ?⌣)
+ ("\\smile" . ?⌣)
+ ("\\spadesuit" . ?♠)
+ ("\\sphericalangle" . ?∢)
+ ("\\sqcap" . ?⊓)
+ ("\\sqcup" . ?⊔)
+ ("\\sqsubset" . ?⊏)
+ ("\\sqsubseteq" . ?⊑)
+ ("\\sqsupset" . ?⊐)
+ ("\\sqsupseteq" . ?⊒)
+ ("\\square" . ?□)
+ ("\\squigarrowright" . ?⇝)
+ ("\\star" . ?⋆)
+ ("\\straightphi" . ?φ)
+ ("\\subset" . ?⊂)
+ ("\\subseteq" . ?⊆)
+ ("\\subseteqq" . ?⊆)
+ ("\\subsetneq" . ?⊊)
+ ("\\subsetneqq" . ?⊊)
+ ("\\succ" . ?≻)
+ ("\\succapprox" . ?≿)
+ ("\\succcurlyeq" . ?≽)
+ ("\\succeq" . ?≽)
+ ("\\succnapprox" . ?⋩)
+ ("\\succnsim" . ?⋩)
+ ("\\succsim" . ?≿)
+ ("\\sum" . ?∑)
+ ("\\supset" . ?⊃)
+ ("\\supseteq" . ?⊇)
+ ("\\supseteqq" . ?⊇)
+ ("\\supsetneq" . ?⊋)
+ ("\\supsetneqq" . ?⊋)
+ ("\\surd" . ?√)
+ ("\\swarrow" . ?↙)
+ ("\\therefore" . ?∴)
+ ("\\thickapprox" . ?≈)
+ ("\\thicksim" . ?∼)
+ ("\\to" . ?→)
+ ("\\top" . ?⊤)
+ ("\\triangle" . ?▵)
+ ("\\triangledown" . ?▿)
+ ("\\triangleleft" . ?◃)
+ ("\\trianglelefteq" . ?⊴)
+ ("\\triangleq" . ?≜)
+ ("\\triangleright" . ?▹)
+ ("\\trianglerighteq" . ?⊵)
+ ("\\twoheadleftarrow" . ?↞)
+ ("\\twoheadrightarrow" . ?↠)
+ ("\\ulcorner" . ?⌜)
+ ("\\uparrow" . ?↑)
+ ("\\updownarrow" . ?↕)
+ ("\\upleftharpoon" . ?↿)
+ ("\\uplus" . ?⊎)
+ ("\\uprightharpoon" . ?↾)
+ ("\\upuparrows" . ?⇈)
+ ("\\urcorner" . ?⌝)
+ ("\\u{i}" . ?ĭ)
+ ("\\vDash" . ?⊨)
+ ("\\varepsilon" . ?ε)
+ ("\\varprime" . ?′)
+ ("\\varpropto" . ?∝)
+ ("\\varrho" . ?ϱ)
+ ;; ("\\varsigma" ?ς) ;FIXME: Looks reversed with the non\var.
+ ("\\vartriangleleft" . ?⊲)
+ ("\\vartriangleright" . ?⊳)
+ ("\\vdash" . ?⊢)
+ ("\\vdots" . ?⋮)
+ ("\\vee" . ?∨)
+ ("\\veebar" . ?⊻)
+ ("\\vert" . ?|)
+ ("\\wedge" . ?∧)
+ ("\\wp" . ?℘)
+ ("\\wr" . ?≀)
+ ("\\Bbb{N}" . ?ℕ) ; AMS commands for blackboard bold
+ ("\\Bbb{P}" . ?ℙ) ; Also sometimes \mathbb.
+ ("\\Bbb{Q}" . ?ℚ)
+ ("\\Bbb{R}" . ?ℝ)
+ ("\\Bbb{Z}" . ?ℤ)
+ ("--" . ?–)
+ ("---" . ?—)
+ ("\\ordfeminine" . ?ª)
+ ("\\ordmasculine" . ?º)
+ ("\\lambdabar" . ?ƛ)
+ ("\\celsius" . ?℃)
+ ("\\textmu" . ?µ)
+ ("\\textfractionsolidus" . ?⁄)
+ ("\\textbigcircle" . ?⃝)
+ ("\\textmusicalnote" . ?♪)
+ ("\\textdied" . ?✝)
+ ("\\textcolonmonetary" . ?₡)
+ ("\\textwon" . ?₩)
+ ("\\textnaira" . ?₦)
+ ("\\textpeso" . ?₱)
+ ("\\textlira" . ?₤)
+ ("\\textrecipe" . ?℞)
+ ("\\textinterrobang" . ?‽)
+ ("\\textpertenthousand" . ?‱)
+ ("\\textbaht" . ?฿)
+ ("\\textnumero" . ?№)
+ ("\\textdiscount" . ?⁒)
+ ("\\textestimated" . ?℮)
+ ("\\textopenbullet" . ?◦)
+ ("\\textlquill" . 8261) ; Literal ?⁅ breaks indentation.
+ ("\\textrquill" . 8262) ; Literal ?⁆ breaks indentation.
+ ("\\textcircledP" . ?℗)
+ ("\\textreferencemark" . ?※))
+ "A `prettify-symbols-alist' usable for (La)TeX modes.")
+
+(defun tex--prettify-symbols-compose-p (_start end _match)
+ (or
+ ;; If the matched symbol doesn't end in a word character, then we
+ ;; simply allow composition. The symbol is probably something like
+ ;; \|, \(, etc.
+ (not (eq ?w (char-syntax (char-before end))))
+ ;; Else we look at what follows the match in order to decide.
+ (let* ((after-char (char-after end))
+ (after-syntax (char-syntax after-char)))
+ (not (or
+ ;; Don't compose \alpha@foo.
+ (eq after-char ?@)
+ ;; The \alpha in \alpha2 or \alpha-\beta may be composed but
+ ;; of course \alphax may not.
+ (and (eq after-syntax ?w)
+ (not (memq after-char
+ '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?+ ?- ?' ?\"))))
+ ;; Don't compose inside verbatim blocks.
+ (eq 2 (nth 7 (syntax-ppss))))))))
+
(run-hooks 'tex-mode-load-hook)
(provide 'tex-mode)
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index ed6ed4932e9..500c1e38394 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -1,6 +1,6 @@
;;; texinfmt.el --- format Texinfo files into Info files
-;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2013 Free Software
+;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2015 Free Software
;; Foundation, Inc.
;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
@@ -34,7 +34,7 @@
If optional argument HERE is non-nil, insert info at point."
(interactive "P")
(let ((version-string
- (format "Version of \`texinfmt.el\': %s" texinfmt-version)))
+ (format-message "Version of `texinfmt.el': %s" texinfmt-version)))
(if here
(insert version-string)
(if (called-interactively-p 'interactive)
@@ -330,25 +330,24 @@ converted to Info is stored in a temporary buffer."
(let ((arg (texinfo-parse-arg-discard)))
(insert " "
texinfo-region-buffer-name
- " buffer for: `")
+ (format-message " buffer for: `"))
(insert (file-name-nondirectory (expand-file-name arg)))
- (insert "', -*-Text-*-\n")))
+ (insert (format-message "', -*-Text-*-\n"))))
;; Else no `@setfilename' line
(insert " "
texinfo-region-buffer-name
" buffer -*-Text-*-\n"))
- (insert "produced by `texinfo-format-region'\n"
+ (insert (format-message "produced by `texinfo-format-region'\n")
"from a region in: "
(if (buffer-file-name input-buffer)
- (concat "`"
- (file-name-sans-versions
- (file-name-nondirectory
- (buffer-file-name input-buffer)))
- "'")
- (concat "buffer `" (buffer-name input-buffer) "'"))
- "\nusing `texinfmt.el' version "
- texinfmt-version
- ".\n\n")
+ (format-message "`%s'"
+ (file-name-sans-versions
+ (file-name-nondirectory
+ (buffer-file-name input-buffer))))
+ (format-message "buffer `%s'" (buffer-name input-buffer)))
+ (format-message "\nusing `texinfmt.el' version ")
+ texinfmt-version
+ ".\n\n")
;; Now convert for real.
(goto-char (point-min))
@@ -479,19 +478,18 @@ if large. You can use `Info-split' to do this manually."
;; Insert info about how this file was made.
(insert "Info file: "
texinfo-format-filename ", -*-Text-*-\n"
- "produced by `texinfo-format-buffer'\n"
+ (format-message "produced by `texinfo-format-buffer'\n")
;; Date string removed so that regression testing is easier.
;; "on "
;; (insert (format-time-string "%e %b %Y")) " "
"from file"
(if (buffer-file-name input-buffer)
- (concat " `"
+ (format-message " `%s'"
(file-name-sans-versions
(file-name-nondirectory
- (buffer-file-name input-buffer)))
- "'")
- (concat "buffer `" (buffer-name input-buffer) "'"))
- "\nusing `texinfmt.el' version "
+ (buffer-file-name input-buffer))))
+ (format-message "buffer `%s'" (buffer-name input-buffer)))
+ (format-message "\nusing `texinfmt.el' version ")
texinfmt-version
".\n\n")
;; Return data for indices.
@@ -1045,7 +1043,7 @@ Leave point after argument."
(setq texinfo-command-end (point)))
(t
(error
- "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
+ "Invalid `texinfo-optional-braces-discard' format (need braces?)")))
(delete-region texinfo-command-start texinfo-command-end)))
(defun texinfo-format-parse-line-args ()
@@ -1287,7 +1285,7 @@ Leave point after argument."
(put 'uref 'texinfo-format 'texinfo-format-uref)
(defun texinfo-format-uref ()
"Format URL and optional URL-TITLE.
-Insert ` ... ' around URL if no URL-TITLE argument;
+Insert \\=` ... \\=' around URL if no URL-TITLE argument;
otherwise, insert URL-TITLE followed by URL in parentheses."
(let ((args (texinfo-format-parse-args)))
(texinfo-discard-command)
@@ -2338,7 +2336,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image."
;; Write a `@definfoenclose' command on a line and follow it with three
;; arguments separated by commas (commas are used as separators in an
;; `@node' line in the same way). The first argument to
-;; `@definfoenclose' is the @-command name \(without the `@'\); the
+;; `@definfoenclose' is the @-command name (without the `@'); the
;; second argument is the Info start delimiter string; and the third
;; argument is the Info end delimiter string. The latter two arguments
;; enclose the highlighted text in the Info file. A delimiter string
@@ -2447,7 +2445,7 @@ Use only the FILENAME arg; for Info, ignore the other arguments to @image."
;; not lead to inserted ` ... ' in a table, but does elsewhere.
(put 'option 'texinfo-format 'texinfo-format-option)
(defun texinfo-format-option ()
- "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
+ "Insert \\=` ... \\=' around arg unless inside a table; in that case, no quotes."
;; `looking-at-backward' not available in v. 18.57, 20.2
(if (not (search-backward "" ; searched-for character is a control-H
(line-beginning-position)
@@ -2493,8 +2491,8 @@ surrounded by in angle brackets."
Enclose the verbatim text, including the delimiters, in braces. Print
text exactly as written (but not the delimiters) in a fixed-width.
-For example, @verb\{|@|\} results in @ and
-@verb\{+@'e?`!`+} results in @'e?`!`."
+For example, @verb{|@|} results in @ and
+@verb{+@\\='e?\\=`!\\=`+} results in @\\='e?\\=`!\\=`."
(let ((delimiter (buffer-substring-no-properties
(1+ texinfo-command-end) (+ 2 texinfo-command-end))))
@@ -3127,7 +3125,7 @@ Default is to leave paragraph indentation as is."
;; (put '\` 'texinfo-format 'texinfo-format-grave-accent)
;; (defun texinfo-format-grave-accent ()
;; (texinfo-discard-command)
-;; (insert "\`"))
+;; (insert "`"))
;;
;; @' ==> ' acute accent
;; (put '\' 'texinfo-format 'texinfo-format-acute-accent)
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index 44e839d2474..2b606ed002e 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -1,11 +1,11 @@
-;;; texinfo.el --- major mode for editing Texinfo files -*- coding: utf-8 -*-
+;;; texinfo.el --- major mode for editing Texinfo files
-;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2013 Free Software
+;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2015 Free Software
;; Foundation, Inc.
;; Author: Robert J. Chassell
;; Date: [See date below for texinfo-version]
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: maint, tex, docs
;; This file is part of GNU Emacs.
@@ -44,6 +44,8 @@
(defvar outline-heading-alist)
+(defvar skeleton-end-newline)
+
(defgroup texinfo nil
"Texinfo Mode."
:link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
@@ -84,7 +86,7 @@ command to gain use of `next-error'."
"Make Info file from current buffer.
Use the \\[next-error] command to move to the next error
-\(if there are errors\)."
+\(if there are errors)."
t nil)
(autoload 'kill-compilation
@@ -626,6 +628,11 @@ value of `texinfo-mode-hook'."
(setq-local tex-first-line-header-regexp "^\\\\input")
(setq-local tex-trailer "@bye\n")
+ ;; Prevent skeleton.el from adding a newline to each inserted
+ ;; skeleton. Those which do want a newline do that explicitly in
+ ;; their define-skeleton form.
+ (setq-local skeleton-end-newline nil)
+
;; Prevent filling certain lines, in addition to ones specified by
;; the user.
(setq-local auto-fill-inhibit-regexp
@@ -653,7 +660,7 @@ Puts point on a blank line between them."
(if (or (string-match "\\`def" str)
(member str '("table" "ftable" "vtable")))
'(nil " " -))
- \n _ \n "@end " str \n)
+ \n _ \n "@end " str \n \n)
(defun texinfo-inside-macro-p (macro &optional bound)
"Non-nil if inside a macro matching the regexp MACRO."
@@ -682,8 +689,8 @@ Puts point on a blank line between them."
'("example\\>" "smallexample\\>" "lisp\\>"))
(defun texinfo-insert-quote (&optional arg)
"Insert the appropriate quote mark for Texinfo.
-Usually inserts the value of `texinfo-open-quote' (normally ``) or
-`texinfo-close-quote' (normally ''), depending on the context.
+Usually inserts the value of `texinfo-open-quote' (normally \\=`\\=`) or
+`texinfo-close-quote' (normally \\='\\='), depending on the context.
With prefix argument or inside @code or @example, inserts a plain \"."
(interactive "*P")
(let ((top (or (save-excursion (re-search-backward "@node\\>" nil t))
@@ -732,7 +739,7 @@ With prefix argument or inside @code or @example, inserts a plain \"."
(backward-word 1)
(texinfo-last-unended-begin)
(or (match-string 1) '-)))
- \n "@end " str \n)
+ \n "@end " str \n \n)
(define-skeleton texinfo-insert-braces
"Make a pair of braces and be poised to type inside of them.
@@ -771,7 +778,7 @@ The default is not to surround any existing words with the braces."
(define-skeleton texinfo-insert-@example
"Insert the string `@example' in a Texinfo buffer."
nil
- \n "@example" \n)
+ \n "@example" \n \n)
(define-skeleton texinfo-insert-@file
"Insert a `@file{...}' command in a Texinfo buffer.
@@ -816,7 +823,7 @@ Leave point after `@node'."
(define-skeleton texinfo-insert-@quotation
"Insert the string `@quotation' in a Texinfo buffer."
- \n "@quotation" \n)
+ \n "@quotation" \n _ \n)
(define-skeleton texinfo-insert-@samp
"Insert a `@samp{...}' command in a Texinfo buffer.
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el
index 40c96ad5fb5..321967a3721 100644
--- a/lisp/textmodes/texnfo-upd.el
+++ b/lisp/textmodes/texnfo-upd.el
@@ -1,6 +1,6 @@
;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files
-;; Copyright (C) 1989-1992, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1989-1992, 2001-2015 Free Software Foundation, Inc.
;; Author: Robert J. Chassell
;; Maintainer: bug-texinfo@gnu.org
@@ -694,8 +694,8 @@ section titles are often too short to explain a node well.
MENU-LIST has form:
- \(\(\"node-name1\" . \"description\"\)
- \(\"node-name2\" . \"description\"\) ... \)
+ ((\"node-name1\" . \"description\")
+ (\"node-name2\" . \"description\") ... )
However, the description field might be nil.
@@ -893,7 +893,7 @@ first update all existing menus in the buffer (incorporating
descriptions from pre-existing menus) before it constructs the
master menu. If the argument is numeric (e.g., \"C-u 2\"),
update all existing nodes as well, by calling
-\`texinfo-update-node' on the entire file. Warning: do NOT
+`texinfo-update-node' on the entire file. Warning: do NOT
invoke with a numeric argument if your Texinfo file uses @node
lines without the `Next', `Previous', `Up' pointers, as the
result could be an invalid Texinfo file!
@@ -1002,9 +1002,9 @@ following menu and the title of the node preceding that menu.
The master menu list has this form:
- \(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\)
- \(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\)
- ...\)
+ (((... \"entry-1-2\" \"entry-1\") \"title-1\")
+ ((... \"entry-2-2\" \"entry-2-1\") \"title-2\")
+ ...)
However, there does not need to be a title field."
@@ -1018,7 +1018,7 @@ However, there does not need to be a title field."
"Format and insert the master menu in the current buffer."
(goto-char (point-min))
;; Insert a master menu only after `Top' node and before next node
- ;; \(or include file if there is no next node\).
+ ;; (or include file if there is no next node).
(unless (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)
(error "This buffer needs a Top node"))
(let ((first-chapter
@@ -1145,24 +1145,40 @@ For example, \"unnumberedsubsec\". Return \"top\" for top node.
Searches forward for a section. Hence, point must be before the
section whose type will be found. Does not move point. Signal an
error if the node is not the top node and a section is not found."
- (let ((case-fold-search t))
- (save-excursion
- (cond
- ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)"
- ;; Following search limit by cph but causes a bug
- ;;(line-end-position)
- nil
- t)
- "top")
- ((re-search-forward texinfo-section-types-regexp nil t)
- (buffer-substring-no-properties
- (progn (beginning-of-line) ; copy its name
- (1+ (point)))
- (progn (forward-word 1)
- (point))))
- (t
- (error
- "texinfo-specific-section-type: Chapter or section not found"))))))
+ (let* ((case-fold-search t)
+ ;; The Texinfo manual has a second Top node inside @verbatim
+ ;; near the end, which dupes us into thinking we are at top
+ ;; level, no matter where we are when invoked. We don't
+ ;; really grok @verbatim, so we cheat: only consider us to be
+ ;; at top level if the position of the Top node we found is
+ ;; before any other sectioning command.
+ (top-pos (save-excursion
+ (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)"
+ ;; Following search limit causes a bug
+ ;;(line-end-position)
+ nil
+ t)))
+ (sec-pos (save-excursion
+ (re-search-forward texinfo-section-types-regexp nil t)))
+ sec-name)
+ (if sec-pos
+ (save-excursion
+ (goto-char sec-pos)
+ (setq sec-name (buffer-substring-no-properties
+ (progn (beginning-of-line) ; copy its name
+ (1+ (point)))
+ (progn (forward-word 1)
+ (point))))))
+ (cond
+ ((or sec-pos top-pos)
+ (if (and top-pos sec-pos)
+ (if (< top-pos sec-pos)
+ "top"
+ sec-name)
+ (or sec-name "top")))
+ (t
+ (error
+ "texinfo-specific-section-type: Chapter or section not found")))))
(defun texinfo-hierarchic-level ()
"Return the general hierarchical level of the next node in a texinfo file.
@@ -1391,7 +1407,7 @@ level in the Texinfo file; when looking for the `Previous' pointer,
the section found will be at the same or higher hierarchical level in
the Texinfo file; when looking for the `Up' pointer, the section found
will be at some level higher in the Texinfo file. The fourth argument
-\(one of 'next, 'previous, or 'up\) specifies whether to find the
+\(one of `next', `previous', or `up') specifies whether to find the
`Next', `Previous', or `Up' pointer."
(let ((case-fold-search t))
(cond ((eq direction 'next)
@@ -1834,8 +1850,8 @@ chapters."
;; The menu-list has the form:
;;
-;; \(\(\"node-name1\" . \"title1\"\)
-;; \(\"node-name2\" . \"title2\"\) ... \)
+;; ((\"node-name1\" . \"title1\")
+;; (\"node-name2\" . \"title2\") ... )
;;
;; However, there does not need to be a title field and this function
;; does not fill it; however a comment tells you how to do so.
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index d9ff04c9b2f..1466556ab59 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -1,9 +1,9 @@
;;; text-mode.el --- text mode, and its idiosyncratic commands
-;; Copyright (C) 1985, 1992, 1994, 2001-2013 Free Software Foundation,
+;; Copyright (C) 1985, 1992, 1994, 2001-2015 Free Software Foundation,
;; Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; Package: emacs
@@ -29,7 +29,9 @@
;;; Code:
-(defcustom text-mode-hook nil
+;; Normally non-nil defaults for hooks are bad, but since this file is
+;; preloaded it's ok/better, and avoids this showing up in customize-rogue.
+(defcustom text-mode-hook '(text-mode-hook-identify)
"Normal hook run when entering Text mode and many related modes."
:type 'hook
:options '(turn-on-auto-fill turn-on-flyspell)
@@ -45,12 +47,50 @@ Use (derived-mode-p 'text-mode) instead.")
(modify-syntax-entry ?\\ ". " st)
;; We add `p' so that M-c on 'hello' leads to 'Hello' rather than 'hello'.
(modify-syntax-entry ?' "w p" st)
+ ;; UAX #29 says HEBREW PUNCTUATION GERESH behaves like a letter
+ ;; for the purposes of finding word boundaries.
+ (modify-syntax-entry #x5f3 "w ") ; GERESH
+ ;; UAX #29 says HEBREW PUNCTUATION GERSHAYIM should not be a word
+ ;; boundary when surrounded by letters. Our infrastructure for
+ ;; finding a word boundary doesn't support 3-character
+ ;; definitions, so for now simply make this a word-constituent
+ ;; character. This leaves a problem of having GERSHAYIM at the
+ ;; beginning or end of a word, where it should be a boundary;
+ ;; FIXME.
+ (modify-syntax-entry #x5f4 "w ") ; GERSHAYIM
+ ;; These all should not be a word boundary when between letters,
+ ;; according to UAX #29, so they again are prone to the same
+ ;; problem as GERSHAYIM; FIXME.
+ (modify-syntax-entry #xb7 "w ") ; MIDDLE DOT
+ (modify-syntax-entry #x2027 "w ") ; HYPHENATION POINT
+ (modify-syntax-entry #xff1a "w ") ; FULLWIDTH COLON
st)
"Syntax table used while in `text-mode'.")
(defvar text-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\e\t" 'ispell-complete-word)
+ (define-key map [menu-bar text]
+ (cons "Text" (make-sparse-keymap "Text")))
+ (bindings--define-key map [menu-bar text toggle-text-mode-auto-fill]
+ '(menu-item "Auto Fill" toggle-text-mode-auto-fill
+ :button (:toggle . (memq 'turn-on-auto-fill text-mode-hook))
+ :help "Automatically fill text while typing in text modes (Auto Fill mode)"))
+ (bindings--define-key map [menu-bar text paragraph-indent-minor-mode]
+ '(menu-item "Paragraph Indent" paragraph-indent-minor-mode
+ :button (:toggle . (bound-and-true-p paragraph-indent-minor-mode))
+ :help "Toggle paragraph indent minor mode"))
+ (bindings--define-key map [menu-bar text sep] menu-bar-separator)
+ (bindings--define-key map [menu-bar text center-region]
+ '(menu-item "Center Region" center-region
+ :help "Center the marked region"
+ :enable (region-active-p)))
+ (bindings--define-key map [menu-bar text center-paragraph]
+ '(menu-item "Center Paragraph" center-paragraph
+ :help "Center the current paragraph"))
+ (bindings--define-key map [menu-bar text center-line]
+ '(menu-item "Center Line" center-line
+ :help "Center the current line"))
map)
"Keymap for `text-mode'.
Many other modes, such as `mail-mode', `outline-mode' and `indented-text-mode',
@@ -101,21 +141,21 @@ Turning on Paragraph-Indent minor mode runs the normal hook
(concat ps-re paragraph-start)))))
;; Change the indentation function.
(if paragraph-indent-minor-mode
- (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
- (if (eq indent-line-function 'indent-to-left-margin)
- (set (make-local-variable 'indent-line-function) 'indent-region))))
+ (add-function :override (local 'indent-line-function)
+ #'indent-to-left-margin)
+ (remove-function (local 'indent-line-function)
+ #'indent-to-left-margin)))
(defalias 'indented-text-mode 'text-mode)
;; This can be made a no-op once all modes that use text-mode-hook
-;; are "derived" from text-mode.
+;; are "derived" from text-mode. (As of 2015/04, and probably well before,
+;; the only one I can find that doesn't so derive is rmail-edit-mode.)
(defun text-mode-hook-identify ()
"Mark that this mode has run `text-mode-hook'.
This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
(set (make-local-variable 'text-mode-variant) t))
-(add-hook 'text-mode-hook 'text-mode-hook-identify)
-
(defun toggle-text-mode-auto-fill ()
"Toggle whether to use Auto Fill in Text mode and related modes.
This command affects all buffers that use modes related to Text mode,
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el
index f25fa87d0ec..f1a42f2b688 100644
--- a/lisp/textmodes/tildify.el
+++ b/lisp/textmodes/tildify.el
@@ -1,9 +1,10 @@
-;;; tildify.el --- adding hard spaces into texts
+;;; tildify.el --- adding hard spaces into texts -*- lexical-binding: t -*-
-;; Copyright (C) 1997-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2015 Free Software Foundation, Inc.
;; Author: Milan Zamazal <pdm@zamazal.org>
-;; Version: 4.5
+;; Michal Nazarewicz <mina86@mina86.com>
+;; Version: 4.6.1
;; Keywords: text, TeX, SGML, wp
;; This file is part of GNU Emacs.
@@ -55,8 +56,21 @@
:version "21.1"
:group 'wp)
-(defcustom tildify-pattern-alist
- '((t "\\([,:;(][ \t]*[a]\\|\\<[AIKOSUVZikosuvz]\\)\\([ \t]+\\|[ \t]*\n[ \t]*\\)\\(\\w\\|[([{\\]\\|<[a-zA-Z]\\)" 2))
+(defcustom tildify-pattern
+ "\\(?:[,:;(][ \t]*[a]\\|\\<[AIKOSUVZikosuvz]\\)\\([ \t]+\\|[ \t]*\n[ \t]*\\)\\(?:\\w\\|[([{\\]\\|<[a-zA-Z]\\)"
+ "A pattern specifying where to insert hard spaces.
+
+`tildify-buffer' function will replace first capturing group of the regexp with
+a hard space (as defined by `tildify-space-string' variable). (Hint: \\(…\\)
+non-capturing groups can be used for grouping prior to the part of the regexp
+matching the white space). The pattern is matched case-sensitive regardless of
+the value of `case-fold-search' setting."
+ :version "25.1"
+ :group 'tildify
+ :type 'string
+ :safe t)
+
+(defcustom tildify-pattern-alist ()
"Alist specifying where to insert hard spaces.
Each alist item is of the form (MAJOR-MODE REGEXP NUMBER) or
@@ -77,16 +91,33 @@ by the hard space character.
The form (MAJOR-MODE . SYMBOL) defines alias item for MAJOR-MODE. For this
mode, the item for the mode SYMBOL is looked up in the alist instead."
:group 'tildify
- :type '(repeat (choice (list symbol regexp integer) (cons symbol symbol))))
-
-(defcustom tildify-string-alist
- '((latex-mode . "~")
- (tex-mode . latex-mode)
- (plain-tex-mode . latex-mode)
- (sgml-mode . "&nbsp;")
- (xml-mode . sgml-mode)
- (html-mode . sgml-mode)
- (t . " "))
+ :type '(repeat (cons :tag "Entry for major mode"
+ (choice (const :tag "Default" t)
+ (symbol :tag "Major mode"))
+ (choice (list :tag "Regexp"
+ regexp
+ (integer :tag "Group "))
+ (symbol :tag "Like other")))))
+(make-obsolete-variable 'tildify-pattern-alist 'tildify-pattern "25.1")
+
+(defcustom tildify-space-string "\u00A0"
+ "Representation of a hard (a.k.a. no-break) space in current major mode.
+
+Used by `tildify-buffer' in places where space is required but line
+cannot be broken. For example \"~\" for TeX or \"&#160;\" for SGML,
+HTML and XML modes. A no-break space Unicode character (\"\\u00A0\")
+might be used for other modes if compatible encoding is used.
+
+If nil, current major mode has no way to represent a hard space."
+ :version "25.1"
+ :group 'tildify
+ :type '(choice (const :tag "Space character (no hard-space representation)"
+ " ")
+ (const :tag "No-break space (U+00A0)" "\u00A0")
+ (string :tag "Custom string"))
+ :safe t)
+
+(defcustom tildify-string-alist ()
"Alist specifying what is a hard space in the current major mode.
Each alist item is of the form (MAJOR-MODE . STRING) or
@@ -98,47 +129,45 @@ MAJOR-MODE defines major mode, for which the item applies. It can be either:
alist item
STRING defines the hard space, which is inserted at places defined by
-`tildify-pattern-alist'. For example it can be \"~\" for TeX or \"&nbsp;\"
-for SGML.
+`tildify-pattern'. For example it can be \"~\" for TeX or \"&nbsp;\" for SGML.
The form (MAJOR-MODE . SYMBOL) defines alias item for MAJOR-MODE. For this
mode, the item for the mode SYMBOL is looked up in the alist instead."
:group 'tildify
- :type '(repeat (cons symbol (choice string symbol))))
-
-(defcustom tildify-ignored-environments-alist
- '((latex-mode
- ("\\\\\\\\" . "") ; do not remove this
- ("\\\\begin{verbatim}" . "\\\\end{verbatim}")
- ("\\\\verb\\*?\\(.\\)" . (1))
- ("\\$\\$" . "\\$\\$")
- ("\\$" . "\\$")
- ("\\\\(" . "\\\\)")
- ("\\\\[[]" . "\\\\[]]")
- ("\\\\begin{math}" . "\\\\end{math}")
- ("\\\\begin{displaymath}" . "\\\\end{displaymath}")
- ("\\\\begin{equation}" . "\\\\end{equation}")
- ("\\\\begin{eqnarray\\*?}" . "\\\\end{eqnarray\\*?}")
- ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "")
- ("%" . "$"))
- (plain-tex-mode . latex-mode)
- (html-mode
- ("<pre[^>]*>" . "</pre>")
- ("<dfn>" . "</dfn>")
- ("<code>" . "</code>")
- ("<samp>" . "</samp>")
- ("<kbd>" . "</kbd>")
- ("<var>" . "</var>")
- ("<PRE[^>]*>" . "</PRE>")
- ("<DFN>" . "</DFN>")
- ("<CODE>" . "</CODE>")
- ("<SAMP>" . "</SAMP>")
- ("<KBD>" . "</KBD>")
- ("<VAR>" . "</VAR>")
- ("<! *--" . "-- *>")
- ("<" . ">"))
- (sgml-mode . html-mode)
- (t nil))
+ :type '(repeat (cons :tag "Entry for major mode"
+ (choice (const :tag "Default" t)
+ (symbol :tag "Major mode"))
+ (choice (const :tag "No-break space (U+00A0)" "\u00A0")
+ (string :tag "String ")
+ (symbol :tag "Like other")))))
+(make-obsolete-variable 'tildify-string-alist
+ 'tildify-space-string "25.1")
+
+(defcustom tildify-foreach-region-function
+ 'tildify--deprecated-ignore-evironments
+ "A function calling a callback on portions of the buffer to tildify.
+
+The function is called from `tildify-buffer' function with three arguments: FUNC
+BEG END. FUNC is a callback accepting two arguments -- REG-BEG REG-END --
+specifying a portion of buffer to operate on.
+
+The BEG and END arguments may be used to limit portion of the buffer being
+scanned, but the `tildify-foreach-region-function' is not required to make use
+of them. IT must, however, terminate as soon as FUNC returns nil.
+
+For example, if `tildify-buffer' function should operate on the whole buffer,
+a simple pass through function could be used:
+ (setq-local tildify-foreach-region-function
+ (lambda (cb beg end) (funcall cb beg end)))
+or better still:
+ (setq-local tildify-foreach-region-function \\='funcall)
+See `tildify-foreach-ignore-environments' function for other ways to use the
+variable."
+ :version "25.1"
+ :group 'tildify
+ :type 'function)
+
+(defcustom tildify-ignored-environments-alist ()
"Alist specifying ignored structured text environments.
Parts of text defined in this alist are skipped without performing hard space
insertion on them. These setting allow skipping text parts like verbatim or
@@ -152,141 +181,165 @@ MAJOR-MODE defines major mode, for which the item applies. It can be either:
- t for default item, this applies to all major modes not defined in another
alist item
-BEG-REGEX is a regexp matching beginning of a text part to be skipped.
-END-REGEX defines end of the corresponding text part and can be either:
-- a regexp matching the end of the skipped text part
-- a list of regexps and numbers, which will compose the ending regexp by
- concatenating themselves, while replacing the numbers with corresponding
- subexpressions of BEG-REGEX (this is used to solve cases like
- \\\\verb<character> in TeX)."
+See `tildify-foreach-ignore-environments' function for description of BEG-REGEX
+and END-REGEX."
:group 'tildify
- :type '(repeat (cons symbol (choice symbol (repeat sexp)))))
-
-
-;;; *** Internal variables ***
-
-(defvar tildify-count nil
- "Counter for replacements.")
+ :type '(repeat
+ (cons :tag "Entry for major mode"
+ (choice (const :tag "Default" t)
+ (symbol :tag "Major mode"))
+ (choice
+ (const :tag "None")
+ (repeat
+ :tag "Environments"
+ (cons :tag "Regexp pair"
+ (regexp :tag "Open ")
+ (choice :tag "Close"
+ (regexp :tag "Regexp")
+ (list :tag "Regexp and groups (concatenated)"
+ (choice (regexp :tag "Regexp")
+ (integer :tag "Group "))))))
+ (symbol :tag "Like other")))))
+(make-obsolete-variable 'tildify-ignored-environments-alist
+ 'tildify-foreach-region-function "25.1")
;;; *** Interactive functions ***
;;;###autoload
-(defun tildify-region (beg end)
+(defun tildify-region (beg end &optional dont-ask)
"Add hard spaces in the region between BEG and END.
-See variables `tildify-pattern-alist', `tildify-string-alist', and
+See variables `tildify-pattern', `tildify-space-string', and
`tildify-ignored-environments-alist' for information about configuration
parameters.
-This function performs no refilling of the changed text."
- (interactive "*r")
- (setq tildify-count 0)
- (let (a
- z
- (marker-end (copy-marker end))
- end-env
- finish
- (ask t)
- (case-fold-search nil)
- (regexp (tildify-build-regexp)) ; beginnings of environments
- aux)
- (if regexp
- ;; Yes, ignored environments exist for the current major mode,
- ;; tildify just texts outside them
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (while (not finish)
- (setq a (point))
- (setq end-env (tildify-find-env regexp))
- (setq z (copy-marker (if end-env (1- (point)) (point-max))))
- (if (>= (marker-position z) beg)
- (progn
- (or (>= a beg) (setq a beg))
- (or (<= (marker-position z) (marker-position marker-end))
- (setq z marker-end))
- (setq aux (tildify-tildify a (marker-position z) ask))
- (if (eq aux 'force)
- (setq ask nil)
- (if (eq aux nil)
- (setq finish t)))))
- (if (>= (marker-position z) (marker-position marker-end))
- (setq finish t))
- (or (>= (point) (marker-position z))
- (goto-char (marker-position z)))
- (if (not finish)
- (if (re-search-forward end-env nil t)
- (if (> (point) (marker-position marker-end))
- (setq finish t))
- (message
- "End of environment not found: %s" end-env)
- (setq finish t))))))
- ;; No ignored environments, tildify directly
- (tildify-tildify beg end ask)))
- (message "%d spaces replaced." tildify-count))
+This function performs no refilling of the changed text.
+If DONT-ASK is set, or called interactively with prefix argument, user
+won't be prompted for confirmation of each substitution."
+ (interactive "*rP")
+ (let (case-fold-search (count 0) (ask (not dont-ask)))
+ (tildify--foreach-region
+ (lambda (beg end)
+ (let ((aux (tildify-tildify beg end ask)))
+ (setq count (+ count (car aux)))
+ (if (not (eq (cdr aux) 'force))
+ (cdr aux)
+ (setq ask nil)
+ t)))
+ beg end)
+ (message "%d spaces replaced." count)))
;;;###autoload
-(defun tildify-buffer ()
+(defun tildify-buffer (&optional dont-ask)
"Add hard spaces in the current buffer.
-See variables `tildify-pattern-alist', `tildify-string-alist', and
+See variables `tildify-pattern', `tildify-space-string', and
`tildify-ignored-environments-alist' for information about configuration
parameters.
-This function performs no refilling of the changed text."
- (interactive "*")
- (tildify-region (point-min) (point-max)))
+This function performs no refilling of the changed text.
+If DONT-ASK is set, or called interactively with prefix argument, user
+won't be prompted for confirmation of each substitution."
+ (interactive "*P")
+ (tildify-region (point-min) (point-max) dont-ask))
;;; *** Auxiliary functions ***
-(defun tildify-build-regexp ()
- "Build start of environment regexp."
- (let ((alist (tildify-mode-alist tildify-ignored-environments-alist))
- regexp)
- (when alist
- (setq regexp (caar alist))
- (setq alist (cdr alist))
- (while alist
- (setq regexp (concat regexp "\\|" (caar alist)))
- (setq alist (cdr alist)))
- regexp)))
-
-(defun tildify-mode-alist (mode-alist &optional mode)
+(defun tildify--pick-alist-entry (mode-alist &optional mode)
"Return alist item for the MODE-ALIST in the current major MODE."
- (if (null mode)
- (setq mode major-mode))
- (let ((alist (cdr (or (assoc mode mode-alist)
+ (let ((alist (cdr (or (assoc (or mode major-mode) mode-alist)
(assoc t mode-alist)))))
(if (and alist
(symbolp alist))
- (tildify-mode-alist mode-alist alist)
+ (tildify--pick-alist-entry mode-alist alist)
alist)))
-
-(defun tildify-find-env (regexp)
+(make-obsolete 'tildify--pick-alist-entry
+ "it should not be used in new code." "25.1")
+
+(defun tildify--deprecated-ignore-evironments (callback beg end)
+ "Call CALLBACK on regions between BEG and END.
+
+Call CALLBACK on each region outside of environment to ignore. Stop scanning
+the region as soon as CALLBACK returns nil. Environments to ignore are
+defined by deprecated `tildify-ignored-environments-alist'. CALLBACK may be
+called on portions of the buffer outside of [BEG END)."
+ (let ((pairs (tildify--pick-alist-entry tildify-ignored-environments-alist)))
+ (if pairs
+ (tildify-foreach-ignore-environments pairs callback beg end)
+ (funcall callback beg end))))
+(make-obsolete 'tildify--deprecated-ignore-evironments
+ "it should not be used in new code." "25.1")
+
+(defun tildify-foreach-ignore-environments (pairs callback _beg end)
+ "Outside of environments defined by PAIRS call CALLBACK.
+
+PAIRS is a list of (BEG-REGEX . END-REGEX) cons. BEG-REGEX is a regexp matching
+beginning of a text part to be skipped. END-REGEX defines end of the
+corresponding text part and can be either:
+- a regexp matching the end of the skipped text part
+- a list of regexps and numbers, which will compose the ending regexp by
+ concatenating themselves, while replacing the numbers with corresponding
+ subexpressions of BEG-REGEX (this is used to solve cases like
+ \\\\verb<character> in TeX).
+
+CALLBACK is a function accepting two arguments -- REG-BEG and REG-END -- that
+will be called for portions of the buffer outside of the environments defined by
+PAIRS regexes.
+
+The function will return as soon as CALLBACK returns nil or point goes past END.
+CALLBACK may be called on portions of the buffer outside of [BEG END); in fact
+BEG argument is ignored.
+
+This function is meant to be used to set `tildify-foreach-region-function'
+variable. For example, for an XML file one might use:
+ (setq-local tildify-foreach-region-function
+ (apply-partially \\='tildify-foreach-ignore-environments
+ \\='((\"<! *--\" . \"-- *>\") (\"<\" . \">\"))))"
+ (let ((beg-re (concat "\\(?:" (mapconcat 'car pairs "\\)\\|\\(?:") "\\)"))
+ p end-re)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (while (and (< (setq p (point)) end)
+ (if (setq end-re (tildify--find-env beg-re pairs))
+ (and (funcall callback p (match-beginning 0))
+ (< (point) end)
+ (re-search-forward end-re nil t))
+ (funcall callback p end)
+ nil)))))))
+
+(defun tildify--foreach-region (callback beg end)
+ "Call CALLBACK on portions of the buffer between BEG and END.
+
+Which portions to call CALLBACK on is determined by
+`tildify-foreach-region-function' variable. This function merely makes sure
+CALLBACK is not called with portions of the buffer outside of [BEG END)."
+ (let ((func (lambda (reg-beg reg-end)
+ (setq reg-beg (max reg-beg beg) reg-end (min reg-end end))
+ (and (or (>= reg-beg reg-end)
+ (funcall callback reg-beg reg-end))
+ (< reg-end end)))))
+ (funcall tildify-foreach-region-function func beg end)))
+
+(defun tildify--find-env (regexp pairs)
"Find environment using REGEXP.
-Return regexp for the end of the environment or nil if no environment was
-found."
+Return regexp for the end of the environment found in PAIRS or nil if
+no environment was found."
;; Find environment
- (if (re-search-forward regexp nil t)
- ;; Build end-env regexp
- (let ((match (match-string 0))
- (alist (tildify-mode-alist tildify-ignored-environments-alist))
- expression)
- (save-match-data
- (while (not (eq (string-match (caar alist) match) 0))
- (setq alist (cdr alist))))
- (if (stringp (setq expression (cdar alist)))
- expression
- (let ((result "")
- aux)
- (while expression
- (setq result (concat result
- (if (stringp (setq aux (car expression)))
- expression
- (regexp-quote (match-string aux)))))
- (setq expression (cdr expression)))
- result)))
- ;; Return nil if not found
- nil))
+ (when (re-search-forward regexp nil t)
+ (save-match-data
+ (let ((match (match-string 0)))
+ (while (not (eq (string-match (caar pairs) match) 0))
+ (setq pairs (cdr pairs)))
+ (let ((expression (cdar pairs)))
+ (if (stringp expression)
+ expression
+ (mapconcat
+ (lambda (expr)
+ (if (stringp expr)
+ expr
+ (regexp-quote (match-string expr match))))
+ expression
+ "")))))))
(defun tildify-tildify (beg end ask)
"Add tilde characters in the region between BEG and END.
@@ -295,20 +348,26 @@ macros.
If ASK is nil, perform replace without asking user for confirmation.
-Returns one of symbols: t (all right), nil (quit), force (replace without
-further questions)."
+Returns (count . response) cons where count is number of string
+replacements done and response is one of symbols: t (all right), nil
+(quit), force (replace without further questions)."
(save-excursion
(goto-char beg)
- (let* ((alist (tildify-mode-alist tildify-pattern-alist))
- (regexp (car alist))
- (match-number (cadr alist))
- (tilde (tildify-mode-alist tildify-string-alist))
- (end-marker (copy-marker end))
- answer
- bad-answer
- replace
- quit
- (message-log-max nil))
+ (let ((regexp tildify-pattern)
+ (match-number 1)
+ (tilde (or (tildify--pick-alist-entry tildify-string-alist)
+ tildify-space-string))
+ (end-marker (copy-marker end))
+ answer
+ bad-answer
+ replace
+ quit
+ (message-log-max nil)
+ (count 0))
+ ;; For the time being, tildify-pattern-alist overwrites tildify-pattern
+ (let ((alist (tildify--pick-alist-entry tildify-pattern-alist)))
+ (when alist
+ (setq regexp (car alist) match-number (cadr alist))))
(while (and (not quit)
(re-search-forward regexp (marker-position end-marker) t))
(when (or (not ask)
@@ -335,21 +394,118 @@ further questions)."
(setq bad-answer t)))
replace))
(replace-match tilde t t nil match-number)
- (setq tildify-count (1+ tildify-count))))
+ (setq count (1+ count))))
;; Return value
+ (cons count (cond (quit nil)
+ ((not ask) 'force)
+ (t t))))))
+
+
+;;; *** Tildify Mode ***
+
+(defcustom tildify-space-pattern "[,:;(][ \t]*[a]\\|\\<[AIKOSUVWZikosuvwz]"
+ "Pattern specifying whether to insert a hard space at point.
+
+If the pattern matches `looking-back', a hard space needs to be inserted instead
+of a space at point. The regexp is always case sensitive, regardless of the
+current `case-fold-search' setting."
+ :version "25.1"
+ :group 'tildify
+ :type 'string)
+
+(defcustom tildify-space-predicates '(tildify-space-region-predicate)
+ "A list of predicate functions for `tildify-space' function."
+ :version "25.1"
+ :group 'tildify
+ :type '(repeat 'function))
+
+(defcustom tildify-double-space-undos t
+ "Weather `tildify-space' should undo hard space when space is typed again."
+ :version "25.1"
+ :group 'tildify
+ :type 'boolean)
+
+;;;###autoload
+(defun tildify-space ()
+ "Convert space before point into a hard space if the context is right.
+
+If
+ * character before point is a space character,
+ * character before that has \"w\" character syntax (i.e. it's a word
+ constituent),
+ * `tildify-space-pattern' matches when `looking-back' (no more than 10
+ characters) from before the space character, and
+ * all predicates in `tildify-space-predicates' return non-nil,
+replace the space character with value of `tildify-space-string' and
+return t.
+
+Otherwise, if
+ * `tildify-double-space-undos' variable is non-nil,
+ * character before point is a space character, and
+ * text before that is a hard space as defined by
+ `tildify-space-string' variable,
+remove the hard space and leave only the space character.
+
+This function is meant to be used as a `post-self-insert-hook'."
+ (interactive)
+ (let* ((p (point)) (p-1 (1- p)) (n (- p (point-min)))
+ (l (length tildify-space-string)) (l+1 (1+ l))
+ case-fold-search)
+ (when (and (> n 2) (eq (preceding-char) ?\s))
(cond
- (quit nil)
- ((not ask) 'force)
- (t t)))))
+ ((and (eq (char-syntax (char-before p-1)) ?w)
+ (save-excursion
+ (goto-char p-1)
+ (looking-back tildify-space-pattern (max (point-min) (- p 10))))
+ (run-hook-with-args-until-failure 'tildify-space-predicates))
+ (delete-char -1)
+ (insert tildify-space-string)
+ t)
+ ((and tildify-double-space-undos
+ (> n l+1)
+ (string-equal tildify-space-string
+ (buffer-substring (- p l+1) p-1)))
+ (goto-char p-1)
+ (delete-char (- l))
+ (goto-char (1+ (point)))
+ nil)))))
+
+(defun tildify-space-region-predicate ()
+ "Check whether character before point should be tildified.
+Based on `tildify-foreach-region-function', check whether character before,
+which is assumed to be a space character, should be replaced with a hard space."
+ (catch 'found
+ (tildify--foreach-region (lambda (_b _e) (throw 'found t)) (1- (point)) (point))))
+
+;;;###autoload
+(define-minor-mode tildify-mode
+ "Adds electric behaviour to space character.
+
+When space is inserted into a buffer in a position where hard space is required
+instead (determined by `tildify-space-pattern' and `tildify-space-predicates'),
+that space character is replaced by a hard space specified by
+`tildify-space-string'. Converting of the space is done by `tildify-space'.
+
+When `tildify-mode' is enabled, if `tildify-string-alist' specifies a hard space
+representation for current major mode, the `tildify-space-string' buffer-local
+variable will be set to the representation."
+ nil " ~" nil
+ (when tildify-mode
+ (let ((space (tildify--pick-alist-entry tildify-string-alist)))
+ (if (not (string-equal " " (or space tildify-space-string)))
+ (when space
+ (setq tildify-space-string space))
+ (message (eval-when-compile
+ (concat "Hard space is a single space character, tildify-"
+ "mode won't have any effect, disabling.")))
+ (setq tildify-mode nil))))
+ (if tildify-mode
+ (add-hook 'post-self-insert-hook 'tildify-space nil t)
+ (remove-hook 'post-self-insert-hook 'tildify-space t)))
;;; *** Announce ***
(provide 'tildify)
-
-;; Local variables:
-;; coding: utf-8
-;; End:
-
;;; tildify.el ends here
diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el
index 23e90552096..4133e0fa126 100644
--- a/lisp/textmodes/two-column.el
+++ b/lisp/textmodes/two-column.el
@@ -1,6 +1,6 @@
;;; two-column.el --- minor mode for editing of two-column text
-;; Copyright (C) 1992-1995, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1995, 2001-2015 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Adapted-By: ESR, Daniel Pfeiffer
@@ -349,6 +349,9 @@ accepting the proposed default buffer.
(if b1 (setq 2C-window-width (- (frame-width) b1)))
(2C-two-columns b2)))
+(autoload 'scroll-bar-columns "scroll-bar")
+(eval-when-compile
+ (require 'fringe)) ; fringe-columns defsubst
;;;###autoload
(defun 2C-split (arg)
@@ -370,9 +373,8 @@ First column's text sSs Second column's text
\(See \\[describe-mode] .)"
(interactive "*p")
(and (2C-other)
- (if (y-or-n-p (concat "Overwrite associated buffer `"
- (buffer-name (2C-other))
- "'? "))
+ (if (y-or-n-p (format-message "Overwrite associated buffer `%s'? "
+ (buffer-name (2C-other))))
(with-current-buffer (2C-other)
(erase-buffer))
(signal 'quit nil)))
diff --git a/lisp/textmodes/underline.el b/lisp/textmodes/underline.el
index 485ccd80ac8..b97fdfded14 100644
--- a/lisp/textmodes/underline.el
+++ b/lisp/textmodes/underline.el
@@ -1,8 +1,8 @@
;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs
-;; Copyright (C) 1985, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2015 Free Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; This file is part of GNU Emacs.