comparison lisp/textmodes/texnfo-upd.el @ 18259:379252f79147

Many doc fixes. (texinfo-all-menus-update): Check for @detailmenu. (texinfo-master-menu): Likewise. (texinfo-multiple-files-update): Likewise. (texinfo-insert-master-menu-list): Put in @detailmenu if appropriate.
author Richard M. Stallman <rms@gnu.org>
date Sun, 15 Jun 1997 17:39:13 +0000
parents 1eecbe9dd89c
children b4b2ad407ba0
comparison
equal deleted inserted replaced
18258:e83bc8150072 18259:379252f79147
228 (push-mark (point-max) t) 228 (push-mark (point-max) t)
229 (goto-char (point-min)) 229 (goto-char (point-min))
230 (message "Checking for a master menu in %s ... "(buffer-name)) 230 (message "Checking for a master menu in %s ... "(buffer-name))
231 (save-excursion 231 (save-excursion
232 (if (re-search-forward texinfo-master-menu-header nil t) 232 (if (re-search-forward texinfo-master-menu-header nil t)
233 ;; Remove detailed master menu listing
234 (progn 233 (progn
234 ;; Check if @detailmenu kludge is used;
235 ;; if so, leave point before @detailmenu.
236 (search-backward "\n@detailmenu"
237 (save-excursion (forward-line -3) (point))
238 t)
239 ;; Remove detailed master menu listing
235 (setq master-menu-p t) 240 (setq master-menu-p t)
236 (goto-char (match-beginning 0)) 241 (goto-char (match-beginning 0))
237 (let ((end-of-detailed-menu-descriptions 242 (let ((end-of-detailed-menu-descriptions
238 (save-excursion ; beginning of end menu line 243 (save-excursion ; beginning of end menu line
239 (goto-char (texinfo-menu-end)) 244 (goto-char (texinfo-menu-end))
422 old description into the new entry. 427 old description into the new entry.
423 428
424 For this function, the new menu is a list made up of lists of dotted 429 For this function, the new menu is a list made up of lists of dotted
425 pairs in which the first element of the pair is the node name and the 430 pairs in which the first element of the pair is the node name and the
426 second element the description. The new menu is changed destructively. 431 second element the description. The new menu is changed destructively.
427 The old menu is the menu as it appears in the texinfo file." 432 The old menu is the menu as it appears in the Texinfo file."
428 433
429 (let ((new-menu-list-pointer new-menu-list) 434 (let ((new-menu-list-pointer new-menu-list)
430 (end-of-menu (texinfo-menu-end))) 435 (end-of-menu (texinfo-menu-end)))
431 (while new-menu-list 436 (while new-menu-list
432 (save-excursion ; keep point at beginning of menu 437 (save-excursion ; keep point at beginning of menu
509 (end-of-line) ; go to end of last description line 514 (end-of-line) ; go to end of last description line
510 (point))) 515 (point)))
511 "")) 516 ""))
512 517
513 (defun texinfo-menu-end () 518 (defun texinfo-menu-end ()
514 "Return position of end of menu. Does not change location of point. 519 "Return position of end of menu, but don't move point.
515 Signal an error if not end of menu." 520 Signal an error if not end of menu."
516 (save-excursion 521 (save-excursion
517 (if (re-search-forward "^@end menu" nil t) 522 (if (re-search-forward "^@end menu" nil t)
518 (point) 523 (point)
519 (error "Menu does not have an end.")))) 524 (error "Menu does not have an end."))))
662 (save-excursion (insert title)))) 667 (save-excursion (insert title))))
663 668
664 669
665 ;;; Handling description indentation 670 ;;; Handling description indentation
666 671
667 ; Since the make-menu functions indent descriptions, these functions 672 ;; Since the make-menu functions indent descriptions, these functions
668 ; are useful primarily for indenting a single menu specially. 673 ;; are useful primarily for indenting a single menu specially.
669 674
670 (defun texinfo-indent-menu-description (column &optional region-p) 675 (defun texinfo-indent-menu-description (column &optional region-p)
671 "Indent every description in menu following point to COLUMN. 676 "Indent every description in menu following point to COLUMN.
672 Non-nil argument (prefix, if interactive) means indent every 677 Non-nil argument (prefix, if interactive) means indent every
673 description in every menu in the region. Does not indent second and 678 description in every menu in the region. Does not indent second and
774 (save-excursion 779 (save-excursion
775 (or (re-search-forward "^@node" nil t) 780 (or (re-search-forward "^@node" nil t)
776 (error "Too few nodes for a master menu!")) 781 (error "Too few nodes for a master menu!"))
777 (point)))) 782 (point))))
778 (if (re-search-forward texinfo-master-menu-header first-chapter t) 783 (if (re-search-forward texinfo-master-menu-header first-chapter t)
779 ;; Remove detailed master menu listing
780 (progn 784 (progn
785 ;; Check if @detailmenu kludge is used;
786 ;; if so, leave point before @detailmenu.
787 (search-backward "\n@detailmenu"
788 (save-excursion (forward-line -3) (point))
789 t)
790 ;; Remove detailed master menu listing
781 (goto-char (match-beginning 0)) 791 (goto-char (match-beginning 0))
782 (let ((end-of-detailed-menu-descriptions 792 (let ((end-of-detailed-menu-descriptions
783 (save-excursion ; beginning of end menu line 793 (save-excursion ; beginning of end menu line
784 (goto-char (texinfo-menu-end)) 794 (goto-char (texinfo-menu-end))
785 (beginning-of-line) (forward-char -1) 795 (beginning-of-line) (forward-char -1)
810 (goto-char (point-min)) 820 (goto-char (point-min))
811 821
812 (if (re-search-forward texinfo-master-menu-header nil t) 822 (if (re-search-forward texinfo-master-menu-header nil t)
813 (progn 823 (progn
814 (goto-char (match-beginning 0)) 824 (goto-char (match-beginning 0))
825 ;; Check if @detailmenu kludge is used;
826 ;; if so, leave point before @detailmenu.
827 (search-backward "\n@detailmenu"
828 (save-excursion (forward-line -3) (point))
829 t)
815 (insert "\n") 830 (insert "\n")
816 (delete-blank-lines) 831 (delete-blank-lines)
817 (goto-char (point-min)))) 832 (goto-char (point-min))))
818 833
819 (re-search-forward "^@menu") 834 (re-search-forward "^@menu")
865 (beginning-of-line) 880 (beginning-of-line)
866 (delete-region ; buffer must have ordinary top menu 881 (delete-region ; buffer must have ordinary top menu
867 (point) 882 (point)
868 (save-excursion (re-search-forward "^@end menu") (point))) 883 (save-excursion (re-search-forward "^@end menu") (point)))
869 884
870 (save-excursion ; leave point at beginning of menu 885 (save-excursion
871 ;; Handle top of menu 886 ;; `master-menu-inserted-p' is a kludge to tell
872 (insert "\n@menu\n") 887 ;; whether to insert @end detailmenu (see bleow)
873 ;; Insert chapter menu entries 888 (let (master-menu-inserted-p)
874 (setq this-very-menu-list (reverse (car (car master-menu-list)))) 889 ;; Handle top of menu
875 ;; Tell user what is going on. 890 (insert "\n@menu\n")
876 (message "Inserting chapter menu entry: %s ... " this-very-menu-list) 891 ;; Insert chapter menu entries
877 (while this-very-menu-list 892 (setq this-very-menu-list (reverse (car (car master-menu-list))))
878 (insert "* " (car this-very-menu-list) "\n") 893 ;; Tell user what is going on.
879 (setq this-very-menu-list (cdr this-very-menu-list))) 894 (message "Inserting chapter menu entry: %s ... " this-very-menu-list)
880 895 (while this-very-menu-list
881 (setq master-menu-list (cdr master-menu-list)) 896 (insert "* " (car this-very-menu-list) "\n")
882 897 (setq this-very-menu-list (cdr this-very-menu-list)))
883 ;; Now, insert all the other menus (if we have any). 898
884 899 (setq master-menu-list (cdr master-menu-list))
885 ;; The menu master-menu-list has a form like this: 900
886 ;; ((("beta" "alpha") "title-A") 901 ;; Only insert detailed master menu if there is one....
887 ;; (("delta" "gamma") "title-B")) 902 (if (car (car master-menu-list))
888 903 (progn (setq master-menu-inserted-p t)
889 (if (car (car master-menu-list)) 904 (insert (concat "\n@detailmenu" texinfo-master-menu-header))))
890 (progn 905
891 (insert "\n@detailmenu\n") 906 ;; @detailmenu added 5 Sept 1996 to `texinfo-master-menu-header'
892 (insert texinfo-master-menu-header) 907 ;; at Karl Berry's request to avert a bug in `makeinfo';
893 908 ;; all agree this is a bad kludge and should eventually be removed.
894 (while master-menu-list 909 ;; @detailmenu ... @end detailmenu is a noop in `texinfmt.el'.
895 910 ;; See @end detailmenu below;
896 (message 911 ;; also see `texinfo-all-menus-update' above, `texinfo-master-menu',
897 "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) 912 ;; `texinfo-multiple-files-update'.
898 ;; insert title of menu section 913
899 (insert "\n" (car (cdr (car master-menu-list))) "\n\n") 914 ;; Now, insert all the other menus
900 915
901 ;; insert each menu entry 916 ;; The menu master-menu-list has a form like this:
902 (setq this-very-menu-list (reverse (car (car master-menu-list)))) 917 ;; ((("beta" "alpha") "title-A")
903 (while this-very-menu-list 918 ;; (("delta" "gamma") "title-B"))
904 (insert "* " (car this-very-menu-list) "\n") 919
905 (setq this-very-menu-list (cdr this-very-menu-list))) 920 (while master-menu-list
906 921
907 (setq master-menu-list (cdr master-menu-list))) 922 (message
908 923 "Inserting menu for %s .... " (car (cdr (car master-menu-list))))
909 (insert "@end detaimenu\n"))) 924 ;; insert title of menu section
910 925 (insert "\n" (car (cdr (car master-menu-list))) "\n\n")
911 ;; Finish menu 926
912 (insert "@end menu\n\n"))) 927 ;; insert each menu entry
928 (setq this-very-menu-list (reverse (car (car master-menu-list))))
929 (while this-very-menu-list
930 (insert "* " (car this-very-menu-list) "\n")
931 (setq this-very-menu-list (cdr this-very-menu-list)))
932
933 (setq master-menu-list (cdr master-menu-list)))
934
935 ;; Finish menu
936
937 ;; @detailmenu (see note above)
938 ;; Only insert @end detailmenu if a master menu was inserted.
939 (if master-menu-inserted-p
940 (insert "\n@end detailmenu"))
941 (insert "\n@end menu\n\n"))))
913 942
914 (defun texinfo-locate-menu-p () 943 (defun texinfo-locate-menu-p ()
915 "Find the next menu in the texinfo file. 944 "Find the next menu in the texinfo file.
916 If found, leave point after word `menu' on the `@menu' line, and return t. 945 If found, leave point after word `menu' on the `@menu' line, and return t.
917 If a menu is not found, do not move point and return nil." 946 If a menu is not found, do not move point and return nil."
1334 (delete-region (1- (point)) eol-point))) 1363 (delete-region (1- (point)) eol-point)))
1335 (beginning-of-line)) 1364 (beginning-of-line))
1336 1365
1337 (defun texinfo-find-pointer (beginning end level direction) 1366 (defun texinfo-find-pointer (beginning end level direction)
1338 "Move point to section associated with next, previous, or up pointer. 1367 "Move point to section associated with next, previous, or up pointer.
1339 Return type of pointer (either 'normal or 'no-pointer). 1368 Return type of pointer (either `normal' or `no-pointer').
1340 1369
1341 The first and second arguments bound the search for a pointer to the 1370 The first and second arguments bound the search for a pointer to the
1342 beginning and end, respectively, of the enclosing higher level 1371 beginning and end, respectively, of the enclosing higher level
1343 section. The third argument is a string specifying the general kind 1372 section. The third argument is a string specifying the general kind
1344 of section such as \"chapter\" or \"section\". When looking for the 1373 of section such as \"chapter\" or \"section\". When looking for the
1415 (t 1444 (t
1416 (error "texinfo-find-pointer: lack proper arguments"))))) 1445 (error "texinfo-find-pointer: lack proper arguments")))))
1417 1446
1418 (defun texinfo-pointer-name (kind) 1447 (defun texinfo-pointer-name (kind)
1419 "Return the node name preceding the section command. 1448 "Return the node name preceding the section command.
1420 The argument is the kind of section, either normal or no-pointer." 1449 The argument is the kind of section, either `normal' or `no-pointer'."
1421 (let (name) 1450 (let (name)
1422 (cond ((eq kind 'normal) 1451 (cond ((eq kind 'normal)
1423 (end-of-line) ; this handles prev node top case 1452 (end-of-line) ; this handles prev node top case
1424 (re-search-backward ; when point is already 1453 (re-search-backward ; when point is already
1425 "^@node" ; at the beginning of @node line 1454 "^@node" ; at the beginning of @node line
1426 (save-excursion (forward-line -3)) 1455 (save-excursion (forward-line -3))
1427 t) 1456 t)
1428 (setq name (texinfo-copy-node-name))) 1457 (setq name (texinfo-copy-node-name)))
1429 ((eq kind 'no-pointer) 1458 ((eq kind 'no-pointer)
1459 ;; Don't need to put a blank in the pointer slot,
1460 ;; since insert "' " always has a space
1430 (setq name " "))) ; put a blank in the pointer slot 1461 (setq name " "))) ; put a blank in the pointer slot
1431 name)) 1462 name))
1432 1463
1433 (defun texinfo-insert-pointer (beginning end level direction) 1464 (defun texinfo-insert-pointer (beginning end level direction)
1434 "Insert the `Next', `Previous' or `Up' node name at point. 1465 "Insert the `Next', `Previous' or `Up' node name at point.
1436 1467
1437 The first and second arguments bound the search for a pointer to the 1468 The first and second arguments bound the search for a pointer to the
1438 beginning and end, respectively, of the enclosing higher level 1469 beginning and end, respectively, of the enclosing higher level
1439 section. The third argument is the hierarchical level of the Texinfo 1470 section. The third argument is the hierarchical level of the Texinfo
1440 file, a string such as \"section\". The fourth argument is direction 1471 file, a string such as \"section\". The fourth argument is direction
1441 towards which the pointer is directed, one of `next, `previous, or 1472 towards which the pointer is directed, one of `next', `previous', or `up'."
1442 'up."
1443 1473
1444 (end-of-line) 1474 (end-of-line)
1445 (insert 1475 (insert
1446 ", " 1476 ", "
1447 (save-excursion 1477 (save-excursion
1454 (skip-chars-backward ", ") 1484 (skip-chars-backward ", ")
1455 (delete-region (point) (save-excursion (end-of-line) (point)))) 1485 (delete-region (point) (save-excursion (end-of-line) (point))))
1456 1486
1457 1487
1458 ;;; Updating nodes sequentially 1488 ;;; Updating nodes sequentially
1459 ; These sequential update functions insert `Next' or `Previous' 1489 ;; These sequential update functions insert `Next' or `Previous'
1460 ; pointers that point to the following or preceding nodes even if they 1490 ;; pointers that point to the following or preceding nodes even if they
1461 ; are at higher or lower hierarchical levels. This means that if a 1491 ;; are at higher or lower hierarchical levels. This means that if a
1462 ; section contains one or more subsections, the section's `Next' 1492 ;; section contains one or more subsections, the section's `Next'
1463 ; pointer will point to the subsection and not the following section. 1493 ;; pointer will point to the subsection and not the following section.
1464 ; (The subsection to which `Next' points will most likely be the first 1494 ;; (The subsection to which `Next' points will most likely be the first
1465 ; item on the section's menu.) 1495 ;; item on the section's menu.)
1466 1496
1467 ;;;###autoload 1497 ;;;###autoload
1468 (defun texinfo-sequential-node-update (&optional region-p) 1498 (defun texinfo-sequential-node-update (&optional region-p)
1469 "Update one node (or many) in a Texinfo file with sequential pointers. 1499 "Update one node (or many) in a Texinfo file with sequential pointers.
1470 1500
1533 (defun texinfo-sequentially-find-pointer (level direction) 1563 (defun texinfo-sequentially-find-pointer (level direction)
1534 "Find next or previous pointer sequentially in Texinfo file, or up pointer. 1564 "Find next or previous pointer sequentially in Texinfo file, or up pointer.
1535 Move point to section associated with the pointer. Find point even if 1565 Move point to section associated with the pointer. Find point even if
1536 it is in a different section. 1566 it is in a different section.
1537 1567
1538 Return type of pointer (either 'normal or 'no-pointer). 1568 Return type of pointer (either `normal' or `no-pointer').
1539 1569
1540 The first argument is a string specifying the general kind of section 1570 The first argument is a string specifying the general kind of section
1541 such as \"chapter\" or \"section\". The section found will be at the 1571 such as \"chapter\" or \"section\". The section found will be at the
1542 same hierarchical level in the Texinfo file, or, in the case of the up 1572 same hierarchical level in the Texinfo file, or, in the case of the up
1543 pointer, some level higher. The second argument (one of 'next, 1573 pointer, some level higher. The second argument (one of `next',
1544 'previous, or 'up) specifies whether to find the `Next', `Previous', 1574 `previous', or `up') specifies whether to find the `Next', `Previous',
1545 or `Up' pointer." 1575 or `Up' pointer."
1546 (let ((case-fold-search t)) 1576 (let ((case-fold-search t))
1547 (cond ((eq direction 'next) 1577 (cond ((eq direction 'next)
1548 (forward-line 3) ; skip over current node 1578 (forward-line 3) ; skip over current node
1549 (if (re-search-forward 1579 (if (re-search-forward
1573 "Insert the `Next', `Previous' or `Up' node name at point. 1603 "Insert the `Next', `Previous' or `Up' node name at point.
1574 Move point forward. 1604 Move point forward.
1575 1605
1576 The first argument is the hierarchical level of the Texinfo file, a 1606 The first argument is the hierarchical level of the Texinfo file, a
1577 string such as \"section\". The second argument is direction, one of 1607 string such as \"section\". The second argument is direction, one of
1578 `next, `previous, or 'up." 1608 `next', `previous', or `up'."
1579 1609
1580 (end-of-line) 1610 (end-of-line)
1581 (insert 1611 (insert
1582 ", " 1612 ", "
1583 (save-excursion 1613 (save-excursion
1584 (texinfo-pointer-name 1614 (texinfo-pointer-name
1585 (texinfo-sequentially-find-pointer level direction))))) 1615 (texinfo-sequentially-find-pointer level direction)))))
1586 1616
1587 1617
1588 ;;; Inserting `@node' lines 1618 ;;; Inserting `@node' lines
1589 ; The `texinfo-insert-node-lines' function inserts `@node' lines as needed 1619 ;; The `texinfo-insert-node-lines' function inserts `@node' lines as needed
1590 ; before the `@chapter', `@section', and such like lines of a region 1620 ;; before the `@chapter', `@section', and such like lines of a region
1591 ; in a Texinfo file. 1621 ;; in a Texinfo file.
1592 1622
1593 (defun texinfo-insert-node-lines (beginning end &optional title-p) 1623 (defun texinfo-insert-node-lines (beginning end &optional title-p)
1594 "Insert missing `@node' lines in region of Texinfo file. 1624 "Insert missing `@node' lines in region of Texinfo file.
1595 Non-nil argument (prefix, if interactive) means also to insert the 1625 Non-nil argument (prefix, if interactive) means also to insert the
1596 section titles as node names; and also to insert the section titles as 1626 section titles as node names; and also to insert the section titles as
1597 node names in pre-existing @node lines that lack names." 1627 node names in pre-existing `@node' lines that lack names."
1598 (interactive "r\nP") 1628 (interactive "r\nP")
1599 1629
1600 ;; Use marker; after inserting node lines, leave point at end of 1630 ;; Use marker; after inserting node lines, leave point at end of
1601 ;; region and mark at beginning. 1631 ;; region and mark at beginning.
1602 1632
1753 * each of the included files must contain exactly one highest 1783 * each of the included files must contain exactly one highest
1754 hierarchical level node, 1784 hierarchical level node,
1755 * this node must be the first node in the included file, 1785 * this node must be the first node in the included file,
1756 * each highest hierarchical level node must be of the same type. 1786 * each highest hierarchical level node must be of the same type.
1757 1787
1758 Thus, normally, each included file contains one, and only one, 1788 Thus, normally, each included file contains one, and only one, chapter."
1759 chapter." 1789
1760 1790 ;; The menu-list has the form:
1761 ; The menu-list has the form: 1791 ;;
1762 ; 1792 ;; \(\(\"node-name1\" . \"title1\"\)
1763 ; \(\(\"node-name1\" . \"title1\"\) 1793 ;; \(\"node-name2\" . \"title2\"\) ... \)
1764 ; \(\"node-name2\" . \"title2\"\) ... \) 1794 ;;
1765 ; 1795 ;; However, there does not need to be a title field and this function
1766 ; However, there does not need to be a title field and this function 1796 ;; does not fill it; however a comment tells you how to do so.
1767 ; does not fill it; however a comment tells you how to do so. 1797 ;; You would use the title field if you wanted to insert titles in the
1768 ; You would use the title field if you wanted to insert titles in the 1798 ;; description slot of a menu as a description.
1769 ; description slot of a menu as a description.
1770 1799
1771 (let ((case-fold-search t) 1800 (let ((case-fold-search t)
1772 menu-list) 1801 menu-list)
1773 1802
1774 ;; Find the name of the first node of the first included file. 1803 ;; Find the name of the first node of the first included file.
1847 (nreverse menu-list))) 1876 (nreverse menu-list)))
1848 1877
1849 (defun texinfo-multi-files-insert-main-menu (menu-list) 1878 (defun texinfo-multi-files-insert-main-menu (menu-list)
1850 "Insert formatted main menu at point. 1879 "Insert formatted main menu at point.
1851 Indents the first line of the description, if any, to the value of 1880 Indents the first line of the description, if any, to the value of
1852 texinfo-column-for-description." 1881 `texinfo-column-for-description'."
1853 1882
1854 (insert "@menu\n") 1883 (insert "@menu\n")
1855 (while menu-list 1884 (while menu-list
1856 ;; Every menu entry starts with a star and a space. 1885 ;; Every menu entry starts with a star and a space.
1857 (insert "* ") 1886 (insert "* ")
1988 (if make-master-menu 2017 (if make-master-menu
1989 (progn 2018 (progn
1990 ;; First, removing detailed part of any pre-existing master menu 2019 ;; First, removing detailed part of any pre-existing master menu
1991 (goto-char (point-min)) 2020 (goto-char (point-min))
1992 (if (re-search-forward texinfo-master-menu-header nil t) 2021 (if (re-search-forward texinfo-master-menu-header nil t)
1993 ;; Remove detailed master menu listing
1994 (progn 2022 (progn
1995 (goto-char (match-beginning 0)) 2023 (goto-char (match-beginning 0))
2024 ;; Check if @detailmenu kludge is used;
2025 ;; if so, leave point before @detailmenu.
2026 (search-backward "\n@detailmenu"
2027 (save-excursion (forward-line -3) (point))
2028 t)
2029 ;; Remove detailed master menu listing
1996 (let ((end-of-detailed-menu-descriptions 2030 (let ((end-of-detailed-menu-descriptions
1997 (save-excursion ; beginning of end menu line 2031 (save-excursion ; beginning of end menu line
1998 (goto-char (texinfo-menu-end)) 2032 (goto-char (texinfo-menu-end))
1999 (beginning-of-line) (forward-char -1) 2033 (beginning-of-line) (forward-char -1)
2000 (point)))) 2034 (point))))