diff options
| author | Richard M. Stallman | 1997-01-02 20:49:15 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-01-02 20:49:15 +0000 |
| commit | 24e519d8c96f05645795a4521c0b451332bb35ff (patch) | |
| tree | cb1cf34e9b242d7da8b60b91399ff76b5d23322e | |
| parent | e8dd2298ce335ae59f2852790b60b7393378e741 (diff) | |
| download | emacs-24e519d8c96f05645795a4521c0b451332bb35ff.tar.gz emacs-24e519d8c96f05645795a4521c0b451332bb35ff.zip | |
(texinfo-mode): Locally set tex-first-line-header-regexp.
Locally set tex-trailer.
(texinfo-mode): Use regexps for
tex-start-of-header and tex-end-of-header.
(texinfo-tex-region, texinfo-tex-buffer): Use tex-region and tex-buffer.
(texinfo-tex-print): Use tex-print.
(texinfo-tex-view): New command, on C-x C-t C-v.
| -rw-r--r-- | lisp/textmodes/texinfo.el | 107 |
1 files changed, 20 insertions, 87 deletions
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index c7ec7af5b3b..ea16b03a4ae 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el | |||
| @@ -271,6 +271,7 @@ chapter." | |||
| 271 | (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue) | 271 | (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue) |
| 272 | (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue) | 272 | (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue) |
| 273 | (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) | 273 | (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) |
| 274 | (define-key keymap "\C-c\C-t\C-v" 'texinfo-tex-view) | ||
| 274 | (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) | 275 | (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) |
| 275 | 276 | ||
| 276 | (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) | 277 | (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) |
| @@ -443,9 +444,13 @@ value of texinfo-mode-hook." | |||
| 443 | (make-local-variable 'outline-level) | 444 | (make-local-variable 'outline-level) |
| 444 | (setq outline-level 'texinfo-outline-level) | 445 | (setq outline-level 'texinfo-outline-level) |
| 445 | (make-local-variable 'tex-start-of-header) | 446 | (make-local-variable 'tex-start-of-header) |
| 446 | (setq tex-start-of-header "%**start") | 447 | (setq tex-start-of-header "%\\*\\*start") |
| 447 | (make-local-variable 'tex-end-of-header) | 448 | (make-local-variable 'tex-end-of-header) |
| 448 | (setq tex-end-of-header "%**end") | 449 | (setq tex-end-of-header "%\\*\\*end") |
| 450 | (make-local-variable 'tex-first-line-header-regexp) | ||
| 451 | (setq tex-first-line-header-regexp "^\\\\input") | ||
| 452 | (make-local-variable 'tex-trailer) | ||
| 453 | (setq tex-trailer "@bye\n") | ||
| 449 | (run-hooks 'text-mode-hook 'texinfo-mode-hook)) | 454 | (run-hooks 'text-mode-hook 'texinfo-mode-hook)) |
| 450 | 455 | ||
| 451 | 456 | ||
| @@ -689,94 +694,16 @@ inclusive. The header must start in the first 100 lines. | |||
| 689 | The value of `texinfo-tex-trailer' is appended to the temporary file after the region." | 694 | The value of `texinfo-tex-trailer' is appended to the temporary file after the region." |
| 690 | (interactive "r") | 695 | (interactive "r") |
| 691 | (require 'tex-mode) | 696 | (require 'tex-mode) |
| 692 | (if (get-buffer "*tex-shell*") | 697 | (let ((tex-command texinfo-tex-command) |
| 693 | (tex-kill-job) | 698 | (tex-trailer "@bye\n")) |
| 694 | (tex-start-shell)) | 699 | (tex-region beg end))) |
| 695 | (or tex-zap-file (setq tex-zap-file (make-temp-name "#tz"))) | ||
| 696 | (let ((tex-out-file (concat tex-zap-file ".tex")) | ||
| 697 | (temp-buffer (get-buffer-create " tex-Output-Buffer")) | ||
| 698 | (zap-directory | ||
| 699 | (file-name-as-directory (expand-file-name tex-directory)))) | ||
| 700 | (save-excursion | ||
| 701 | (save-restriction | ||
| 702 | (widen) | ||
| 703 | (goto-char (point-min)) | ||
| 704 | (forward-line 100) | ||
| 705 | (let ((search-end (point)) | ||
| 706 | (hbeg (point-min)) (hend (point-min)) | ||
| 707 | (default-directory zap-directory)) | ||
| 708 | (goto-char (point-min)) | ||
| 709 | |||
| 710 | ;; Copy first line, the `\input texinfo' line, to temp file | ||
| 711 | (write-region (point) | ||
| 712 | (save-excursion (end-of-line) (point)) | ||
| 713 | tex-out-file nil nil) | ||
| 714 | |||
| 715 | ;; Don't copy first line twice if region includes it. | ||
| 716 | (forward-line 1) | ||
| 717 | (if (< beg (point)) (setq beg (point))) | ||
| 718 | |||
| 719 | ;; Initialize the temp file with either the header or nothing | ||
| 720 | (if (search-forward tex-start-of-header search-end t) | ||
| 721 | (progn | ||
| 722 | (beginning-of-line) | ||
| 723 | (setq hbeg (point)) ; Mark beginning of header. | ||
| 724 | (if (search-forward tex-end-of-header nil t) | ||
| 725 | (progn (beginning-of-line) | ||
| 726 | (setq hend (point))) ; Mark end of header. | ||
| 727 | (setq hbeg (point-min))))) ; Else no header. | ||
| 728 | |||
| 729 | ;; Copy header to temp file. | ||
| 730 | (write-region (min hbeg beg) hend tex-out-file t nil) | ||
| 731 | |||
| 732 | ;; Copy region to temp file. | ||
| 733 | (write-region (max beg hend) end tex-out-file t nil)) | ||
| 734 | |||
| 735 | ;; This is a kludge to insert the tex-trailer into the tex-out-file. | ||
| 736 | ;; We have to create a special buffer in which to insert | ||
| 737 | ;; the tex-trailer first because there is no function with | ||
| 738 | ;; which to append a literal string directly to a file. | ||
| 739 | (let ((local-tex-trailer texinfo-tex-trailer)) | ||
| 740 | (set-buffer temp-buffer) | ||
| 741 | (erase-buffer) | ||
| 742 | ;; make sure trailer isn't hidden by a comment | ||
| 743 | (insert-string "\n") | ||
| 744 | (if local-tex-trailer (insert-string local-tex-trailer)) | ||
| 745 | (tex-set-buffer-directory temp-buffer zap-directory) | ||
| 746 | (write-region (point-min) (point-max) tex-out-file t nil)) | ||
| 747 | |||
| 748 | ;;; The following is sufficient in Emacs 19. | ||
| 749 | ;;; (write-region (concat "\n" texinfo-tex-trailer) nil | ||
| 750 | ;;; tex-out-file t nil) | ||
| 751 | )) | ||
| 752 | |||
| 753 | (tex-set-buffer-directory "*tex-shell*" zap-directory) | ||
| 754 | (tex-send-command tex-shell-cd-command zap-directory) | ||
| 755 | (tex-send-command texinfo-tex-command tex-out-file)) | ||
| 756 | (tex-recenter-output-buffer 0)) | ||
| 757 | 700 | ||
| 758 | (defun texinfo-tex-buffer () | 701 | (defun texinfo-tex-buffer () |
| 759 | "Run TeX on visited file, once or twice, to make a correct `.dvi' file." | 702 | "Run TeX on visited file, once or twice, to make a correct `.dvi' file." |
| 760 | (interactive) | 703 | (interactive) |
| 761 | |||
| 762 | ;; Make sure TeX shell is running. | ||
| 763 | (require 'tex-mode) | 704 | (require 'tex-mode) |
| 764 | (if (get-buffer "*tex-shell*") | 705 | (let ((tex-command texinfo-texi2dvi-command)) |
| 765 | (quit-process (get-process "tex-shell") t) | 706 | (tex-buffer))) |
| 766 | (tex-start-shell)) | ||
| 767 | |||
| 768 | (cond ((null buffer-file-name) | ||
| 769 | (error "Buffer not visiting any file!")) | ||
| 770 | ((buffer-modified-p) | ||
| 771 | (error "Buffer has been modified since last saved!"))) | ||
| 772 | |||
| 773 | (setq tex-zap-file buffer-file-name) | ||
| 774 | |||
| 775 | (tex-send-command tex-shell-cd-command (file-name-directory tex-zap-file)) | ||
| 776 | |||
| 777 | (tex-send-command texinfo-texi2dvi-command tex-zap-file) | ||
| 778 | |||
| 779 | (tex-recenter-output-buffer 0)) | ||
| 780 | 707 | ||
| 781 | (defun texinfo-texindex () | 708 | (defun texinfo-texindex () |
| 782 | "Run `texindex' on unsorted index files. | 709 | "Run `texindex' on unsorted index files. |
| @@ -792,8 +719,14 @@ This runs the shell command defined by `texinfo-texindex-command'." | |||
| 792 | This runs the shell command defined by `tex-dvi-print-command'." | 719 | This runs the shell command defined by `tex-dvi-print-command'." |
| 793 | (interactive) | 720 | (interactive) |
| 794 | (require 'tex-mode) | 721 | (require 'tex-mode) |
| 795 | (tex-send-command tex-dvi-print-command (concat tex-zap-file ".dvi")) | 722 | (tex-print)) |
| 796 | (tex-recenter-output-buffer nil)) | 723 | |
| 724 | (defun texinfo-tex-view () | ||
| 725 | "View `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. | ||
| 726 | This runs the shell command defined by `tex-dvi-view-command'." | ||
| 727 | (interactive) | ||
| 728 | (require 'tex-mode) | ||
| 729 | (tex-view)) | ||
| 797 | 730 | ||
| 798 | (defun texinfo-quit-job () | 731 | (defun texinfo-quit-job () |
| 799 | "Quit currently running TeX job, by sending an `x' to it." | 732 | "Quit currently running TeX job, by sending an `x' to it." |