diff options
| author | Stefan Monnier | 2001-10-28 03:24:14 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-10-28 03:24:14 +0000 |
| commit | b9f60161102101cb0bbc31db7cc2079e2953273e (patch) | |
| tree | a54be95d124faf152feb2e3b54201e6ef6f7f457 | |
| parent | 788faf1fc20d8d9ce1f2193c75a20614a74cfa7e (diff) | |
| download | emacs-b9f60161102101cb0bbc31db7cc2079e2953273e.tar.gz emacs-b9f60161102101cb0bbc31db7cc2079e2953273e.zip | |
Use `when', `dolist', `push', ...
(texinfo-update-node, texinfo-sequential-node-update):
Don't bind the obsolete `auto-fill-hook'.
(texinfo-multi-file-included-list,texinfo-multi-file-master-menu-list):
Use `set-buffer' rather than `switch-to-buffer'.
(texinfo-multi-file-update): Use "Top" rather than `up-node-name'.
Use `set-buffer' rather than `switch-to-buffer'.
| -rw-r--r-- | lisp/textmodes/texnfo-upd.el | 495 |
1 files changed, 222 insertions, 273 deletions
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el index d928ec44c68..eee804cd513 100644 --- a/lisp/textmodes/texnfo-upd.el +++ b/lisp/textmodes/texnfo-upd.el | |||
| @@ -318,11 +318,10 @@ at the level specified by LEVEL. Point is left at the end of menu." | |||
| 318 | (beginning-of-line) | 318 | (beginning-of-line) |
| 319 | (texinfo-copy-node-name))) | 319 | (texinfo-copy-node-name))) |
| 320 | (new-menu-list (texinfo-make-menu-list beginning end level))) | 320 | (new-menu-list (texinfo-make-menu-list beginning end level))) |
| 321 | (if (texinfo-old-menu-p beginning first) | 321 | (when (texinfo-old-menu-p beginning first) |
| 322 | (progn | 322 | (texinfo-incorporate-descriptions new-menu-list) |
| 323 | (texinfo-incorporate-descriptions new-menu-list) | 323 | (texinfo-incorporate-menu-entry-names new-menu-list) |
| 324 | (texinfo-incorporate-menu-entry-names new-menu-list) | 324 | (texinfo-delete-old-menu beginning first)) |
| 325 | (texinfo-delete-old-menu beginning first))) | ||
| 326 | (texinfo-insert-menu new-menu-list node-name))) | 325 | (texinfo-insert-menu new-menu-list node-name))) |
| 327 | 326 | ||
| 328 | (defun texinfo-all-menus-update (&optional update-all-nodes-p) | 327 | (defun texinfo-all-menus-update (&optional update-all-nodes-p) |
| @@ -339,35 +338,32 @@ nodes in the buffer before updating the menus." | |||
| 339 | (goto-char (point-min)) | 338 | (goto-char (point-min)) |
| 340 | (message "Checking for a master menu in %s ... "(buffer-name)) | 339 | (message "Checking for a master menu in %s ... "(buffer-name)) |
| 341 | (save-excursion | 340 | (save-excursion |
| 342 | (if (search-forward texinfo-master-menu-header nil t) | 341 | (when (search-forward texinfo-master-menu-header nil t) |
| 343 | (progn | 342 | ;; Check if @detailmenu kludge is used; |
| 344 | ;; Check if @detailmenu kludge is used; | 343 | ;; if so, leave point before @detailmenu. |
| 345 | ;; if so, leave point before @detailmenu. | 344 | (search-backward "\n@detailmenu" |
| 346 | (search-backward "\n@detailmenu" | 345 | (save-excursion (forward-line -3) (point)) |
| 347 | (save-excursion (forward-line -3) (point)) | 346 | t) |
| 348 | t) | 347 | ;; Remove detailed master menu listing |
| 349 | ;; Remove detailed master menu listing | 348 | (setq master-menu-p t) |
| 350 | (setq master-menu-p t) | 349 | (goto-char (match-beginning 0)) |
| 351 | (goto-char (match-beginning 0)) | 350 | (let ((end-of-detailed-menu-descriptions |
| 352 | (let ((end-of-detailed-menu-descriptions | 351 | (save-excursion ; beginning of end menu line |
| 353 | (save-excursion ; beginning of end menu line | 352 | (goto-char (texinfo-menu-end)) |
| 354 | (goto-char (texinfo-menu-end)) | 353 | (beginning-of-line) (forward-char -1) |
| 355 | (beginning-of-line) (forward-char -1) | 354 | (point)))) |
| 356 | (point)))) | 355 | (delete-region (point) end-of-detailed-menu-descriptions)))) |
| 357 | (delete-region (point) end-of-detailed-menu-descriptions))))) | 356 | |
| 358 | 357 | (when update-all-nodes-p | |
| 359 | (if update-all-nodes-p | 358 | (message "Updating all nodes in %s ... " (buffer-name)) |
| 360 | (progn | 359 | (texinfo-update-node (point-min) (point-max))) |
| 361 | (message "Updating all nodes in %s ... " (buffer-name)) | ||
| 362 | (texinfo-update-node (point-min) (point-max)))) | ||
| 363 | 360 | ||
| 364 | (message "Updating all menus in %s ... " (buffer-name)) | 361 | (message "Updating all menus in %s ... " (buffer-name)) |
| 365 | (texinfo-make-menu (point-max) (point-min)) | 362 | (texinfo-make-menu (point-max) (point-min)) |
| 366 | 363 | ||
| 367 | (if master-menu-p | 364 | (when master-menu-p |
| 368 | (progn | 365 | (message "Updating the master menu in %s... " (buffer-name)) |
| 369 | (message "Updating the master menu in %s... " (buffer-name)) | 366 | (texinfo-master-menu nil))) |
| 370 | (texinfo-master-menu nil)))) | ||
| 371 | 367 | ||
| 372 | (message "Done...updated all the menus. You may save the buffer."))) | 368 | (message "Done...updated all the menus. You may save the buffer."))) |
| 373 | 369 | ||
| @@ -413,18 +409,18 @@ if the match is found there, the value is t and point does not move." | |||
| 413 | (if (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" region-end t) | 409 | (if (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" region-end t) |
| 414 | (progn (beginning-of-line) t))) | 410 | (progn (beginning-of-line) t))) |
| 415 | (t | 411 | (t |
| 416 | (if (re-search-forward | 412 | (when (re-search-forward |
| 417 | (concat | 413 | (concat |
| 418 | "\\(^@node\\).*\n" ; match node line | 414 | "\\(^@node\\).*\n" ; match node line |
| 419 | "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | 415 | "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any |
| 420 | "\\|" ; or | 416 | "\\|" ; or |
| 421 | "\\(^@ifinfo[ ]*\n\\)" ; ifinfo line, if any | 417 | "\\(^@ifinfo[ ]*\n\\)" ; ifinfo line, if any |
| 422 | "\\|" ; or | 418 | "\\|" ; or |
| 423 | "\\(^@ifnottex[ ]*\n\\)" ; ifnottex line, if any | 419 | "\\(^@ifnottex[ ]*\n\\)" ; ifnottex line, if any |
| 424 | "\\)?" ; end of expression | 420 | "\\)?" ; end of expression |
| 425 | (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) | 421 | (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) |
| 426 | region-end t) | 422 | region-end t) |
| 427 | (progn (beginning-of-line) t)))))) | 423 | (beginning-of-line) t))))) |
| 428 | 424 | ||
| 429 | 425 | ||
| 430 | ;;; Making the list of new menu entries | 426 | ;;; Making the list of new menu entries |
| @@ -443,14 +439,13 @@ element consists only of the node name." | |||
| 443 | (goto-char beginning) | 439 | (goto-char beginning) |
| 444 | (let (new-menu-list) | 440 | (let (new-menu-list) |
| 445 | (while (texinfo-menu-locate-entry-p level end) | 441 | (while (texinfo-menu-locate-entry-p level end) |
| 446 | (setq new-menu-list | 442 | (push (cons |
| 447 | (cons (cons | 443 | (texinfo-copy-node-name) |
| 448 | (texinfo-copy-node-name) | 444 | (prog1 "" (forward-line 1))) |
| 449 | (prog1 "" (forward-line 1))) | 445 | ;; Use following to insert section titles automatically. |
| 450 | ;; Use following to insert section titles automatically. | 446 | ;; (texinfo-copy-section-title)) |
| 451 | ;; (texinfo-copy-section-title)) | 447 | new-menu-list)) |
| 452 | new-menu-list))) | 448 | (nreverse new-menu-list))) |
| 453 | (reverse new-menu-list))) | ||
| 454 | 449 | ||
| 455 | (defun texinfo-menu-locate-entry-p (level search-end) | 450 | (defun texinfo-menu-locate-entry-p (level search-end) |
| 456 | "Find a node that will be part of menu for this section. | 451 | "Find a node that will be part of menu for this section. |
| @@ -492,9 +487,7 @@ line. If there is no node name, returns an empty string." | |||
| 492 | (progn (forward-word 1) ; skip over node command | 487 | (progn (forward-word 1) ; skip over node command |
| 493 | (skip-chars-forward " \t") ; and over spaces | 488 | (skip-chars-forward " \t") ; and over spaces |
| 494 | (point)) | 489 | (point)) |
| 495 | (if (search-forward | 490 | (if (search-forward "," (line-end-position) t) ; bound search |
| 496 | "," | ||
| 497 | (save-excursion (end-of-line) (point)) t) ; bound search | ||
| 498 | (1- (point)) | 491 | (1- (point)) |
| 499 | (end-of-line) (point))))) | 492 | (end-of-line) (point))))) |
| 500 | 493 | ||
| @@ -534,9 +527,9 @@ node within the section. | |||
| 534 | If no menu is found, the function inserts two newlines just before the | 527 | If no menu is found, the function inserts two newlines just before the |
| 535 | end of the section, and leaves point there where a menu ought to be." | 528 | end of the section, and leaves point there where a menu ought to be." |
| 536 | (goto-char beginning) | 529 | (goto-char beginning) |
| 537 | (if (not (re-search-forward "^@menu" first 'goto-end)) | 530 | (if (re-search-forward "^@menu" first 'goto-end) |
| 538 | (progn (insert "\n\n") (forward-line -2) nil) | 531 | t |
| 539 | t)) | 532 | (insert "\n\n") (forward-line -2) nil)) |
| 540 | 533 | ||
| 541 | (defun texinfo-incorporate-descriptions (new-menu-list) | 534 | (defun texinfo-incorporate-descriptions (new-menu-list) |
| 542 | "Copy the old menu line descriptions that exist to the new menu. | 535 | "Copy the old menu line descriptions that exist to the new menu. |
| @@ -551,29 +544,25 @@ pairs in which the first element of the pair is the node name and the | |||
| 551 | second element the description. The new menu is changed destructively. | 544 | second element the description. The new menu is changed destructively. |
| 552 | The old menu is the menu as it appears in the Texinfo file." | 545 | The old menu is the menu as it appears in the Texinfo file." |
| 553 | 546 | ||
| 554 | (let ((new-menu-list-pointer new-menu-list) | 547 | (let ((end-of-menu (texinfo-menu-end))) |
| 555 | (end-of-menu (texinfo-menu-end))) | 548 | (dolist (new-menu new-menu-list new-menu-list) |
| 556 | (while new-menu-list | 549 | (save-excursion ; keep point at beginning of menu |
| 557 | (save-excursion ; keep point at beginning of menu | 550 | (when (re-search-forward |
| 558 | (if (re-search-forward | 551 | ;; Existing nodes can have the form |
| 559 | ;; Existing nodes can have the form | 552 | ;; * NODE NAME:: DESCRIPTION |
| 560 | ;; * NODE NAME:: DESCRIPTION | 553 | ;; or |
| 561 | ;; or | 554 | ;; * MENU ITEM: NODE NAME. DESCRIPTION. |
| 562 | ;; * MENU ITEM: NODE NAME. DESCRIPTION. | 555 | ;; |
| 563 | ;; | 556 | ;; Recognize both when looking for the description. |
| 564 | ;; Recognize both when looking for the description. | 557 | (concat "\\* \\(" ; so only menu entries are found |
| 565 | (concat "\\* \\(" ; so only menu entries are found | 558 | (regexp-quote (car new-menu)) "::" |
| 566 | (regexp-quote (car (car new-menu-list))) "::" | 559 | "\\|" |
| 567 | "\\|" | 560 | ".*: " (regexp-quote (car new-menu)) "[.,\t\n]" |
| 568 | ".*: " (regexp-quote (car (car new-menu-list))) "[.,\t\n]" | 561 | "\\)" |
| 569 | "\\)" | 562 | ) ; so only complete entries are found |
| 570 | ) ; so only complete entries are found | 563 | end-of-menu |
| 571 | end-of-menu | 564 | t) |
| 572 | t) | 565 | (setcdr new-menu (texinfo-menu-copy-old-description end-of-menu))))))) |
| 573 | (setcdr (car new-menu-list) | ||
| 574 | (texinfo-menu-copy-old-description end-of-menu)))) | ||
| 575 | (setq new-menu-list (cdr new-menu-list))) | ||
| 576 | (setq new-menu-list new-menu-list-pointer))) | ||
| 577 | 566 | ||
| 578 | (defun texinfo-incorporate-menu-entry-names (new-menu-list) | 567 | (defun texinfo-incorporate-menu-entry-names (new-menu-list) |
| 579 | "Copy any old menu entry names to the new menu. | 568 | "Copy any old menu entry names to the new menu. |
| @@ -594,9 +583,8 @@ name and the cdr is the node name. | |||
| 594 | NEW-MENU-LIST is changed destructively. The old menu is the menu as it | 583 | NEW-MENU-LIST is changed destructively. The old menu is the menu as it |
| 595 | appears in the texinfo file." | 584 | appears in the texinfo file." |
| 596 | 585 | ||
| 597 | (let ((new-menu-list-pointer new-menu-list) | 586 | (let ((end-of-menu (texinfo-menu-end))) |
| 598 | (end-of-menu (texinfo-menu-end))) | 587 | (dolist (new-menu new-menu-list new-menu-list) |
| 599 | (while new-menu-list | ||
| 600 | (save-excursion ; keep point at beginning of menu | 588 | (save-excursion ; keep point at beginning of menu |
| 601 | (if (re-search-forward | 589 | (if (re-search-forward |
| 602 | ;; Existing nodes can have the form | 590 | ;; Existing nodes can have the form |
| @@ -606,16 +594,14 @@ appears in the texinfo file." | |||
| 606 | ;; | 594 | ;; |
| 607 | ;; We're interested in the second case. | 595 | ;; We're interested in the second case. |
| 608 | (concat "\\* " ; so only menu entries are found | 596 | (concat "\\* " ; so only menu entries are found |
| 609 | "\\(.*\\): " (regexp-quote (car (car new-menu-list))) | 597 | "\\(.*\\): " (regexp-quote (car new-menu)) |
| 610 | "[.,\t\n]") | 598 | "[.,\t\n]") |
| 611 | end-of-menu | 599 | end-of-menu |
| 612 | t) | 600 | t) |
| 613 | (setcar | 601 | (setcar |
| 614 | (car new-menu-list) ; replace the node name | 602 | new-menu ; replace the node name |
| 615 | (cons (buffer-substring (match-beginning 1) (match-end 1)) | 603 | (cons (buffer-substring (match-beginning 1) (match-end 1)) |
| 616 | (car (car new-menu-list))))) | 604 | (car new-menu)))))))) |
| 617 | (setq new-menu-list (cdr new-menu-list)))) | ||
| 618 | (setq new-menu-list new-menu-list-pointer))) | ||
| 619 | 605 | ||
| 620 | (defun texinfo-menu-copy-old-description (end-of-menu) | 606 | (defun texinfo-menu-copy-old-description (end-of-menu) |
| 621 | "Return description field of old menu line as string. | 607 | "Return description field of old menu line as string. |
| @@ -680,12 +666,12 @@ strings instead of just a string. In that case, the car of P | |||
| 680 | is the menu entry name, and the cdr of P is the node name." | 666 | is the menu entry name, and the cdr of P is the node name." |
| 681 | 667 | ||
| 682 | (insert "@menu\n") | 668 | (insert "@menu\n") |
| 683 | (while menu-list | 669 | (dolist (menu menu-list) |
| 684 | ;; Every menu entry starts with a star and a space. | 670 | ;; Every menu entry starts with a star and a space. |
| 685 | (insert "* ") | 671 | (insert "* ") |
| 686 | 672 | ||
| 687 | ;; Insert the node name (and menu entry name, if present). | 673 | ;; Insert the node name (and menu entry name, if present). |
| 688 | (let ((node-part (car (car menu-list)))) | 674 | (let ((node-part (car menu))) |
| 689 | (if (stringp node-part) | 675 | (if (stringp node-part) |
| 690 | ;; "Double colon" entry line; menu entry and node name are the same, | 676 | ;; "Double colon" entry line; menu entry and node name are the same, |
| 691 | (insert (format "%s::" node-part)) | 677 | (insert (format "%s::" node-part)) |
| @@ -693,17 +679,16 @@ is the menu entry name, and the cdr of P is the node name." | |||
| 693 | (insert (format "%s: %s." (car node-part) (cdr node-part))))) | 679 | (insert (format "%s: %s." (car node-part) (cdr node-part))))) |
| 694 | 680 | ||
| 695 | ;; Insert the description, if present. | 681 | ;; Insert the description, if present. |
| 696 | (if (cdr (car menu-list)) | 682 | (when (cdr menu) |
| 697 | (progn | 683 | ;; Move to right place. |
| 698 | ;; Move to right place. | 684 | (indent-to texinfo-column-for-description 2) |
| 699 | (indent-to texinfo-column-for-description 2) | 685 | ;; Insert description. |
| 700 | ;; Insert description. | 686 | (insert (format "%s" (cdr menu)))) |
| 701 | (insert (format "%s" (cdr (car menu-list)))))) | ||
| 702 | 687 | ||
| 703 | (insert "\n") ; end this menu entry | 688 | (insert "\n")) ; end this menu entry |
| 704 | (setq menu-list (cdr menu-list))) | ||
| 705 | (insert "@end menu") | 689 | (insert "@end menu") |
| 706 | (message | 690 | (message |
| 691 | ;; FIXME: `level' is passed by dynamic scoping. | ||
| 707 | "Updated \"%s\" level menu following node: %s ... " level node-name)) | 692 | "Updated \"%s\" level menu following node: %s ... " level node-name)) |
| 708 | 693 | ||
| 709 | 694 | ||
| @@ -720,14 +705,14 @@ complements the node name rather than repeats it as a title does." | |||
| 720 | (interactive) | 705 | (interactive) |
| 721 | (let (beginning end node-name title) | 706 | (let (beginning end node-name title) |
| 722 | (save-excursion | 707 | (save-excursion |
| 723 | (beginning-of-line) | 708 | (beginning-of-line) |
| 724 | (if (search-forward "* " (save-excursion (end-of-line) (point)) t) | 709 | (if (search-forward "* " (save-excursion (end-of-line) (point)) t) |
| 725 | (progn (skip-chars-forward " \t") | 710 | (progn (skip-chars-forward " \t") |
| 726 | (setq beginning (point))) | 711 | (setq beginning (point))) |
| 727 | (error "This is not a line in a menu")) | 712 | (error "This is not a line in a menu")) |
| 728 | 713 | ||
| 729 | (cond | 714 | (cond |
| 730 | ;; "Double colon" entry line; menu entry and node name are the same, | 715 | ;; "Double colon" entry line; menu entry and node name are the same, |
| 731 | ((search-forward "::" (save-excursion (end-of-line) (point)) t) | 716 | ((search-forward "::" (save-excursion (end-of-line) (point)) t) |
| 732 | (if (looking-at "[ \t]*[^ \t\n]+") | 717 | (if (looking-at "[ \t]*[^ \t\n]+") |
| 733 | (error "Descriptive text already exists")) | 718 | (error "Descriptive text already exists")) |
| @@ -748,7 +733,7 @@ complements the node name rather than repeats it as a title does." | |||
| 748 | (setq node-name (buffer-substring beginning (point)))) | 733 | (setq node-name (buffer-substring beginning (point)))) |
| 749 | ;; Menu entry line ends in a return. | 734 | ;; Menu entry line ends in a return. |
| 750 | (re-search-forward ".*\n" | 735 | (re-search-forward ".*\n" |
| 751 | (save-excursion (forward-line 1) (point)) t) | 736 | (save-excursion (forward-line 1) (point)) t) |
| 752 | (skip-chars-backward " \t\n") | 737 | (skip-chars-backward " \t\n") |
| 753 | (setq node-name (buffer-substring beginning (point))) | 738 | (setq node-name (buffer-substring beginning (point))) |
| 754 | (if (= 0 (length node-name)) | 739 | (if (= 0 (length node-name)) |
| @@ -760,7 +745,7 @@ complements the node name rather than repeats it as a title does." | |||
| 760 | (concat | 745 | (concat |
| 761 | "^@node[ \t]+" | 746 | "^@node[ \t]+" |
| 762 | (regexp-quote node-name) | 747 | (regexp-quote node-name) |
| 763 | ".*\n" ; match node line | 748 | ".*\n" ; match node line |
| 764 | "\\(" | 749 | "\\(" |
| 765 | "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any | 750 | "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any |
| 766 | "\\|" ; or | 751 | "\\|" ; or |
| @@ -770,17 +755,16 @@ complements the node name rather than repeats it as a title does." | |||
| 770 | "\\)?" ; end of expression | 755 | "\\)?" ; end of expression |
| 771 | "\\)?") | 756 | "\\)?") |
| 772 | nil t) | 757 | nil t) |
| 773 | (progn | 758 | (setq title |
| 774 | (setq title | 759 | (buffer-substring |
| 775 | (buffer-substring | 760 | ;; skip over section type |
| 776 | ;; skip over section type | 761 | (progn (forward-word 1) |
| 777 | (progn (forward-word 1) | 762 | ;; and over spaces |
| 778 | ;; and over spaces | 763 | (skip-chars-forward " \t") |
| 779 | (skip-chars-forward " \t") | 764 | (point)) |
| 780 | (point)) | 765 | (progn (end-of-line) |
| 781 | (progn (end-of-line) | 766 | (skip-chars-backward " \t") |
| 782 | (skip-chars-backward " \t") | 767 | (point)))) |
| 783 | (point))))) | ||
| 784 | (error "Cannot find node to match node name in menu entry"))) | 768 | (error "Cannot find node to match node name in menu entry"))) |
| 785 | ;; Return point to the menu and insert the title. | 769 | ;; Return point to the menu and insert the title. |
| 786 | (end-of-line) | 770 | (end-of-line) |
| @@ -829,22 +813,21 @@ leave point on the line before the `@end menu' line. Does not indent | |||
| 829 | second and subsequent lines of a multi-line description." | 813 | second and subsequent lines of a multi-line description." |
| 830 | (let* ((beginning-of-next-line (point))) | 814 | (let* ((beginning-of-next-line (point))) |
| 831 | (while (< beginning-of-next-line | 815 | (while (< beginning-of-next-line |
| 832 | (save-excursion ; beginning of end menu line | 816 | (save-excursion ; beginning of end menu line |
| 833 | (goto-char (texinfo-menu-end)) | 817 | (goto-char (texinfo-menu-end)) |
| 834 | (beginning-of-line) | 818 | (beginning-of-line) |
| 835 | (point))) | 819 | (point))) |
| 836 | 820 | ||
| 837 | (if (re-search-forward "\\* \\(.*::\\|.*: [^.,\t\n]+[.,\t]\\)" | 821 | (when (re-search-forward "\\* \\(.*::\\|.*: [^.,\t\n]+[.,\t]\\)" |
| 838 | (texinfo-menu-end) | 822 | (texinfo-menu-end) |
| 839 | t) | 823 | t) |
| 840 | (progn | 824 | (let ((beginning-white-space (point))) |
| 841 | (let ((beginning-white-space (point))) | 825 | (skip-chars-forward " \t") ; skip over spaces |
| 842 | (skip-chars-forward " \t") ; skip over spaces | 826 | (if (looking-at "\\(@\\|\\w\\)+") ; if there is text |
| 843 | (if (looking-at "\\(@\\|\\w\\)+") ; if there is text | 827 | (progn |
| 844 | (progn | 828 | ;; remove pre-existing indentation |
| 845 | ;; remove pre-existing indentation | 829 | (delete-region beginning-white-space (point)) |
| 846 | (delete-region beginning-white-space (point)) | 830 | (indent-to-column to-column-number))))) |
| 847 | (indent-to-column to-column-number)))))) | ||
| 848 | ;; position point at beginning of next line | 831 | ;; position point at beginning of next line |
| 849 | (forward-line 1) | 832 | (forward-line 1) |
| 850 | (setq beginning-of-next-line (point))))) | 833 | (setq beginning-of-next-line (point))))) |
| @@ -974,25 +957,21 @@ However, there does not need to be a title field." | |||
| 974 | 957 | ||
| 975 | (let (master-menu-list) | 958 | (let (master-menu-list) |
| 976 | (while (texinfo-locate-menu-p) | 959 | (while (texinfo-locate-menu-p) |
| 977 | (setq master-menu-list | 960 | (push (list (texinfo-copy-menu) (texinfo-copy-menu-title)) |
| 978 | (cons (list | 961 | master-menu-list)) |
| 979 | (texinfo-copy-menu) | 962 | (nreverse master-menu-list))) |
| 980 | (texinfo-copy-menu-title)) | ||
| 981 | master-menu-list))) | ||
| 982 | (reverse master-menu-list))) | ||
| 983 | 963 | ||
| 984 | (defun texinfo-insert-master-menu-list (master-menu-list) | 964 | (defun texinfo-insert-master-menu-list (master-menu-list) |
| 985 | "Format and insert the master menu in the current buffer." | 965 | "Format and insert the master menu in the current buffer." |
| 986 | (goto-char (point-min)) | 966 | (goto-char (point-min)) |
| 987 | ;; Insert a master menu only after `Top' node and before next node | 967 | ;; Insert a master menu only after `Top' node and before next node |
| 988 | ;; \(or include file if there is no next node\). | 968 | ;; \(or include file if there is no next node\). |
| 989 | (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) | 969 | (unless (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) |
| 990 | (error "This buffer needs a Top node")) | 970 | (error "This buffer needs a Top node")) |
| 991 | (let ((first-chapter | 971 | (let ((first-chapter |
| 992 | (save-excursion (re-search-forward "^@node\\|^@include") (point)))) | 972 | (save-excursion (re-search-forward "^@node\\|^@include") (point)))) |
| 993 | (if (not (re-search-forward "^@menu" first-chapter t)) | 973 | (unless (re-search-forward "^@menu" first-chapter t) |
| 994 | (error | 974 | (error "Buffer lacks ordinary `Top' menu in which to insert master"))) |
| 995 | "Buffer lacks ordinary `Top' menu in which to insert master"))) | ||
| 996 | (beginning-of-line) | 975 | (beginning-of-line) |
| 997 | (delete-region ; buffer must have ordinary top menu | 976 | (delete-region ; buffer must have ordinary top menu |
| 998 | (point) | 977 | (point) |
| @@ -1004,13 +983,11 @@ However, there does not need to be a title field." | |||
| 1004 | (let (master-menu-inserted-p) | 983 | (let (master-menu-inserted-p) |
| 1005 | ;; Handle top of menu | 984 | ;; Handle top of menu |
| 1006 | (insert "\n@menu\n") | 985 | (insert "\n@menu\n") |
| 1007 | ;; Insert chapter menu entries | 986 | ;; Insert chapter menu entries. Tell user what is going on. |
| 1008 | (setq this-very-menu-list (reverse (car (car master-menu-list)))) | 987 | (message "Inserting chapter menu entry: %s ... " |
| 1009 | ;; Tell user what is going on. | 988 | (car (car master-menu-list))) |
| 1010 | (message "Inserting chapter menu entry: %s ... " this-very-menu-list) | 989 | (dolist (entry (reverse (car (car master-menu-list)))) |
| 1011 | (while this-very-menu-list | 990 | (insert "* " entry "\n")) |
| 1012 | (insert "* " (car this-very-menu-list) "\n") | ||
| 1013 | (setq this-very-menu-list (cdr this-very-menu-list))) | ||
| 1014 | 991 | ||
| 1015 | (setq master-menu-list (cdr master-menu-list)) | 992 | (setq master-menu-list (cdr master-menu-list)) |
| 1016 | 993 | ||
| @@ -1034,20 +1011,15 @@ However, there does not need to be a title field." | |||
| 1034 | ;; ((("beta" "alpha") "title-A") | 1011 | ;; ((("beta" "alpha") "title-A") |
| 1035 | ;; (("delta" "gamma") "title-B")) | 1012 | ;; (("delta" "gamma") "title-B")) |
| 1036 | 1013 | ||
| 1037 | (while master-menu-list | 1014 | (dolist (menu master-menu-list) |
| 1038 | 1015 | ||
| 1039 | (message | 1016 | (message "Inserting menu for %s .... " (cadr menu)) |
| 1040 | "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) | ||
| 1041 | ;; insert title of menu section | 1017 | ;; insert title of menu section |
| 1042 | (insert "\n" (car (cdr (car master-menu-list))) "\n\n") | 1018 | (insert "\n" (cadr menu) "\n\n") |
| 1043 | 1019 | ||
| 1044 | ;; insert each menu entry | 1020 | ;; insert each menu entry |
| 1045 | (setq this-very-menu-list (reverse (car (car master-menu-list)))) | 1021 | (dolist (entry (reverse (car menu))) |
| 1046 | (while this-very-menu-list | 1022 | (insert "* " entry "\n"))) |
| 1047 | (insert "* " (car this-very-menu-list) "\n") | ||
| 1048 | (setq this-very-menu-list (cdr this-very-menu-list))) | ||
| 1049 | |||
| 1050 | (setq master-menu-list (cdr master-menu-list))) | ||
| 1051 | 1023 | ||
| 1052 | ;; Finish menu | 1024 | ;; Finish menu |
| 1053 | 1025 | ||
| @@ -1063,7 +1035,7 @@ If found, leave point after word `menu' on the `@menu' line, and return t. | |||
| 1063 | If a menu is not found, do not move point and return nil." | 1035 | If a menu is not found, do not move point and return nil." |
| 1064 | (re-search-forward "\\(^@menu\\)" nil t)) | 1036 | (re-search-forward "\\(^@menu\\)" nil t)) |
| 1065 | 1037 | ||
| 1066 | (defun texinfo-copy-menu-title () | 1038 | (defun texinfo-copy-menu-title () |
| 1067 | "Return the title of the section preceding the menu as a string. | 1039 | "Return the title of the section preceding the menu as a string. |
| 1068 | If such a title cannot be found, return an empty string. Do not move | 1040 | If such a title cannot be found, return an empty string. Do not move |
| 1069 | point." | 1041 | point." |
| @@ -1101,16 +1073,13 @@ and leave point on the line before the `@end menu' line." | |||
| 1101 | (point)))) | 1073 | (point)))) |
| 1102 | (while (< (point) last-entry) | 1074 | (while (< (point) last-entry) |
| 1103 | (if (re-search-forward "^\\* " end-of-menu t) | 1075 | (if (re-search-forward "^\\* " end-of-menu t) |
| 1104 | (progn | 1076 | (push (buffer-substring |
| 1105 | (setq this-menu-list | 1077 | (point) |
| 1106 | (cons | 1078 | ;; copy multi-line descriptions |
| 1107 | (buffer-substring | 1079 | (save-excursion |
| 1108 | (point) | 1080 | (re-search-forward "\\(^\\* \\|^@e\\)" nil t) |
| 1109 | ;; copy multi-line descriptions | 1081 | (- (point) 3))) |
| 1110 | (save-excursion | 1082 | this-menu-list))) |
| 1111 | (re-search-forward "\\(^\\* \\|^@e\\)" nil t) | ||
| 1112 | (- (point) 3))) | ||
| 1113 | this-menu-list))))) | ||
| 1114 | this-menu-list)) | 1083 | this-menu-list)) |
| 1115 | 1084 | ||
| 1116 | 1085 | ||
| @@ -1127,10 +1096,8 @@ error if the node is not the top node and a section is not found." | |||
| 1127 | (save-excursion | 1096 | (save-excursion |
| 1128 | (cond | 1097 | (cond |
| 1129 | ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" | 1098 | ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" |
| 1130 | ;;; Following search limit by cph but causes a bug | 1099 | ;; Following search limit by cph but causes a bug |
| 1131 | ;;; (save-excursion | 1100 | ;;(line-end-position) |
| 1132 | ;;; (end-of-line) | ||
| 1133 | ;;; (point)) | ||
| 1134 | nil | 1101 | nil |
| 1135 | t) | 1102 | t) |
| 1136 | "top") | 1103 | "top") |
| @@ -1149,8 +1116,8 @@ error if the node is not the top node and a section is not found." | |||
| 1149 | Thus, a subheading or appendixsubsec is of type subsection." | 1116 | Thus, a subheading or appendixsubsec is of type subsection." |
| 1150 | (let ((case-fold-search t)) | 1117 | (let ((case-fold-search t)) |
| 1151 | (cadr (assoc | 1118 | (cadr (assoc |
| 1152 | (texinfo-specific-section-type) | 1119 | (texinfo-specific-section-type) |
| 1153 | texinfo-section-list)))) | 1120 | texinfo-section-list)))) |
| 1154 | 1121 | ||
| 1155 | 1122 | ||
| 1156 | ;;; Locating the major positions | 1123 | ;;; Locating the major positions |
| @@ -1257,14 +1224,13 @@ which menu descriptions are indented. Its default value is 32." | |||
| 1257 | (list (point) (mark)))) | 1224 | (list (point) (mark)))) |
| 1258 | (if (null beginning) | 1225 | (if (null beginning) |
| 1259 | ;; Update a single node. | 1226 | ;; Update a single node. |
| 1260 | (let ((auto-fill-function nil) (auto-fill-hook nil)) | 1227 | (let ((auto-fill-function nil)) |
| 1261 | (if (not (re-search-backward "^@node" (point-min) t)) | 1228 | (if (not (re-search-backward "^@node" (point-min) t)) |
| 1262 | (error "Node line not found before this position")) | 1229 | (error "Node line not found before this position")) |
| 1263 | (texinfo-update-the-node) | 1230 | (texinfo-update-the-node) |
| 1264 | (message "Done...updated the node. You may save the buffer.")) | 1231 | (message "Done...updated the node. You may save the buffer.")) |
| 1265 | ;; else | 1232 | ;; else |
| 1266 | (let ((auto-fill-function nil) | 1233 | (let ((auto-fill-function nil)) |
| 1267 | (auto-fill-hook nil)) | ||
| 1268 | (save-excursion | 1234 | (save-excursion |
| 1269 | (save-restriction | 1235 | (save-restriction |
| 1270 | (narrow-to-region beginning end) | 1236 | (narrow-to-region beginning end) |
| @@ -1531,7 +1497,7 @@ Info `g*' command is inadequate." | |||
| 1531 | (interactive "P") | 1497 | (interactive "P") |
| 1532 | (if (not region-p) | 1498 | (if (not region-p) |
| 1533 | ;; update a single node | 1499 | ;; update a single node |
| 1534 | (let ((auto-fill-function nil) (auto-fill-hook nil)) | 1500 | (let ((auto-fill-function nil)) |
| 1535 | (if (not (re-search-backward "^@node" (point-min) t)) | 1501 | (if (not (re-search-backward "^@node" (point-min) t)) |
| 1536 | (error "Node line not found before this position")) | 1502 | (error "Node line not found before this position")) |
| 1537 | (texinfo-sequentially-update-the-node) | 1503 | (texinfo-sequentially-update-the-node) |
| @@ -1539,7 +1505,6 @@ Info `g*' command is inadequate." | |||
| 1539 | "Done...sequentially updated the node . You may save the buffer.")) | 1505 | "Done...sequentially updated the node . You may save the buffer.")) |
| 1540 | ;; else | 1506 | ;; else |
| 1541 | (let ((auto-fill-function nil) | 1507 | (let ((auto-fill-function nil) |
| 1542 | (auto-fill-hook nil) | ||
| 1543 | (beginning (region-beginning)) | 1508 | (beginning (region-beginning)) |
| 1544 | (end (region-end))) | 1509 | (end (region-end))) |
| 1545 | (if (= end beginning) | 1510 | (if (= end beginning) |
| @@ -1607,6 +1572,7 @@ or `Up' pointer." | |||
| 1607 | ((eq direction 'up) | 1572 | ((eq direction 'up) |
| 1608 | (if (re-search-backward | 1573 | (if (re-search-backward |
| 1609 | (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) | 1574 | (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) |
| 1575 | ;; FIXME: passed many levels down via dynamic scoping! | ||
| 1610 | beginning | 1576 | beginning |
| 1611 | t) | 1577 | t) |
| 1612 | 'normal | 1578 | 'normal |
| @@ -1741,7 +1707,7 @@ node names in pre-existing `@node' lines that lack names." | |||
| 1741 | (let ((included-file-list (list outer-file)) | 1707 | (let ((included-file-list (list outer-file)) |
| 1742 | start) | 1708 | start) |
| 1743 | (save-excursion | 1709 | (save-excursion |
| 1744 | (switch-to-buffer (find-file-noselect outer-file)) | 1710 | (set-buffer (find-file-noselect outer-file)) |
| 1745 | (widen) | 1711 | (widen) |
| 1746 | (goto-char (point-min)) | 1712 | (goto-char (point-min)) |
| 1747 | (while (re-search-forward "^@include" nil t) | 1713 | (while (re-search-forward "^@include" nil t) |
| @@ -1813,10 +1779,10 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1813 | ;; description slot of a menu as a description. | 1779 | ;; description slot of a menu as a description. |
| 1814 | 1780 | ||
| 1815 | (let ((case-fold-search t) | 1781 | (let ((case-fold-search t) |
| 1816 | menu-list) | 1782 | menu-list next-node-name previous-node-name) |
| 1817 | 1783 | ||
| 1818 | ;; Find the name of the first node of the first included file. | 1784 | ;; Find the name of the first node of the first included file. |
| 1819 | (switch-to-buffer (find-file-noselect (car (cdr files)))) | 1785 | (set-buffer (find-file-noselect (car (cdr files)))) |
| 1820 | (widen) | 1786 | (widen) |
| 1821 | (goto-char (point-min)) | 1787 | (goto-char (point-min)) |
| 1822 | (if (not (re-search-forward "^@node" nil t)) | 1788 | (if (not (re-search-forward "^@node" nil t)) |
| @@ -1825,16 +1791,13 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1825 | (texinfo-check-for-node-name) | 1791 | (texinfo-check-for-node-name) |
| 1826 | (setq next-node-name (texinfo-copy-node-name)) | 1792 | (setq next-node-name (texinfo-copy-node-name)) |
| 1827 | 1793 | ||
| 1828 | (setq menu-list | 1794 | (push (cons next-node-name (prog1 "" (forward-line 1))) |
| 1829 | (cons (cons | 1795 | ;; Use following to insert section titles automatically. |
| 1830 | next-node-name | 1796 | ;; (texinfo-copy-next-section-title) |
| 1831 | (prog1 "" (forward-line 1))) | 1797 | menu-list) |
| 1832 | ;; Use following to insert section titles automatically. | ||
| 1833 | ;; (texinfo-copy-next-section-title) | ||
| 1834 | menu-list)) | ||
| 1835 | 1798 | ||
| 1836 | ;; Go to outer file | 1799 | ;; Go to outer file |
| 1837 | (switch-to-buffer (find-file-noselect (car files))) | 1800 | (set-buffer (find-file-noselect (pop files))) |
| 1838 | (goto-char (point-min)) | 1801 | (goto-char (point-min)) |
| 1839 | (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) | 1802 | (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) |
| 1840 | (error "This buffer needs a Top node")) | 1803 | (error "This buffer needs a Top node")) |
| @@ -1844,7 +1807,6 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1844 | (insert ", " next-node-name ", (dir), (dir)") | 1807 | (insert ", " next-node-name ", (dir), (dir)") |
| 1845 | (beginning-of-line) | 1808 | (beginning-of-line) |
| 1846 | (setq previous-node-name "Top") | 1809 | (setq previous-node-name "Top") |
| 1847 | (setq files (cdr files)) | ||
| 1848 | 1810 | ||
| 1849 | (while files | 1811 | (while files |
| 1850 | 1812 | ||
| @@ -1853,7 +1815,7 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1853 | (setq next-node-name "") | 1815 | (setq next-node-name "") |
| 1854 | ;; Else, | 1816 | ;; Else, |
| 1855 | ;; find the name of the first node in the next file. | 1817 | ;; find the name of the first node in the next file. |
| 1856 | (switch-to-buffer (find-file-noselect (car (cdr files)))) | 1818 | (set-buffer (find-file-noselect (car (cdr files)))) |
| 1857 | (widen) | 1819 | (widen) |
| 1858 | (goto-char (point-min)) | 1820 | (goto-char (point-min)) |
| 1859 | (if (not (re-search-forward "^@node" nil t)) | 1821 | (if (not (re-search-forward "^@node" nil t)) |
| @@ -1861,16 +1823,13 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1861 | (beginning-of-line) | 1823 | (beginning-of-line) |
| 1862 | (texinfo-check-for-node-name) | 1824 | (texinfo-check-for-node-name) |
| 1863 | (setq next-node-name (texinfo-copy-node-name)) | 1825 | (setq next-node-name (texinfo-copy-node-name)) |
| 1864 | (setq menu-list | 1826 | (push (cons next-node-name (prog1 "" (forward-line 1))) |
| 1865 | (cons (cons | 1827 | ;; Use following to insert section titles automatically. |
| 1866 | next-node-name | 1828 | ;; (texinfo-copy-next-section-title) |
| 1867 | (prog1 "" (forward-line 1))) | 1829 | menu-list)) |
| 1868 | ;; Use following to insert section titles automatically. | ||
| 1869 | ;; (texinfo-copy-next-section-title) | ||
| 1870 | menu-list))) | ||
| 1871 | 1830 | ||
| 1872 | ;; Go to node to be updated. | 1831 | ;; Go to node to be updated. |
| 1873 | (switch-to-buffer (find-file-noselect (car files))) | 1832 | (set-buffer (find-file-noselect (car files))) |
| 1874 | (goto-char (point-min)) | 1833 | (goto-char (point-min)) |
| 1875 | (if (not (re-search-forward "^@node" nil t)) | 1834 | (if (not (re-search-forward "^@node" nil t)) |
| 1876 | (error "No `@node' line found in %s" (buffer-name))) | 1835 | (error "No `@node' line found in %s" (buffer-name))) |
| @@ -1882,7 +1841,7 @@ Thus, normally, each included file contains one, and only one, chapter." | |||
| 1882 | (beginning-of-line) | 1841 | (beginning-of-line) |
| 1883 | (texinfo-delete-existing-pointers) | 1842 | (texinfo-delete-existing-pointers) |
| 1884 | (end-of-line) | 1843 | (end-of-line) |
| 1885 | (insert ", " next-node-name ", " previous-node-name ", " up-node-name) | 1844 | (insert ", " next-node-name ", " previous-node-name ", Top") |
| 1886 | 1845 | ||
| 1887 | (beginning-of-line) | 1846 | (beginning-of-line) |
| 1888 | (setq previous-node-name (texinfo-copy-node-name)) | 1847 | (setq previous-node-name (texinfo-copy-node-name)) |
| @@ -1896,12 +1855,12 @@ Indents the first line of the description, if any, to the value of | |||
| 1896 | `texinfo-column-for-description'." | 1855 | `texinfo-column-for-description'." |
| 1897 | 1856 | ||
| 1898 | (insert "@menu\n") | 1857 | (insert "@menu\n") |
| 1899 | (while menu-list | 1858 | (dolist (entry menu-list) |
| 1900 | ;; Every menu entry starts with a star and a space. | 1859 | ;; Every menu entry starts with a star and a space. |
| 1901 | (insert "* ") | 1860 | (insert "* ") |
| 1902 | 1861 | ||
| 1903 | ;; Insert the node name (and menu entry name, if present). | 1862 | ;; Insert the node name (and menu entry name, if present). |
| 1904 | (let ((node-part (car (car menu-list)))) | 1863 | (let ((node-part (car entry))) |
| 1905 | (if (stringp node-part) | 1864 | (if (stringp node-part) |
| 1906 | ;; "Double colon" entry line; menu entry and node name are the same, | 1865 | ;; "Double colon" entry line; menu entry and node name are the same, |
| 1907 | (insert (format "%s::" node-part)) | 1866 | (insert (format "%s::" node-part)) |
| @@ -1909,15 +1868,13 @@ Indents the first line of the description, if any, to the value of | |||
| 1909 | (insert (format "%s: %s." (car node-part) (cdr node-part))))) | 1868 | (insert (format "%s: %s." (car node-part) (cdr node-part))))) |
| 1910 | 1869 | ||
| 1911 | ;; Insert the description, if present. | 1870 | ;; Insert the description, if present. |
| 1912 | (if (cdr (car menu-list)) | 1871 | (when (cdr entry) |
| 1913 | (progn | 1872 | ;; Move to right place. |
| 1914 | ;; Move to right place. | 1873 | (indent-to texinfo-column-for-description 2) |
| 1915 | (indent-to texinfo-column-for-description 2) | 1874 | ;; Insert description. |
| 1916 | ;; Insert description. | 1875 | (insert (format "%s" (cdr entry)))) |
| 1917 | (insert (format "%s" (cdr (car menu-list)))))) | ||
| 1918 | 1876 | ||
| 1919 | (insert "\n") ; end this menu entry | 1877 | (insert "\n")) ; end this menu entry |
| 1920 | (setq menu-list (cdr menu-list))) | ||
| 1921 | (insert "@end menu")) | 1878 | (insert "@end menu")) |
| 1922 | 1879 | ||
| 1923 | (defun texinfo-multi-file-master-menu-list (files-list) | 1880 | (defun texinfo-multi-file-master-menu-list (files-list) |
| @@ -1928,13 +1885,12 @@ The first file in FILES-LIST must be the outer file; the others must | |||
| 1928 | be the files included within it. A main menu must already exist." | 1885 | be the files included within it. A main menu must already exist." |
| 1929 | (save-excursion | 1886 | (save-excursion |
| 1930 | (let (master-menu-list) | 1887 | (let (master-menu-list) |
| 1931 | (while files-list | 1888 | (dolist (file files-list) |
| 1932 | (switch-to-buffer (find-file-noselect (car files-list))) | 1889 | (set-buffer (find-file-noselect file)) |
| 1933 | (message "Working on: %s " (current-buffer)) | 1890 | (message "Working on: %s " (current-buffer)) |
| 1934 | (goto-char (point-min)) | 1891 | (goto-char (point-min)) |
| 1935 | (setq master-menu-list | 1892 | (setq master-menu-list |
| 1936 | (append master-menu-list (texinfo-master-menu-list))) | 1893 | (append master-menu-list (texinfo-master-menu-list)))) |
| 1937 | (setq files-list (cdr files-list))) | ||
| 1938 | master-menu-list))) | 1894 | master-menu-list))) |
| 1939 | 1895 | ||
| 1940 | 1896 | ||
| @@ -1983,76 +1939,69 @@ chapter." | |||
| 1983 | (read-string | 1939 | (read-string |
| 1984 | "Name of outer `include' file: " | 1940 | "Name of outer `include' file: " |
| 1985 | (buffer-file-name)) | 1941 | (buffer-file-name)) |
| 1986 | (cond ((not current-prefix-arg) | 1942 | (cond |
| 1987 | '(nil nil)) | 1943 | ((not current-prefix-arg) '(nil nil)) |
| 1988 | ((listp current-prefix-arg) | 1944 | ((listp current-prefix-arg) '(t nil)) ; make-master-menu |
| 1989 | '(t nil)) ; make-master-menu | 1945 | ((numberp current-prefix-arg) '(t t))))) ; update-everything |
| 1990 | ((numberp current-prefix-arg) | ||
| 1991 | '(t t)) ; update-everything | ||
| 1992 | ))) | ||
| 1993 | 1946 | ||
| 1994 | (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) | 1947 | (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) |
| 1995 | (files included-file-list) | 1948 | (files included-file-list) |
| 1996 | main-menu-list | ||
| 1997 | next-node-name | 1949 | next-node-name |
| 1998 | previous-node-name | 1950 | previous-node-name |
| 1999 | (up-node-name "Top")) | 1951 | ;; Update the pointers and collect the names of the nodes and titles |
| 2000 | 1952 | (main-menu-list (texinfo-multi-file-update files update-everything))) | |
| 2001 | ;;; Update the pointers | ||
| 2002 | ;;; and collect the names of the nodes and titles | ||
| 2003 | (setq main-menu-list (texinfo-multi-file-update files update-everything)) | ||
| 2004 | 1953 | ||
| 2005 | ;;; Insert main menu | 1954 | ;; Insert main menu |
| 2006 | 1955 | ||
| 2007 | ;; Go to outer file | 1956 | ;; Go to outer file |
| 2008 | (switch-to-buffer (find-file-noselect (car included-file-list))) | 1957 | (set-buffer (find-file-noselect (car included-file-list))) |
| 2009 | (if (texinfo-old-menu-p | 1958 | (if (texinfo-old-menu-p |
| 2010 | (point-min) | 1959 | (point-min) |
| 2011 | (save-excursion | 1960 | (save-excursion |
| 2012 | (re-search-forward "^@include") | 1961 | (re-search-forward "^@include") |
| 2013 | (beginning-of-line) | 1962 | (beginning-of-line) |
| 2014 | (point))) | 1963 | (point))) |
| 2015 | 1964 | ||
| 2016 | ;; If found, leave point after word `menu' on the `@menu' line. | 1965 | ;; If found, leave point after word `menu' on the `@menu' line. |
| 2017 | (progn | 1966 | (progn |
| 2018 | (texinfo-incorporate-descriptions main-menu-list) | 1967 | (texinfo-incorporate-descriptions main-menu-list) |
| 2019 | ;; Delete existing menu. | 1968 | ;; Delete existing menu. |
| 2020 | (beginning-of-line) | 1969 | (beginning-of-line) |
| 2021 | (delete-region | 1970 | (delete-region |
| 2022 | (point) | 1971 | (point) |
| 2023 | (save-excursion (re-search-forward "^@end menu") (point))) | 1972 | (save-excursion (re-search-forward "^@end menu") (point))) |
| 2024 | ;; Insert main menu | 1973 | ;; Insert main menu |
| 2025 | (texinfo-multi-files-insert-main-menu main-menu-list)) | 1974 | (texinfo-multi-files-insert-main-menu main-menu-list)) |
| 2026 | 1975 | ||
| 2027 | ;; Else no current menu; insert it before `@include' | 1976 | ;; Else no current menu; insert it before `@include' |
| 2028 | (texinfo-multi-files-insert-main-menu main-menu-list)) | 1977 | (texinfo-multi-files-insert-main-menu main-menu-list)) |
| 2029 | 1978 | ||
| 2030 | ;;; Insert master menu | 1979 | ;; Insert master menu |
| 2031 | 1980 | ||
| 2032 | (if make-master-menu | 1981 | (if make-master-menu |
| 2033 | (progn | 1982 | (progn |
| 2034 | ;; First, removing detailed part of any pre-existing master menu | 1983 | ;; First, removing detailed part of any pre-existing master menu |
| 2035 | (goto-char (point-min)) | 1984 | (goto-char (point-min)) |
| 2036 | (if (search-forward texinfo-master-menu-header nil t) | 1985 | (if (search-forward texinfo-master-menu-header nil t) |
| 2037 | (progn | 1986 | (progn |
| 2038 | (goto-char (match-beginning 0)) | 1987 | (goto-char (match-beginning 0)) |
| 2039 | ;; Check if @detailmenu kludge is used; | 1988 | ;; Check if @detailmenu kludge is used; |
| 2040 | ;; if so, leave point before @detailmenu. | 1989 | ;; if so, leave point before @detailmenu. |
| 2041 | (search-backward "\n@detailmenu" | 1990 | (search-backward "\n@detailmenu" |
| 2042 | (save-excursion (forward-line -3) (point)) | 1991 | (save-excursion (forward-line -3) (point)) |
| 2043 | t) | 1992 | t) |
| 2044 | ;; Remove detailed master menu listing | 1993 | ;; Remove detailed master menu listing |
| 2045 | (let ((end-of-detailed-menu-descriptions | 1994 | (let ((end-of-detailed-menu-descriptions |
| 2046 | (save-excursion ; beginning of end menu line | 1995 | (save-excursion ; beginning of end menu line |
| 2047 | (goto-char (texinfo-menu-end)) | 1996 | (goto-char (texinfo-menu-end)) |
| 2048 | (beginning-of-line) (forward-char -1) | 1997 | (beginning-of-line) (forward-char -1) |
| 2049 | (point)))) | 1998 | (point)))) |
| 2050 | (delete-region (point) end-of-detailed-menu-descriptions)))) | 1999 | (delete-region (point) end-of-detailed-menu-descriptions)))) |
| 2051 | 2000 | ||
| 2052 | ;; Create a master menu and insert it | 2001 | ;; Create a master menu and insert it |
| 2053 | (texinfo-insert-master-menu-list | 2002 | (texinfo-insert-master-menu-list |
| 2054 | (texinfo-multi-file-master-menu-list | 2003 | (texinfo-multi-file-master-menu-list |
| 2055 | included-file-list))))) | 2004 | included-file-list))))) |
| 2056 | 2005 | ||
| 2057 | ;; Remove unwanted extra lines. | 2006 | ;; Remove unwanted extra lines. |
| 2058 | (save-excursion | 2007 | (save-excursion |
| @@ -2060,18 +2009,18 @@ chapter." | |||
| 2060 | 2009 | ||
| 2061 | (re-search-forward "^@menu") | 2010 | (re-search-forward "^@menu") |
| 2062 | (forward-line -1) | 2011 | (forward-line -1) |
| 2063 | (insert "\n") ; Ensure at least one blank line. | 2012 | (insert "\n") ; Ensure at least one blank line. |
| 2064 | (delete-blank-lines) | 2013 | (delete-blank-lines) |
| 2065 | 2014 | ||
| 2066 | (re-search-forward "^@end menu") | 2015 | (re-search-forward "^@end menu") |
| 2067 | (forward-line 1) | 2016 | (forward-line 1) |
| 2068 | (insert "\n") ; Ensure at least one blank line. | 2017 | (insert "\n") ; Ensure at least one blank line. |
| 2069 | (delete-blank-lines)) | 2018 | (delete-blank-lines)) |
| 2070 | 2019 | ||
| 2071 | (message "Multiple files updated.")) | 2020 | (message "Multiple files updated.")) |
| 2072 | 2021 | ||
| 2073 | 2022 | ||
| 2074 | ;;; Place `provide' at end of file. | 2023 | ;; Place `provide' at end of file. |
| 2075 | (provide 'texnfo-upd) | 2024 | (provide 'texnfo-upd) |
| 2076 | 2025 | ||
| 2077 | ;;; texnfo-upd.el ends here | 2026 | ;;; texnfo-upd.el ends here |