Mercurial > emacs
comparison lisp/textmodes/texinfo.el @ 16814:fdda5e6e6fe8
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 02 Jan 1997 20:49:15 +0000 |
parents | fb0dfd81302a |
children | ae0ba78d6c07 |
comparison
equal
deleted
inserted
replaced
16813:56bf42e4fb29 | 16814:fdda5e6e6fe8 |
---|---|
269 (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job) | 269 (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job) |
270 (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer) | 270 (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer) |
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) |
277 (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) | 278 (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) |
278 | 279 |
441 (mapconcat 'car texinfo-section-list "\\>\\|") | 442 (mapconcat 'car texinfo-section-list "\\>\\|") |
442 "\\>\\)")) | 443 "\\>\\)")) |
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 |
452 ;;; Insert string commands | 457 ;;; Insert string commands |
453 | 458 |
687 inclusive. The header must start in the first 100 lines. | 692 inclusive. The header must start in the first 100 lines. |
688 | 693 |
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. |
783 The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. | 710 The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. |
784 This runs the shell command defined by `texinfo-texindex-command'." | 711 This runs the shell command defined by `texinfo-texindex-command'." |
790 (defun texinfo-tex-print () | 717 (defun texinfo-tex-print () |
791 "Print `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. | 718 "Print `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. |
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." |
800 (interactive) | 733 (interactive) |
801 (if (not (get-process "tex-shell")) | 734 (if (not (get-process "tex-shell")) |