From 9bd4f69c5df4a6206b680a04fc9482826ab6a3e6 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 9 Mar 1998 06:36:25 +0000 Subject: [PATCH] (latex-mode): Set fill-nobreak-predicate. (slitex-mode): Set fill-nobreak-predicate, tex-face-alist, and imenu-create-index-function. (latex-fill-nobreak-predicate): New function. --- lisp/textmodes/tex-mode.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index f599c581540..8da1916fff8 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -565,6 +565,8 @@ subshell is initiated, `tex-shell-hook' is run." (setq imenu-create-index-function 'latex-imenu-create-index) (make-local-variable 'tex-face-alist) (setq tex-face-alist tex-latex-face-alist) + (make-local-variable 'fill-nobreak-predicate) + (setq fill-nobreak-predicate 'latex-fill-nobreak-predicate) (run-hooks 'text-mode-hook 'tex-mode-hook 'latex-mode-hook)) ;;;###autoload @@ -638,6 +640,12 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook \\\\[a-z]*space[ \t]*$\\|\\\\[a-z]*skip[ \t]*$\\|\ \\\\newpage[ \t]*$\\|\\\\[a-z]*page[a-z]*[ \t]*$\\|\\\\footnote[ \t]*$\\|\ \\\\marginpar[ \t]*$\\|\\\\parbox[ \t]*$\\|\\\\caption[ \t]*$") + (make-local-variable 'imenu-create-index-function) + (setq imenu-create-index-function 'latex-imenu-create-index) + (make-local-variable 'tex-face-alist) + (setq tex-face-alist tex-latex-face-alist) + (make-local-variable 'fill-nobreak-predicate) + (setq fill-nobreak-predicate 'latex-fill-nobreak-predicate) (run-hooks 'text-mode-hook 'tex-mode-hook 'latex-mode-hook 'slitex-mode-hook)) @@ -879,6 +887,21 @@ A prefix arg inhibits the checking." (save-excursion (insert ?}))) +;; This function is used as the value of fill-nobreak-predicate +;; in LaTeX mode. Its job is to prevent line-breaking inside +;; of a \verb construct. +(defun latex-fill-nobreak-predicate () + (let ((opoint (point)) + inside) + (save-excursion + (save-restriction + (beginning-of-line) + (narrow-to-region (point) opoint) + (while (re-search-forward "\\\\verb\\(.\\)" nil t) + (unless (re-search-forward (regexp-quote (match-string 1)) nil t) + (setq inside t))))) + inside)) + ;;; Like tex-insert-braces, but for LaTeX. (define-skeleton tex-latex-block "Create a matching pair of lines \\begin[OPT]{NAME} and \\end{NAME} at point. -- 2.39.2