changeset 21121:dd5c2baa6674

(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.
author Richard M. Stallman <rms@gnu.org>
date Mon, 09 Mar 1998 06:36:25 +0000
parents 116fb3c03737
children 912cc3491589
files lisp/textmodes/tex-mode.el
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/tex-mode.el	Mon Mar 09 05:26:05 1998 +0000
+++ b/lisp/textmodes/tex-mode.el	Mon Mar 09 06:36:25 1998 +0000
@@ -565,6 +565,8 @@
   (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 @@
 \\\\[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 @@
   (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.