[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: INFO on add-ons

From: Robert J. Chassell
Subject: Re: INFO on add-ons
Date: Wed, 4 Sep 2002 17:12:53 +0000 (UTC)

"Stefan Monnier" <monnier+gnu/address@hidden> wrote:

    If you say WYSIWYG, you know that it is very difficult to
    reconcile with the purpose of TeXinfo which is to concentrate on
    the intent and allow many *different* output formats.

Yes.  One way to think about this is that the Texinfo source provides
the `deep structure' of a document, while the various output formats
provide `surface representations'.

A while back, I wrote a little package, very brittle, that
showed three of the output formats you could produce from a Texinfo
file that you are working on:  Info in GNU Emacs, HTML in a Web
browser, and DVI in an xdvi window.  

I ended up not caring for it; I am happy enough copying the necessary
shell commands to a xterm and generating the output that way.  But it
is an interesting idea.

Here is the code, if anyone wants to try it or improve on it.  As I
said this is brittle and has a hard time with errors.  Your Texinfo
source must format without reported error.

;;;; texinfo-split-screen.el
;;;; 2002 Jun  5
;;;; Robert J. Chassell, address@hidden
;;;; low alpha quality at the moment.

;;;; Does NOT report errors well..... :-(

;; To use this, start GNU Emacs with two frames.  Load this file.
;; Find the Texinfo file on which you are working in one frame.
;; Invoke `M-x texinfo-split-screen' on that Texinfo file.

;; The dvi file and the Web browser file will appear, but at the
;; beginning of the document.  The Info file will appear in the other
;; window at the beginning of the node where you are located in the
;; Texinfo file.

;; At the moment, we need the 

;;       (sit-for 1)
;;       (message "current-nodename --> %s and info-place --> %s"
;;                current-nodename info-place)
;;       (sleep-for 3)

;; so that the `makeinfo --no-split --paragraph-indent=0 --verbose'
;; process has an opportunity to complete before Info is run on the
;; resulting .info file.  This should be changed so that Info is run
;; only after the `makeinfo' process completes.

;; The trouble with the following `add-hook' is that it runs
;; `texinfo-split-screen' after *every* save, not just after 
;; saves for the Texinfo file.... :-)       So it is no good.
;; (add-hook 'after-save-hook 'texinfo-split-screen)

(defun texinfo-split-screen ()
  "Update Info, HTML, and DVI outputs of current Texinfo buffer."
  (let ((split-screen-current-buffer (buffer-name)))

    (set-buffer split-screen-current-buffer)
    (let ((current-process-list (process-list)))
      (while current-process-list
        (if (equal "texi2dvi"
                   (substring (process-name (car current-process-list)) 0 8))
            (kill-process (car current-process-list)))
        (setq current-process-list (cdr current-process-list))))

    ;; remove following files first:
    ;;     *.dvi *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr 

    (apply 'start-process
           ;; NAME for the process
           (concat "rm "
                   (file-name-sans-extension (buffer-file-name)) 
                   ".toc" " "
                   (file-name-sans-extension (buffer-file-name)) ".aux")
           nil                          ; BUFFER
           "rm"                         ; PROGRAM
           ;; ARGs to PROGRAM
            (concat (file-name-sans-extension (buffer-file-name)) ".toc")
            (concat (file-name-sans-extension (buffer-file-name)) ".aux"))

    (apply 'start-process
           (concat "texi2dvi " (buffer-file-name)) ; NAME for the process
           nil                          ; BUFFER
           "texi2dvi"                   ; PROGRAM
           (list (buffer-file-name))    ; ARGs to PROGRAM

     (concat (file-name-sans-extension (buffer-file-name)) ".dvi"))

    (set-buffer split-screen-current-buffer)
    (apply 'start-process
           ;; NAME for the process
           (concat "makeinfo --html --no-split --verbose " (buffer-file-name))
           nil                          ; BUFFER
           "makeinfo"                   ; PROGRAM
           ;; ARGs to PROGRAM
           (list "--html" "--no-split" "--verbose" (buffer-file-name)) 

    (let ((current-process-list (process-list)))
      (while current-process-list
        (if (equal "galeon"
                   (substring (process-name (car (process-list))) 0 6))
            (kill-process (car current-process-list)))
        (setq current-process-list (cdr current-process-list))))

    (let ((browse-url-new-window-flag -1))
       (concat (file-name-sans-extension (buffer-file-name)) ".html")))

    (sit-for 1)

    (set-buffer split-screen-current-buffer)
    (let ((info-file-creation-process
           (apply 'start-process
                  (concat               ; NAME for the process
                   "makeinfo --no-split --paragraph-indent=0 --verbose "
                  nil                   ; BUFFER
                  "makeinfo"            ; PROGRAM
                  (list                 ; ARGs to PROGRAM
                   "--no-split" "--paragraph-indent=0" "--verbose"
      (setq info-file-creation-process-name
            (process-name info-file-creation-process)))

    (message "sit-for 5")
    (sit-for 5)

    (if (eq (process-status info-file-creation-process-name) nil)
        ;; start Info reader
          (or (functionp 'texinfo-copy-node-name)
              (require 'texnfo-upd))
          (let* ((current-location (point))
                  (if (re-search-backward "address@hidden" (point-min) t)
                      (texinfo-copy-node-name) "Top"))
                    (goto-char (point-min))
                    (search-forward "@setfilename ")
                      (point) (save-excursion (end-of-line) (point))))))
                  (concat "(" current-filename ")" current-nodename)))
            (goto-char current-location)
            (sit-for 1)
            (message "current-nodename --> %s and info-place --> %s"
                     current-nodename info-place)
            (sleep-for 3)
            (texinfo-split-screen-info info-place))

(defun texinfo-split-screen-view-xdvi (xdvifile)
  "Ask  xdvi to view a .dvi file."
  (interactive "fxdvi file: ")
  ;;  -sourceposition  line[:col][ ]filename
  (defvar xdvi-process-name "xdvi-process-holder")

  (if (eq (process-status xdvi-process-name) nil)
      ;; start xdvi
      (let ((process
             (apply 'start-process
                    (concat "xdvi " xdvifile) ; NAME for the process
                    nil                 ; BUFFER
                    "xdvi"              ; PROGRAM
                    (list xdvifile)     ; ARGs to PROGRAM
        (setq xdvi-process-name (process-name process)))
    ;; else
    (continue-process xdvi-process-name)))

(defun texinfo-split-screen-view-HTML (htmlfile)
  "Ask Galeon to view an HTML file."
  (interactive "fHTML file: ")
  (defvar galeon-process-name "galeon-process-holder")

  (if (eq (process-status galeon-process-name) nil)
      ;; start galeon
      (let ((process
             (apply 'start-process
                    (concat "galeon " htmlfile) ; NAME for the process
                    nil                 ; BUFFER
                    "galeon"              ; PROGRAM
                    (list htmlfile)     ; ARGs to PROGRAM
        (setq galeon-process-name (process-name process)))
    ;; else
    (continue-process galeon-process-name)))

(defun texinfo-split-screen-info (file)
  "For texinfo-split-screen, enter Info in another window."
  (if (buffer-live-p (get-buffer "*info*"))
      (kill-buffer (get-buffer "*info*")))
;;  (message " sleep 2 then go to other frame")
;;  (sleep-for 2)
  (other-frame 1)
  (get-buffer "*info*")
  (switch-to-buffer "*info*")
  (Info-goto-node file))

;;;;;;;;;;;;;;;; end texinfo-split-screen.el ;;;;;;;;;;;;;;;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]