diff options
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/bibtex.el | 4 | ||||
-rw-r--r-- | lisp/textmodes/conf-mode.el | 3 | ||||
-rw-r--r-- | lisp/textmodes/css-mode.el | 79 | ||||
-rw-r--r-- | lisp/textmodes/enriched.el | 3 | ||||
-rw-r--r-- | lisp/textmodes/ispell.el | 195 | ||||
-rw-r--r-- | lisp/textmodes/paragraphs.el | 4 | ||||
-rw-r--r-- | lisp/textmodes/reftex-auc.el | 14 | ||||
-rw-r--r-- | lisp/textmodes/reftex-cite.el | 15 | ||||
-rw-r--r-- | lisp/textmodes/reftex-dcr.el | 8 | ||||
-rw-r--r-- | lisp/textmodes/reftex-global.el | 13 | ||||
-rw-r--r-- | lisp/textmodes/reftex-index.el | 14 | ||||
-rw-r--r-- | lisp/textmodes/reftex-parse.el | 46 | ||||
-rw-r--r-- | lisp/textmodes/reftex-ref.el | 19 | ||||
-rw-r--r-- | lisp/textmodes/reftex-sel.el | 26 | ||||
-rw-r--r-- | lisp/textmodes/reftex-toc.el | 19 | ||||
-rw-r--r-- | lisp/textmodes/reftex.el | 840 | ||||
-rw-r--r-- | lisp/textmodes/remember.el | 33 | ||||
-rw-r--r-- | lisp/textmodes/rst.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 45 | ||||
-rw-r--r-- | lisp/textmodes/tex-mode.el | 37 | ||||
-rw-r--r-- | lisp/textmodes/texnfo-upd.el | 52 | ||||
-rw-r--r-- | lisp/textmodes/tildify.el | 515 |
22 files changed, 1462 insertions, 524 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index abb98516441..5933559b37c 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -4840,7 +4840,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))) @@ -4852,7 +4852,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) diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index aae03d32ee5..b6bea218626 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el @@ -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 () diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index c04c6a36e6a..c171bd50f62 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -185,7 +185,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) @@ -210,11 +210,15 @@ "\\\\\\(?:[^\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-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 +228,44 @@ (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 the + ;; 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 "[^:{}#]*\\)*")) + "\\(?::" (regexp-opt css-pseudo-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 @@ -260,6 +284,8 @@ "\\)\\s-*:") (1 (if (match-end 2) 'css-proprietary-property 'css-property))))) +(defvar css-font-lock-keywords (css--font-lock-keywords)) + (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) @@ -277,6 +303,7 @@ (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))) @@ -293,7 +320,8 @@ (forward-comment (- (point))) (cond ;; FIXME: If the next char is not whitespace, what should we do? - ((and (eq (char-before) ?\}) (> pos (point))) ";") + ((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))))) @@ -315,7 +343,6 @@ (setq-local comment-end "*/") (setq-local comment-end-skip "[ \t]*\\*+/") (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 add-log-current-defun-function #'css-current-defun-name) (smie-setup css-smie-grammar #'css-smie-rules @@ -406,5 +433,35 @@ (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-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/enriched.el b/lisp/textmodes/enriched.el index b9d45b3a32f..040a50e3099 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el @@ -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/ispell.el b/lisp/textmodes/ispell.el index 81d8078df40..82a09a0f89a 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -931,16 +931,14 @@ 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))) @@ -2211,16 +2209,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 +2229,27 @@ 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 "\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 +2264,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 @@ -2408,18 +2394,13 @@ Global `ispell-quit' set to start location to continue spell session." (or ispell-complete-word-dict ispell-alternate-dictionary)) miss (ispell-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)) + 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 +2409,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 +2471,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 +2553,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 @@ -2818,49 +2775,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) @@ -2939,8 +2882,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 "~/"))) @@ -2998,8 +2940,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")) diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index b18a93cd3e6..8bcc71ed531 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -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 () diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el index 08b38cfa1a7..bbad065c4ba 100644 --- a/lisp/textmodes/reftex-auc.el +++ b/lisp/textmodes/reftex-auc.el @@ -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 328064271f8..fa09efb64a4 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el @@ -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 @@ -452,6 +457,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. @@ -604,6 +610,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 +794,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 +1067,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)) @@ -1151,6 +1161,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 @@ -1244,3 +1255,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 2957692dc5c..60cb1f65257 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el @@ -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 03bf009bb12..15d42fe7b02 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el @@ -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 b5a3e05867e..b1aff428278 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el @@ -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. @@ -1244,6 +1251,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 +1266,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 +1354,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 +2106,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 4dc20c4fa8f..7f186afc27c 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -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)) @@ -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) @@ -359,6 +365,7 @@ of master file." (save-excursion (re-search-forward "^[^%\n]*?\\\\usepackage.*{biblatex}" nil t)))) +;;;###autoload (defun reftex-locate-bibliography-files (master-dir &optional files) "Scan buffer for bibliography macros and return file list." (unless files @@ -421,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!" @@ -457,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' @@ -472,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!" @@ -525,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." @@ -585,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 @@ -683,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 @@ -759,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)) @@ -781,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. @@ -848,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 @@ -885,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. @@ -925,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 @@ -944,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." @@ -982,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) '(?\[ ?\{)) @@ -1021,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)) @@ -1039,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." @@ -1107,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 0767b567c31..be119d9db58 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -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. @@ -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." @@ -867,3 +878,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 cd166735e27..643dbfb5a35 100644 --- a/lisp/textmodes/reftex-sel.el +++ b/lisp/textmodes/reftex-sel.el @@ -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 697cdfc929d..69cab782315 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -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,6 +190,7 @@ 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).") +;;;###autoload (defun reftex-toc (&optional rebuild reuse) "Show the table of contents for the current document. When called with a raw C-u prefix, rescan the document first." @@ -240,13 +241,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,7 +279,7 @@ 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) 'font-lock-face reftex-toc-header-face)) (put-text-property (point-min) (point) 'intangible t) (put-text-property (point-min) (1+ (point-min)) 'xr-alist xr-alist) @@ -319,6 +320,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") @@ -372,8 +374,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) @@ -1009,6 +1011,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 +1091,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.el b/lisp/textmodes/reftex.el index 97dd36ae9e8..160d9fb4cdf 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -70,141 +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" - "Create a new BibTeX database BIBFILE with all entries referenced in document." - t) - -;; 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") - ;;; ========================================================================= ;;; @@ -2493,6 +2378,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" "5a53c260fa01268c04ea2f558add9d7d") +;;; 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" "d80e84d499050e32569a454d8db16861") +;;; 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" "c327a848a6d168412b1a9be9f2e3dce8") +;;; 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" "64cd7a4eaec426177a8fb3689139d935") +;;; 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" "e04344fac7ba4c2043439e130bdd283f") +;;; 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 31bcb34314d..35eaffa9284 100644 --- a/lisp/textmodes/remember.el +++ b/lisp/textmodes/remember.el @@ -319,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." @@ -461,8 +459,7 @@ Used by `remember-store-in-files'." "Store remember data in a file in `remember-data-directory'. 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 (current-time))) + (let ((name (format-time-string remember-directory-file-name-format)) (text (buffer-string))) (with-temp-buffer (insert text) @@ -499,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 @@ -511,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))) diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index fcaf85508a5..cda9703ea6b 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el @@ -3121,7 +3121,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) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 7dd9c8a6ed2..12d98c8238a 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -240,12 +240,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." @@ -447,6 +456,9 @@ 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. @@ -468,6 +480,27 @@ 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 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) " ") + " " " ")) + ;; 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 diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index fa149c6ae2b..e9c7e2f114e 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1203,9 +1203,32 @@ 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) + (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, @@ -2603,18 +2626,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)) diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el index 6a63108a134..df05b670095 100644 --- a/lisp/textmodes/texnfo-upd.el +++ b/lisp/textmodes/texnfo-upd.el @@ -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. diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 08c2f074c2d..0eae67ae83a 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-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 . " ") - (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 \" \" 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 \" \" -for SGML. +`tildify-pattern'. For example it can be \"~\" for TeX or \" \" 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,12 +394,114 @@ 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 *** |