File: patch-texinfmt.el-20.3

package info (click to toggle)
emacs-manual-ja 20.5-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,964 kB
  • ctags: 12
  • sloc: lisp: 119; ansic: 69; makefile: 43; sh: 28
file content (124 lines) | stat: -rw-r--r-- 3,666 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
*** texinfmt.el-ORIG	Mon Jul  6 09:11:32 1998
--- texinfmt.el	Fri Oct 30 16:14:55 1998
***************
*** 1105,1110 ****
--- 1105,1182 ----
  
  ;;; @node, @menu, @detailmenu
  
+ ; section levels taken from makeinfo.c
+ (defconst texinfo-format-node-levels
+   '( ("unnumberedsubsubsec" . 5)
+      ("unnumberedsubsec" . 4)
+      ("unnumberedsec" . 3)
+      ("unnumbered" . 2)
+      ("appendixsubsubsec" . 5)
+      ("appendixsubsec" . 4)
+      ("appendixsec" . 3)
+      ("appendixsection" . 3)
+      ("appendix" . 2)
+      ("subsubsec" . 5)
+      ("subsubsection" . 5)
+      ("subsection" . 4)
+      ("section" . 3)
+      ("chapter" . 2)
+      ("top" . 1)))
+ 
+ (defvar texinfo-format-node:*level-name
+   (vector nil nil nil nil nil nil))
+ 
+ (defun texinfo-format-node-find-level ()
+   (let (level)
+     (save-excursion
+       (forward-line 1)
+       (while (null level)
+ 	(let (pos)
+ 	  (if (setq pos (re-search-forward "^@[a-zA-Z0-9]+" nil t))
+ 	      (setq level (assoc (buffer-substring
+ 				  (progn (beginning-of-line)
+ 					 (forward-char 1)
+ 					 (point))
+ 				  pos)
+ 				 texinfo-format-node-levels))
+ 	    (setq level t)))))
+     (if (eq level t)
+ 	0
+       (cdr level))))
+ 
+ 
+ (defun texinfo-format-node-find-next (level)
+   (let (node-pos node-name (done nil))
+     (save-excursion
+       (while (null done)
+ 	(forward-line 1)
+ 	(if (setq node-pos (re-search-forward "^@node  *" nil t))
+ 	    (let (next)
+ 	      (setq node-name
+ 		    (buffer-substring
+ 		     node-pos
+ 		     (progn (re-search-forward "$\\|,")
+ 			    (forward-char -1)
+ 			    (unless (eq (following-char) ?,)
+ 			      (forward-char 1))
+ 			    (point))))
+ 	      (if (eq (following-char) ?,)
+ 		  (setq done t
+ 			node-name nil)
+ 		(forward-line 1)
+ 		(if (integerp (setq next (texinfo-format-node-find-level)))
+ 		    (if (= next level)
+ 			(setq done t)
+ 		      (if (< next level)
+ 			  (setq done t
+ 				node-name nil)
+ 			(setq node-name nil)))
+ 		  (setq node-name nil))))
+ 	  ;; re-search-foward failed
+ 	  (setq done t
+ 		node-name nil))))
+   node-name))
+ 
  (put 'node 'texinfo-format 'texinfo-format-node)
  (put 'nwnode 'texinfo-format 'texinfo-format-node)
  (defun texinfo-format-node ()
***************
*** 1112,1118 ****
           (name (nth 0 args))
           (next (nth 1 args))
           (prev (nth 2 args))
!          (up (nth 3 args)))
      (texinfo-discard-command)
      (setq texinfo-last-node name)
      (let ((tem (downcase name)))
--- 1184,1214 ----
           (name (nth 0 args))
           (next (nth 1 args))
           (prev (nth 2 args))
!          (up (nth 3 args))
! 	 (level (texinfo-format-node-find-level)))
!     ;; XXX -- beginning of make node links
!     (if (and (integerp level) (> level 0))
! 	(let ((i (1+ level)))
! 	  (while (<= i 5)
! 	    (aset texinfo-format-node:*level-name
! 		  i nil)
! 	    (setq i (1+ i)))
! 	  (if (and name next prev up)
! 	      ;; set up default for descending nodes
! 	      (progn (aset texinfo-format-node:*level-name
! 			   level name)
! 		     (aset texinfo-format-node:*level-name
! 			   (1- level) up))
! 	    ;; only node name without next, prev, up
! 	    (unless up (setq up (aref texinfo-format-node:*level-name
! 				      (1- level))))
! 	    (unless prev (setq prev (aref texinfo-format-node:*level-name
! 					  level)))
! 	    (aset texinfo-format-node:*level-name
! 		  level name)
! 	    (unless next 
! 	      (setq next (texinfo-format-node-find-next level))))))
!     ;; XXX --  end of make node links
      (texinfo-discard-command)
      (setq texinfo-last-node name)
      (let ((tem (downcase name)))