changeset 15240:21998d33460f

(latex-imenu-create-index): Change the regexp to match the * versions of commands. (latex-mode): Make imenu-create-index-function buffer-local.
author Richard M. Stallman <rms@gnu.org>
date Wed, 15 May 1996 15:17:41 +0000
parents 299516818a79
children 9304a470dd2d
files lisp/textmodes/tex-mode.el
diffstat 1 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/tex-mode.el	Wed May 15 14:56:35 1996 +0000
+++ b/lisp/textmodes/tex-mode.el	Wed May 15 15:17:41 1996 +0000
@@ -179,19 +179,23 @@
 (defvar tex-mode-syntax-table nil
   "Syntax table used while in TeX mode.")
 
-;; Written by Wolfgang Bangerth <zcg51122@rpool1.rus.uni-stuttgart.de>
-(defvar latex-imenu-generic-expression
-  '(
-    ("Part" "\\\\part{\\([^}]*\\)}" 1)
-    ("Chapter" "\\\\chapter{\\([^}]*\\)}" 1)
-    ("Section" "\\\\[a-zA-Z]*section{\\([^}]*\\)}" 1)
-    ;; i put numbers like 3.15 before my
-    ;; \begin{equation}'s which tell me
-    ;; the number the equation will get when
-    ;; being printed.
-    ("Equations" "%[ \t]*\\([0-9]+\\.[0-9]+\\)[,;]?[ \t]?" 1))  
-
-  "Imenu generic expression for LaTex mode.  See `imenu-generic-expression'.")
+(defun latex-imenu-create-index ()
+  "Generates an alist for imenu from a LaTeX buffer."
+  (let (result temp)
+    (goto-char (point-max))
+    (while (re-search-backward "\\\\\\(part\\|chapter\\|\
+\\(sub\\)?\\(\\(sub\\)?section\\|paragraph\\)\\)\\*?[ \t\n]*{\\([^}]*\\)}" nil t)
+      (setq temp
+	    (assoc (buffer-substring-no-properties (match-beginning 1)
+						   (match-end 1)) 
+		   '(("part" . "") ("chapter" . " ")
+		     ("section" . "  ") ("subsection" . "   ")
+		     ("subsubsection" . "    ")
+		     ("paragraph" . "     ") ("subparagraph" . "      "))))
+      (setq result (cons (cons (concat (cdr temp) (match-string 5)) 
+			       (match-beginning 0))
+			 result)))
+    result))
 
 (defun tex-define-common-keys (keymap)
   "Define the keys that we want defined both in TeX mode and in the TeX shell."
@@ -430,8 +434,8 @@
 \\\\[a-z]*space\\|\\\\[a-z]*skip\\|\
 \\\\newpage\\|\\\\[a-z]*page[a-z]*\\|\\\\footnote\\|\
 \\\\marginpar\\|\\\\parbox\\|\\\\caption\\)[ \t]*\\($\\|%\\)")
-  (make-local-variable 'imenu-generic-expression)
-  (setq imenu-generic-expression latex-imenu-generic-expression)
+  (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)
   (run-hooks 'text-mode-hook 'tex-mode-hook 'latex-mode-hook))