changeset 50135:167c56f6d789

(texinfo-outline-level): Remove. (texinfo-mode): Set outline-heading-alist instead. (texinfo-section-list): Reorder for the needs of outline-heading-alist. (texinfo-insert-block): Don't cons needlessly. (texinfo-enable-quote-macros, texinfo-enable-quote-envs): New vars. (texinfo-insert-quote): Use them.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 14 Mar 2003 22:29:13 +0000
parents de92ccad3ff8
children ad28e7a35442
files lisp/textmodes/texinfo.el
diffstat 1 files changed, 30 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/texinfo.el	Fri Mar 14 21:56:25 2003 +0000
+++ b/lisp/textmodes/texinfo.el	Fri Mar 14 22:29:13 2003 +0000
@@ -28,6 +28,7 @@
 ;;; Todo:
 
 ;; - facemenu support.
+;; - command completion. 
 
 ;;; Commentary:
 
@@ -265,22 +266,22 @@
 
 (defvar texinfo-section-list
   '(("top" 1)
-    ("majorheading" 2)
     ("chapter" 2)
+    ("section" 3)
+    ("subsection" 4)
+    ("subsubsection" 5)
     ("unnumbered" 2)
+    ("unnumberedsec" 3)
+    ("unnumberedsubsec" 4)
+    ("unnumberedsubsubsec" 5)
     ("appendix" 2)
-    ("chapheading" 2)
-    ("section" 3)
-    ("unnumberedsec" 3)
     ("appendixsec" 3)
+    ("appendixsubsec" 4)
+    ("appendixsubsubsec" 5)
+    ("majorheading" 2)
+    ("chapheading" 2)
     ("heading" 3)
-    ("subsection" 4)
-    ("unnumberedsubsec" 4)
-    ("appendixsubsec" 4)
     ("subheading" 4)
-    ("subsubsection" 5)
-    ("unnumberedsubsubsec" 5)
-    ("appendixsubsubsec" 5)
     ("subsubheading" 5))
   "Alist of sectioning commands and their relative level.")
 
@@ -384,19 +385,6 @@
 		 (concat (regexp-quote (buffer-substring start end)) "\\>"))
 	    (text-clone-create start end 'spread "\\w*")))))))
 
-(defun texinfo-outline-level ()
-  ;; Calculate level of current texinfo outline heading.
-  (save-excursion
-    (if (bobp)
-        0
-      (forward-char 1)
-      (let* ((word (buffer-substring-no-properties
-                    (point) (progn (forward-word 1) (point))))
-             (entry (assoc word texinfo-section-list)))
-        (if entry
-            (nth 1 entry)
-          5)))))
-
 
 ;;; Keybindings
 (defvar texinfo-mode-map nil)
@@ -613,11 +601,17 @@
 				     (font-lock-syntactic-keywords
 				      . texinfo-font-lock-syntactic-keywords)))
   (set (make-local-variable 'parse-sexp-lookup-properties) t)
-  (make-local-variable 'outline-regexp)
-  (setq outline-regexp
-        (concat "@" (regexp-opt (mapcar 'car texinfo-section-list) t) "\\>"))
-  (make-local-variable 'outline-level)
-  (setq outline-level 'texinfo-outline-level)
+
+  ;; Outline settings.
+  (set (make-local-variable 'outline-heading-alist)
+       ;; We should merge outline-heading-alist and texinfo-section-list
+       ;; but in the mean time, let's just generate one from the other.
+       (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
+	       texinfo-section-list))
+  (set (make-local-variable 'outline-regexp)
+       (concat (regexp-opt (mapcar 'car outline-heading-alist) t)
+	       "\\>"))
+
   (make-local-variable 'tex-start-of-header)
   (setq tex-start-of-header "%\\*\\*start")
   (make-local-variable 'tex-end-of-header)
@@ -646,7 +640,7 @@
 Puts point on a blank line between them."
   (setq texinfo-block-default
 	(completing-read (format "Block name [%s]: " texinfo-block-default)
-			 (mapcar 'list texinfo-environments)
+			 texinfo-environments
 			 nil nil nil nil texinfo-block-default))
   \n "@" str \n _ \n "@end " str \n)
 
@@ -672,6 +666,8 @@
     (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t)
 	 (not (match-end 1)))))
 
+(defvar texinfo-enable-quote-macros '("@\\(code\\|samp\\|kbd\\)\\>"))
+(defvar texinfo-enable-quote-envs '("example\\>" "lisp\\>"))
 (defun texinfo-insert-quote (&optional arg)
   "Insert the appropriate quote mark for TeXinfo.
 Usually inserts the value of `texinfo-open-quote' (normally ``) or
@@ -688,9 +684,11 @@
 			(looking-at texinfo-close-quote))
 		(delete-char (length texinfo-open-quote))
 		t))
-	    (texinfo-inside-macro-p "@\\(code\\|samp\\|kbd\\)\\>" top)
-	    (texinfo-inside-env-p "example\\>" top)
-	    (texinfo-inside-env-p "lisp\\>" top))
+	    (texinfo-inside-macro-p texinfo-enable-quote-macros top)
+	    (let ((in-env nil))
+	      (dolist (env texinfo-enable-quote-envs in-env)
+		(if (texinfo-inside-env-p env top)
+		    (setq in-env t)))))
 	(self-insert-command (prefix-numeric-value arg))
       (insert
        (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ ))