home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / docs.lha / latexinfo / elisp / latexnfo-upd.elc (.txt) < prev    next >
Encoding:
LaTeX Document  |  1992-02-26  |  39.1 KB  |  488 lines

  1. (defun latexinfo-make-menu (&optional region-p) "\
  2. Without any prefix argument, make or update a menu.
  3. Make the menu for the section enclosing the node found following point.
  4. Non-nil argument (prefix, if interactive) means make or update menus
  5. for nodes within or part of the marked region.
  6. Whenever a menu exists, and is being updated, the descriptions that
  7. are associated with node names in the pre-existing menu are
  8. incorporated into the new menu.  Otherwise, the nodes' section titles
  9. are inserted as descriptions." (interactive "P") (byte-code "
  10. " [region-p level beginning region-end nil latexinfo-hierarchic-level latexinfo-make-one-menu message "Done...updated the menu.  You may save the buffer." "Making or updating menus in %s... " buffer-name region-beginning error "Please mark a region!" widen latexinfo-find-lower-level-node latexinfo-find-higher-level-node "Done...updated menus.  You may save the buffer."] 22))
  11. (defun latexinfo-make-one-menu (level) "\
  12. Make a menu of all the appropriate nodes in this section.
  13. `Appropriate nodes' are those associated with sections that are 
  14. at the level specified by LEVEL.  Point is left at the end of menu." (byte-code "
  15. " [case-fold-search t beginning level end first node-name new-menu-list latexinfo-update-menu-region-beginning end-of-line latexinfo-update-menu-region-end latexinfo-menu-first-node beginning-of-line latexinfo-copy-node-name latexinfo-make-menu-list latexinfo-old-menu-p latexinfo-incorporate-descriptions latexinfo-delete-old-menu latexinfo-insert-menu] 13))
  16. (defun latexinfo-all-menus-update (&optional update-all-nodes-p) "\
  17. Update every regular menu in a Latexinfo file.
  18. Update pre-existing master menu, if there is one.
  19. If called with a non-nil argument, this function first updates all the
  20. nodes in the buffer before updating the menus.
  21. If called with a non-nil argument of 'sequential, this function first 
  22. sequentially updates all the nodes in the buffer before updating the menus.
  23. " (interactive "P") (byte-code "
  24. " [master-menu-p latexinfo-master-menu-header nil t end-of-detailed-menu-descriptions update-all-nodes-p mark-whole-buffer message "Checking for a master menu in %s ... " buffer-name re-search-forward match-beginning 0 latexinfo-menu-end beginning-of-line forward-char -1 delete-region "Updating all nodes in %s ... " sleep-for 2 equal sequential latexinfo-sequential-node-update latexinfo-update-node "Updating all menus in %s ... " latexinfo-make-menu "Updating the master menu in %s... " latexinfo-master-menu "Done...updated all the menus.  You may save the buffer."] 27))
  25. (defun latexinfo-find-lower-level-node (level region-end) "\
  26. Search forward from point for node at any level lower than LEVEL.
  27. Search is limited to the end of the marked region, REGION-END, 
  28. and to the end of the menu region for the level.
  29. Return t if the node is found, else nil.  Leave point at the beginning
  30. of the node if one is found; else do not move point." (byte-code "`
  31. \"A!%
  32. " [region-end level latexinfo-update-menu-lower-regexps t re-search-forward concat "\\(^\\\\node\\).*
  33. " "\\(\\(\\(^\\\\c\\).*
  34. \\)" "\\|" "\\(^\\\\begin{ifinfo}[ ]*
  35. \\)\\)?" eval assoc latexinfo-update-menu-region-end match-beginning 1] 10))
  36. (defun latexinfo-find-higher-level-node (level region-end) "\
  37. Search forward from point for node at any higher level than argument LEVEL.
  38. Search is limited to the end of the marked region, REGION-END.
  39. Return t if the node is found, else nil.  Leave point at the beginning
  40. of the node if one is found; else do not move point." (byte-code "
  41. \"A!%    
  42. " [level region-end t latexinfo-update-menu-higher-regexps string-equal "top" "chapter" re-search-forward "^\\\\node [     ]*top[     ]*\\(,\\|$\\)" beginning-of-line concat "\\(^\\\\node\\).*
  43. " "\\(\\(\\(^\\\\c\\).*
  44. \\)" "\\|" "\\(^\\\\begin{ifinfo}[ ]*
  45. \\)\\)?" eval assoc] 14))
  46. (defun latexinfo-make-menu-list (beginning end level) "\
  47. Make a list of node names and their descriptions.
  48. Point is left at the end of the menu region, but the menu is not inserted.
  49. First argument is position from which to start making menu list; 
  50. second argument is end of region in which to try to locate entries;
  51. third argument is the level of the nodes that are the entries.
  52. Node names and descriptions are dotted pairs of strings.  Each pair is
  53. an element of the list.  If the description does not exist, the
  54. element consists only of the node name." (byte-code "
  55. " [beginning new-menu-list level end nil latexinfo-menu-locate-entry-p latexinfo-copy-node-name latexinfo-copy-section-title reverse] 6))
  56. (defun latexinfo-menu-locate-entry-p (level search-end) "\
  57. Find a node that will be part of menu for this section.
  58. First argument is a string such as \"section\" specifying the general
  59. hierarchical level of the menu; second argument is a postion
  60. specifying the end of the search.
  61. The function returns t if the node is found, else nil.  It searches
  62. forward from point, and leaves point at the beginning of the node.
  63. The function finds entries of the same type.  Thus `subsections' and
  64. `unnumberedsubsecs' will appear in the same menu." (byte-code "
  65.     \"A!%
  66. " [level latexinfo-update-menu-same-level-regexps search-end t re-search-forward concat "\\(^\\\\node\\).*
  67. " "\\(\\(\\(^\\\\c\\).*
  68. \\)" "\\|" "\\(^\\\\begin{ifinfo}[ ]*
  69. \\)\\)?" eval assoc match-beginning 1] 10))
  70. (defun latexinfo-copy-node-name nil "\
  71. Return the node name as a string.
  72. Start with point at the beginning of the node line; copy the text
  73. after the node command up to the first comma on the line, if any, and
  74. return the text as a string.  Leaves point at the beginning of the
  75. line.  If there is no node name, returns an empty string." (byte-code "
  76. " [t buffer-substring forward-word 1 skip-chars-forward "     " search-forward "," end-of-line] 9))
  77. (defun latexinfo-copy-section-title nil "\
  78. Return the title of the section as a string.
  79. The title is used as a description line in the menu when one does not
  80. already exist.
  81. Move point to the beginning of the appropriate section line by going
  82. to the start of the text matched by last regexp searched for, which
  83. must have been done by `latexinfo-menu-locate-entry-p'." (byte-code "
  84. " [match-beginning 7 forward-word 1 skip-chars-forward "     " buffer-substring forward-sexp] 7))
  85. (defun latexinfo-old-menu-p (beginning first) "\
  86. Move point to the beginning of the menu for this section, if any.
  87. Otherwise move point to the end of the first node of this section.
  88. Return t if a menu is found, nil otherwise.
  89. First argument is the position of the beginning of the section in which
  90. the menu will be located; second argument is the position of the first
  91. node within the section.
  92. If no menu is found, the function inserts two newlines just before the
  93. end of the section, and leaves point there where a menu ought to be." (byte-code "
  94. " [beginning first nil t re-search-forward "^\\\\begin{menu}" goto-end "
  95. " forward-line -2] 4))
  96. (defun latexinfo-incorporate-descriptions (new-menu-list) "\
  97. Copy the old menu line descriptions that exist to the new menu.
  98. Point must be at beginning of old menu.
  99. If the node-name of the new menu entry cannot be found in the old
  100. menu, use the new section title for the description, but if the
  101. node-name of the new menu is found in the old menu, replace the
  102. section title with the old description, whatever it may be.
  103. For this function, the new menu is a list made up of lists of dotted
  104. pairs in which the first element of the pair is the node name and the
  105. second element the description. The new menu is changed destructively.
  106. The old menu is the menu as it appears in the latexinfo file." (byte-code "    
  107. " [new-menu-list-pointer new-menu-list end-of-menu t latexinfo-menu-end search-forward "* " ":" setcdr latexinfo-menu-copy-old-description] 7))
  108. (defun latexinfo-menu-copy-old-description (end-of-menu) "\
  109. Return description field of old menu line as string.
  110. Point must be located just after the node name.  Point left before description.
  111. Single argument, END-OF-MENU, is position limiting search." (byte-code "
  112. " [end-of-menu t skip-chars-forward "[:.,    
  113.  ]+" looking-at "\\(\\w+\\|\\\\\\)" "\\(^\\* \\|^\\\\end{menu}\\)" buffer-substring re-search-forward forward-line -1 end-of-line ""] 9))
  114. (defun latexinfo-menu-end nil "\
  115. Return position of end of menu. Does not change location of point.
  116. Signal an error if not end of menu." (byte-code "
  117. " [nil t re-search-forward "^\\\\end{menu}" error "Menu does not have an end."] 4))
  118. (defun latexinfo-delete-old-menu (beginning first) "\
  119. Delete the old menu.  Point must be in or after menu.
  120. First argument is position of the beginning of the section in which
  121. the menu will be located; second argument is the position of the first
  122. node within the section." (byte-code "
  123. " [beginning first re-search-backward "^\\\\begin{menu}" delete-region re-search-forward "^\\\\end{menu}"] 6))
  124. (defvar latexinfo-column-for-description 32 "\
  125. *Column at which descriptions start in a Latexinfo menu.")
  126. (defun latexinfo-insert-menu (menu-list node-name) "\
  127. Insert formatted menu at point.
  128. Indents the first line of the description, if any, to the value of
  129. latexinfo-column-for-description.
  130. MENU-LIST has form:
  131.     ((\"node-name1\" . \"description\") 
  132.     (\"node-name\" . \"description\") ... )
  133. However, there does not need to be a description field." (byte-code "
  134. @@\"?
  135. @@\"c
  136. @A\"c
  137. @@\"c
  138. " [menu-list latexinfo-column-for-description level node-name "\\begin{menu}
  139. " string-equal format "* %s::" indent-to 2 "%s
  140. " "* %s::
  141. " "\\end{menu}" message "Updated \"%s\" level menu following node: %s ... "] 9))
  142. (defun latexinfo-indent-menu-description (column &optional region-p) "\
  143. Indent every description in menu following point to COLUMN.  
  144. Non-nil argument (prefix, if interactive) means indent every
  145. description in every menu in the region.  Does not indent second and
  146. subsequent lines of a multi-line description." (interactive "nIndent menu descriptions to (column number): 
  147. P") (byte-code "
  148. " [region-p column nil widen re-search-forward "^\\\\begin{menu}" latexinfo-menu-indent-description message "Indented descriptions in menu.  You may save the buffer." "Indenting every menu description in region... " region-beginning region-end latexinfo-locate-menu-p forward-line 1 "Indenting done.  You may save the buffer."] 12))
  149. (defun latexinfo-menu-indent-description (to-column-number) "\
  150. Indent the Latexinfo file menu description to TO-COLUMN-NUMBER.
  151. Start with point just after the word `menu' in the `\\menu' line and
  152. leave point on the line before the `\\end{menu}' line.  Does not indent
  153. second and subsequent lines of a multi-line description." (byte-code "`
  154. " [beginning-of-next-line t beginning-white-space to-column-number latexinfo-menu-end beginning-of-line search-forward "::" skip-chars-forward "     " looking-at "\\(\\\\\\|\\w\\)+" delete-region indent-to-column forward-line 1] 12))
  155. (defun latexinfo-master-menu (update-all-nodes-menus-p) "\
  156. Make a master menu for a whole Latexinfo file.
  157. Non-nil argument (prefix, if interactive) means first update all
  158. existing nodes and menus.  Remove pre-existing master menu, if there is one.
  159. This function creates a master menu that follows the top node.  The
  160. master menu includes every entry from all the other menus.  It
  161. replaces any existing ordinary menu that follows the top node.
  162. If called with a non-nil argument, this function first updates all the
  163. menus in the buffer (incorporating descriptions from pre-existing
  164. menus) before it constructs the master menu.
  165. The function removes the detailed part of an already existing master
  166. menu.  This action depends on the pre-exisitng master menu using the
  167. standard `latexinfo-master-menu-header'.
  168. The master menu has the following format, which is adapted from the
  169. recommendation in the Latexinfo Manual:
  170.    * The first part contains the major nodes in the Latexinfo file: the
  171.      nodes for the chapters, chapter-like sections, and the major
  172.      appendices.  This includes the indices, so long as they are in
  173.      chapter-like sections, such as unnumbered sections.
  174.    * The second and subsequent parts contain a listing of the other,
  175.      lower level menus, in order.  This way, an inquirer can go
  176.      directly to a particular node if he or she is searching for
  177.      specific information.
  178. Each of the menus in the detailed node listing is introduced by the
  179. title of the section containing the menu." (interactive "P") (byte-code "
  180. " [nil t first-chapter latexinfo-master-menu-header end-of-detailed-menu-descriptions update-all-nodes-menus-p widen re-search-forward "^\\\\node [     ]*top[     ]*\\(,\\|$\\)" error "This buffer needs a Top node!" "^\\\\node" match-beginning 0 latexinfo-menu-end beginning-of-line forward-char -1 delete-region message "Making a master menu in %s ...first updating all nodes... " buffer-name sleep-for 2 mark-whole-buffer latexinfo-update-node "Updating all menus in %s ... " latexinfo-make-menu "Now making the master menu in %s... " latexinfo-insert-master-menu-list latexinfo-master-menu-list "
  181. " delete-blank-lines re-search-backward "^\\\\begin{menu}" forward-line "^\\\\end{menu}" 1 "Done...completed making master menu.  You may save the buffer."] 36))
  182. (defun latexinfo-master-menu-list nil "\
  183. Return a list of menu entries and header lines for the master menu.
  184. Start with the menu for chapters and indices and then find each
  185. following menu and the title of the node preceding that menu.
  186. The master menu list has this form:
  187.     (((... \"entry-1-2\"  \"entry-1\") \"title-1\")
  188.       ((... \"entry-2-2\"  \"entry-2-1\") \"title-2\")
  189.       ...)
  190. However, there does not need to be a title field." (byte-code "
  191. " [master-menu-list nil latexinfo-locate-menu-p latexinfo-copy-menu latexinfo-copy-menu-title reverse] 6))
  192. (defun latexinfo-insert-master-menu-list (master-menu-list) "\
  193. Format and insert the master menu in the current buffer." (byte-code "eb
  194.     @A@\"
  195. " [this-very-menu-list master-menu-list latexinfo-master-menu-header re-search-forward "^\\\\begin{menu}" beginning-of-line delete-region "^\\\\end{menu}" "
  196. \\begin{menu}
  197. " reverse message "Inserting chapter menu entry: %s ... " insert "* " "
  198. " "Inserting menu for %s .... " "
  199. " "\\end{menu}
  200. "] 16))
  201. (defvar latexinfo-master-menu-header "
  202.  --- The Detailed Node Listing ---
  203. " "String inserted before lower level entries in Latexinfo master menu.
  204. It comes after the chapter-level menu entries.")
  205. (defun latexinfo-locate-menu-p nil "\
  206. Find the next menu in the latexinfo file.
  207. If found, leave point after word `menu' on the `\\begin{menu}' line, and 
  208. return t. If a menu is not found, do not move point and return nil." (byte-code "
  209. " [nil t re-search-forward "\\(^\\\\begin{menu}\\)"] 4))
  210. (defun latexinfo-copy-menu-title nil "\
  211. Return the title of the section preceding the menu as a string.
  212. If such a title cannot be found, return an empty string.  Do not move
  213. point." (byte-code "
  214. " [latexinfo-section-types-regexp nil t re-search-backward "\\(^\\\\top" "\\|" "\\)" beginning-of-line forward-word 1 skip-chars-forward "     " buffer-substring forward-sexp ""] 8))
  215. (defun latexinfo-copy-menu nil "\
  216. Return the entries of an existing menu as a list.
  217. Start with point just after the word `menu' in the `\\menu' line
  218. and leave point on the line before the `\\end{menu}' line." (byte-code "
  219. " [this-menu-list end-of-menu last-entry t nil latexinfo-menu-end re-search-backward "^* " re-search-forward buffer-substring "\\(^* \\|^\\\\e\\)" 3] 10))
  220. (defun latexinfo-specific-section-type nil "\
  221. Return the specific type of next section, as a string.
  222. For example, \"unnumberedsubsec\".  Return \"top\" for top node.
  223. Searches forward for a section.  Hence, point must be before the
  224. section whose type will be found.  Does not move point.  Signal an
  225. error if the node is not the top node and a section is not found." (byte-code "
  226. " [nil t latexinfo-section-types-regexp re-search-forward "^\\\\node [     ]*top[     ]*\\(,\\|$\\)" "top" buffer-substring beginning-of-line forward-word 1 error "latexinfo-specific-section-type: Chapter or section not found."] 7))
  227. (defun latexinfo-hierarchic-level nil "\
  228. Return the general hierarchal level of the next node in a latexinfo file.
  229. Thus, a subsection* is of type subsection." (byte-code "
  230. " [latexinfo-section-to-generic-alist assoc latexinfo-specific-section-type error "Unknown section type!"] 4))
  231. (defun latexinfo-update-menu-region-beginning (level) "\
  232. Locate beginning of higher level section this section is within.
  233. Return position of the beginning of the node line; do not move point.
  234. Thus, if this level is subsection, searches backwards for section node.
  235. Only argument is a string of the general type of section." (byte-code "
  236. \"A!%
  237. " [level nil t latexinfo-update-menu-higher-regexps string-equal "top" "chapter" re-search-forward "^\\\\node [     ]*top[     ]*\\(,\\|$\\)" beginning-of-line re-search-backward concat "\\(^\\\\node\\).*
  238. " "\\(\\(\\(^\\\\c\\).*
  239. \\)" "\\|" "\\(^\\\\begin{ifinfo}[ ]*
  240. \\)\\)?" eval assoc goto-beginning] 14))
  241. (defun latexinfo-update-menu-region-end (level) "\
  242. Locate end of higher level section this section is within.
  243. Return position; do not move point.  Thus, if this level is a
  244. subsection, find the node for the section this subsection is within.
  245. If level is top or chapter, returns end of file.  Only argument is a
  246. string of the general type of section." (byte-code "
  247.     \"A!%
  248. " [level latexinfo-update-menu-higher-regexps nil re-search-forward concat "\\(^\\\\node\\).*
  249. " "\\(\\(\\(^\\\\c\\).*
  250. \\)" "\\|" "\\(^\\\\begin{ifinfo}[ ]*
  251. \\)\\)?" eval assoc goto-end match-beginning 1] 10))
  252. (defun latexinfo-menu-first-node (beginning end) "\
  253. Locate first node of the section the menu will be placed in.  
  254. Return position; do not move point.
  255. The menu will be located just before this position.  
  256. First argument is the position of the beginning of the section in
  257. which the menu will be located; second argument is the position of the
  258. end of that region; it limits the search." (byte-code "
  259. " [beginning end t forward-line 1 re-search-forward "^\\\\node" beginning-of-line] 5))
  260. (defvar latexinfo-section-to-generic-alist (quote (("top" . "top") ("chapter" . "chapter") ("chapter*" . "chapter") ("unnumbered" . "chapter") ("section" . "section") ("section*" . "section") ("unnumberedsec" . "section") ("subsection" . "subsection") ("subsection*" . "subsection") ("unnumberedsubsec" . "subsection") ("subsubsection" . "subsubsection") ("subsubsection*" . "subsubsection") ("unnumberedsubsubsec" . "subsubsection"))) "\
  261. *An alist of specific and corresponding generic Latexinfo section types.
  262. The keys are strings specifying specific types of section; the values
  263. are strings of their corresponding general types.")
  264. (defvar latexinfo-section-types-regexp "^\\\\\\(chapter\\|section\\|subsection\\|subsubsection\\|unnumbered\\|unnumberedsec\\|unnumberedsubsec\\|unnumberedsubsubsec\\)" "\
  265. Regexp matching chapter, section, other headings (but not the top node).")
  266. (defvar latexinfo-chapter-level-regexp "chapter\\|chapter\\*\\|unnumbered" "\
  267. Regular expression matching just the Latexinfo chapter level headings.")
  268. (defvar latexinfo-section-level-regexp "section\\|section\\*\\|unnumberedsec" "\
  269. Regular expression matching just the Latexinfo section level headings.")
  270. (defvar latexinfo-subsection-level-regexp "subsection\\|subsection\\*\\|unnumberedsubsec" "\
  271. Regular expression matching just the Latexinfo subsection level headings.")
  272. (defvar latexinfo-subsubsection-level-regexp "subsubsection\\|subsubsection\\*\\|unnumberedsubsubsec" "\
  273. Regular expression matching just the Latexinfo subsubsection level headings.")
  274. (defvar latexinfo-update-menu-same-level-regexps (quote (("top" . "top[     {]+") ("chapter" concat "\\(^\\\\\\)\\(" latexinfo-chapter-level-regexp "\\)[     {]*") ("section" concat "\\(^\\\\\\)\\(" latexinfo-section-level-regexp "\\)[     {]*") ("subsection" concat "\\(^\\\\\\)\\(" latexinfo-subsection-level-regexp "\\)[     {]*") ("subsubsection" concat "\\(^\\\\\\)\\(" latexinfo-subsubsection-level-regexp "\\)[     {]*"))) "\
  275. *Regexps for searching for same level sections in a Latexinfo file.
  276. The keys are strings specifying the general hierarchical level in the
  277. document; the values are regular expressions.")
  278. (defvar latexinfo-update-menu-higher-regexps (quote (("top" . "^\\\\node [     ]*DIR") ("chapter" . "^\\\\node [     ]*top[     ]*\\(,\\|$\\)") ("section" concat "\\(^\\\\\\(" latexinfo-chapter-level-regexp "\\)[     {]*\\)") ("subsection" concat "\\(^\\\\\\(" latexinfo-section-level-regexp "\\|" latexinfo-chapter-level-regexp "\\)[     {]*\\)") ("subsubsection" concat "\\(^\\\\\\(" latexinfo-subsection-level-regexp "\\|" latexinfo-section-level-regexp "\\|" latexinfo-chapter-level-regexp "\\)[     {]*\\)"))) "\
  279. *Regexps for searching for higher level sections in a Latexinfo file.
  280. The keys are strings specifying the general hierarchical level in the
  281. document; the values are regular expressions.")
  282. (defvar latexinfo-update-menu-lower-regexps (quote (("top" concat "\\(^\\\\\\(" latexinfo-chapter-level-regexp "\\|" latexinfo-section-level-regexp "\\|" latexinfo-subsection-level-regexp "\\|" latexinfo-subsubsection-level-regexp "\\)[     {]*\\)") ("chapter" concat "\\(^\\\\\\(" latexinfo-section-level-regexp "\\|" latexinfo-subsection-level-regexp "\\|" latexinfo-subsubsection-level-regexp "\\)[     {]*\\)") ("section" concat "\\(^\\\\\\(" latexinfo-subsection-level-regexp "\\|" latexinfo-subsubsection-level-regexp "\\)[     {]*\\)") ("subsection" concat "\\(^\\\\\\(" latexinfo-subsubsection-level-regexp "\\)[     {]*\\)") ("subsubsection" . "nothing lower"))) "\
  283. *Regexps for searching for lower level sections in a Latexinfo file.
  284. The keys are strings specifying the general hierarchical level in the
  285. document; the values are regular expressions.")
  286. (defun latexinfo-update-node (&optional region-p) "\
  287. Without any prefix argument, update the node in which point is located.
  288. Non-nil argument (prefix, if interactive) means update the nodes in the
  289. marked region.
  290. The functions for creating or updating nodes and menus, and their
  291. keybindings, are:
  292.     latexinfo-update-node (&optional region-p)    \\[latexinfo-update-node]
  293.     latexinfo-every-node-update ()                \\[latexinfo-every-node-update]
  294.     latexinfo-sequential-node-update (&optional region-p)
  295.     latexinfo-make-menu (&optional region-p)      \\[latexinfo-make-menu]
  296.     latexinfo-all-menus-update ()                 \\[latexinfo-all-menus-update]
  297.     latexinfo-master-menu ()
  298.     latexinfo-indent-menu-description (column &optional region-p)
  299. The `latexinfo-column-for-description' variable specifies the column to
  300. which menu descriptions are indented. Its default value is 32." (interactive "P") (byte-code "
  301. " [region-p auto-fill-hook nil t beginning end re-search-backward "^\\\\node" error "Node line not found before this position." latexinfo-update-the-node message "Done...updated the node.  You may save the buffer." region-beginning region-end "Please mark a region!" narrow-to-region push-mark re-search-forward beginning-of-line "Done...updated nodes in region.  You may save the buffer."] 14))
  302. (defun latexinfo-every-node-update nil "\
  303. Update every node in a Latexinfo file." (interactive) (byte-code "
  304. " [t nil mark-whole-buffer latexinfo-update-node message "Done...updated every node.       You may save the buffer."] 4))
  305. (defun latexinfo-update-the-node nil "\
  306. Update one node.  Point must be at the beginning of node line.  
  307. Leave point at the end of the node line." (byte-code "
  308. " [case-fold-search t level beginning end latexinfo-check-for-node-name latexinfo-delete-existing-pointers message "Updating node: %s ... " latexinfo-copy-node-name widen latexinfo-hierarchic-level latexinfo-update-menu-region-beginning latexinfo-update-menu-region-end string-equal "top" latexinfo-top-pointer-case latexinfo-insert-pointer next previous up latexinfo-clean-up-node-line] 17))
  309. (defun latexinfo-top-pointer-case nil "\
  310. Insert pointers in the Top node.  This is a special case.
  311. The `Next' pointer is a pointer to a chapter or section at a lower
  312. hierarchical level in the file.  The `Previous' and `Up' pointers are
  313. to `(dir)'.  Point must be at the beginning of the node line, and is
  314. left at the end of the node line." (byte-code "
  315. " [nil t latexinfo-clean-up-node-line insert ", " re-search-forward "^\\\\node" beginning-of-line latexinfo-copy-node-name " " ", (dir), (dir)"] 8))
  316. (defun latexinfo-check-for-node-name nil "\
  317. Determine whether the node has a node name.  Prompt for one if not.
  318. Point must be at beginning of node line.  Does not move point." (byte-code "
  319. " [node-name forward-word 1 skip-chars-forward "     " looking-at "[^,    
  320.  ]+" read-from-minibuffer "Node name: " insert " "] 7))
  321. (defun latexinfo-delete-existing-pointers nil "\
  322. Delete `Next', `Previous', and `Up' pointers.  
  323. Starts from the current position of the cursor, and searches forward
  324. on the line for a comma and if one is found, deletes the rest of the
  325. line, including the comma.  Leaves point at beginning of line." (byte-code "
  326. " [t nil search-forward "," end-of-line kill-line beginning-of-line] 5))
  327. (defun latexinfo-find-pointer (beginning end level direction) "\
  328. Move point to section associated with next, previous, or up pointer.
  329. Return type of pointer (either 'normal or 'no-pointer).
  330. The first and second arguments bound the search for a pointer to the
  331. beginning and end, respectively, of the enclosing higher level
  332. section.  The third argument is a string specifying the general kind
  333. of section such as \"chapter or \"section\".  When looking for the
  334. `Next' pointer, the section found will be at the same hierarchical
  335. level in the Latexinfo file; when looking for the `Previous' pointer,
  336. the section found will be at the same or higher hierarchical level in
  337. the Latexinfo file; when looking for the `Up' pointer, the section found
  338. will be at some level higher in the Latexinfo file.  The fourth argument
  339. (one of 'next, 'previous, or 'up) specifies whether to find the
  340. `Next', `Previous', or `Up' pointer." (byte-code "
  341. " [direction level latexinfo-update-menu-same-level-regexps end t latexinfo-update-menu-higher-regexps beginning next forward-line 3 re-search-forward eval assoc normal no-pointer previous re-search-backward concat "\\(" "\\|" "\\)" up beginning-of-line error "latexinfo-find-pointer: lack proper arguments"] 17))
  342. (defun latexinfo-pointer-name (kind) "\
  343. Return the node name preceding the section command.
  344. The argument is the kind of section, either normal or no-pointer." (byte-code "
  345. " [name kind t nil normal end-of-line re-search-backward "^\\\\node" forward-line -3 latexinfo-copy-node-name no-pointer " "] 6))
  346. (defun latexinfo-insert-pointer (beginning end level direction) "\
  347. Insert the `Next', `Previous' or `Up' node name at point.
  348. Move point forward.  
  349. The first and second arguments bound the search for a pointer to the
  350. beginning and end, respectively, of the enclosing higher level
  351. section.  The third argument is the hierarchical level of the Latexinfo
  352. file, a string such as \"section\".  The fourth argument is direction
  353. towards which the pointer is directed, one of `next, `previous, or
  354. 'up." (byte-code "
  355. $!)\"
  356. " [beginning end level direction end-of-line insert ", " latexinfo-pointer-name latexinfo-find-pointer] 9))
  357. (defun latexinfo-clean-up-node-line nil "\
  358. Remove extra commas, if any, at end of node line." (byte-code "
  359. " [end-of-line skip-chars-backward ", " delete-region] 6))
  360. (defun latexinfo-sequential-node-update (&optional region-p) "\
  361. Update one node (or many) in a Latexinfo file with sequential pointers.
  362. This function causes the `Next' or `Previous' pointer to point to the
  363. immediately preceding or following node, even if it is at a higher or
  364. lower hierarchical level in the document.  Continually pressing `n' or
  365. `p' takes you straight through the file.
  366. Without any prefix argument, update the node in which point is located.
  367. Non-nil argument (prefix, if interactive) means update the nodes in the
  368. marked region.
  369. This command makes it awkward to navigate among sections and
  370. subsections; it should be used only for those documents that are meant
  371. to be read like a novel rather than a reference, and for which the
  372. Info `g*' command is inadequate." (interactive "P") (byte-code "
  373. " [region-p auto-fill-hook nil t beginning end re-search-backward "^\\\\node" error "Node line not found before this position." latexinfo-sequentially-update-the-node message "Done...sequentially updated the node .  You may save the buffer." region-beginning region-end "Please mark a region!" narrow-to-region push-mark re-search-forward beginning-of-line "Done...updated the nodes in sequence.  You may save the buffer."] 14))
  374. (defun latexinfo-sequentially-update-the-node nil "\
  375. Update one node such that the pointers are sequential. 
  376. A `Next' or `Previous' pointer points to any preceding or following node,
  377. regardless of its hierarchical level." (byte-code "
  378. " [case-fold-search t level latexinfo-check-for-node-name latexinfo-delete-existing-pointers message "Sequentially updating node: %s ... " latexinfo-copy-node-name widen latexinfo-hierarchic-level string-equal "top" latexinfo-top-pointer-case latexinfo-sequentially-insert-pointer next previous up latexinfo-clean-up-node-line] 13))
  379. (defun latexinfo-sequentially-find-pointer (level direction) "\
  380. Find next or previous pointer sequentially in Latexinfo file, or up pointer.
  381. Move point to section associated with the pointer.  Find point even if
  382. it is in a different section.
  383. Return type of pointer (either 'normal or 'no-pointer).
  384. The first argument is a string specifying the general kind of section
  385. such as \"chapter or \"section\".  The section found will be at the
  386. same hierarchical level in the Latexinfo file, or, in the case of the up
  387. pointer, some level higher.  The second argument (one of 'next,
  388. 'previous, or 'up) specifies whether to find the `Next', `Previous',
  389. or `Up' pointer." (byte-code "
  390. " [direction latexinfo-section-types-regexp t up-level level latexinfo-update-menu-higher-regexps nil next forward-line 3 re-search-forward normal no-pointer previous re-search-backward up eval assoc message "latexinfo-sequential-find-pointer: null up-level" error "latexinfo-sequential-find-pointer: lack proper arguments"] 10))
  391. (defun latexinfo-sequentially-insert-pointer (level direction) "\
  392. Insert the `Next', `Previous' or `Up' node name at point.
  393. Move point forward.  
  394. The first argument is the hierarchical level of the Latexinfo file, a
  395. string such as \"section\".  The second argument is direction, one of
  396. `next, `previous, or 'up." (byte-code "
  397.     \"!)\"
  398. " [level direction end-of-line insert ", " latexinfo-pointer-name latexinfo-sequentially-find-pointer] 7))
  399. (defun latexinfo-insert-node-lines (beginning end &optional title-p) "\
  400. Insert missing `\\node' lines in region of Latexinfo file.
  401. Non-nil argument (prefix, if interactive) means also to insert the
  402. section titles as node names; and also to insert the section titles as
  403. node names in pre-existing \\node lines that lack names." (interactive "r
  404. P") (byte-code "
  405. " [beginning-marker end-marker title last-section-position end t beginning latexinfo-section-types-regexp title-p nil push-mark mark-marker re-search-forward beginning-of-line forward-word 1 skip-chars-forward "     " buffer-substring search-forward "," forward-sexp yes re-search-backward "^\\\\node" forward-line -2 "\\node
  406. " backward-char looking-at "[^,    
  407.  ]+" insert " " message "Inserted title %s ... " 3 set-mark "Done inserting node lines and titles.  You may save the buffer." "Done inserting node lines.  You may save the buffer."] 27))
  408. (defun latexinfo-multi-file-included-list (outer-file) "\
  409. Return a list of the included files in OUTER-FILE." (byte-code "    C
  410. " [included-file-list outer-file start nil t switch-to-buffer find-file-noselect widen re-search-forward "^\\\\include" skip-chars-forward "     " end-of-line skip-chars-backward buffer-substring nreverse] 11))
  411. (defun latexinfo-copy-next-section-title nil "\
  412. Return the name of the immediately following section as a string.
  413. Start with point at the beginning of the node line.  Leave point at the
  414. same place.  If there is no title, returns an empty string." (byte-code "
  415. " [section-end nil t latexinfo-section-types-regexp title end-of-line re-search-forward "\\(^\\\\node\\)" match-beginning 0 beginning-of-line buffer-substring forward-word 1 skip-chars-forward "     " ""] 11))
  416. (defun latexinfo-multi-file-update (files &optional update-everything) "\
  417. Update first node pointers in each file in FILES.
  418. Return a list of the node names and the title immediate following them.
  419. The first file in the list is an outer file; the remaining are
  420. files included in the outer file with `\\include' commands.
  421. If optional arg UPDATE-EVERYTHING non-nil, update every menu and
  422. pointer in each of the included files.
  423. Also update the `Top' level node pointers of the outer file.
  424. Requirements:
  425.   * the first file in the FILES list must be the outer file,
  426.   * each of the included files must contain exactly one highest
  427.     hierarchical level node, 
  428.   * this node must be the first node in the included file,
  429.   * each highest hierarchical level node must be of the same type.
  430. Thus, normally, each included file contains one, and only one,
  431. chapter.
  432. The menu-list has the form:
  433.     ((\"node-name1\" . \"title1\") 
  434.       (\"node-name2\" . \"title2\") ... )
  435. However, there does not need to be a title field." (byte-code "
  436.     A@!!
  437.     A@!!
  438. " [menu-list files nil t next-node-name previous-node-name update-everything up-node-name switch-to-buffer find-file-noselect widen re-search-forward "^\\\\node" error "No `\\node' line found in %s !" buffer-name beginning-of-line latexinfo-check-for-node-name latexinfo-copy-node-name latexinfo-copy-next-section-title "^\\\\node [     ]*top[     ]*\\(,\\|$\\)" "This buffer needs a Top node!" latexinfo-delete-existing-pointers end-of-line insert ", " ", (dir), (dir)" "Top" "" latexinfo-all-menus-update nreverse] 47))
  439. (defun latexinfo-multi-files-insert-main-menu (menu-list) "\
  440. Insert formatted main menu at point.
  441. Indents the first line of the description, if any, to the value of
  442. latexinfo-column-for-description." (byte-code "
  443. @@\"c
  444. @A\"c
  445. @@\"c
  446. " [menu-list latexinfo-column-for-description "\\begin{menu}
  447. " format "* %s::" indent-to 2 "%s
  448. " "* %s::
  449. " "\\end{menu}"] 7))
  450. (defun latexinfo-multi-file-master-menu-list (files-list) "\
  451. Return master menu list from files in FILES-LIST.
  452. Menu entries in each file collected using `latexinfo-master-menu-list'.
  453. The first file in FILES-LIST must be the outer file; the others must
  454. be the files included within it.  A main menu must already exist." (byte-code "
  455. " [master-menu-list files-list nil switch-to-buffer find-file-noselect message "Working on: %s " append latexinfo-master-menu-list] 8))
  456. (defun latexinfo-multiple-files-update (outer-file &optional update-everything make-master-menu) "\
  457. Update first node pointers in each file included in OUTER-FILE;
  458. create or update the `Top' level node pointers and the main menu in
  459. the outer file that refers to such nodes.  This does not create or
  460. update menus or pointers within the included files.
  461. With optional MAKE-MASTER-MENU argument (prefix arg, if interactive),
  462. insert a master menu in OUTER-FILE in addition to creating or updating
  463. pointers in the first \\node line in each included file and creating or
  464. updating the `Top' level node pointers of the outer file.  This does
  465. not create or update other menus and pointers within the included
  466. files.
  467. With optional UPDATE-EVERYTHING argument (numeric prefix arg, if
  468. interactive), update all the menus and all the `Next', `Previous', and
  469. `Up' pointers of all the files included in OUTER-FILE before inserting
  470. a master menu in OUTER-FILE.  Also, update the `Top' level node
  471. pointers of OUTER-FILE.
  472. Notes: 
  473.   * this command does NOT save any files--you must save the
  474.     outer file and any modified, included files.
  475.   * except for the `Top' node, this command does NOT handle any
  476.     pre-existing nodes in the outer file; hence, indices must be
  477.     enclosed in an included file.
  478. Requirements:
  479.   * each of the included files must contain exactly one highest
  480.     hierarchical level node, 
  481.   * this highest node must be the first node in the included file,
  482.   * each highest hierarchical level node must be of the same type.
  483. Thus, normally, each included file contains one, and only one,
  484. chapter." (interactive (byte-code "
  485. " [current-prefix-arg read-string "Name of outer `include' file: " buffer-file-name (nil nil) (t nil) numberp (t t)] 5)) (byte-code "
  486. " [current-prefix-arg included-file-list outer-file files main-menu-list next-node-name previous-node-name up-node-name update-everything make-master-menu latexinfo-master-menu-header nil t end-of-detailed-menu-descriptions latexinfo-multi-file-included-list "Top" latexinfo-multi-file-update switch-to-buffer find-file-noselect latexinfo-old-menu-p re-search-forward "^\\include" beginning-of-line latexinfo-incorporate-descriptions delete-region "^\\\\end{menu}" latexinfo-multi-files-insert-main-menu match-beginning 0 latexinfo-menu-end forward-char -1 latexinfo-insert-master-menu-list latexinfo-multi-file-master-menu-list message "Multiple files updated."] 23))
  487. (provide (quote latexnfo-upd))
  488.