X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=sinfo.el;h=e78dfbdae48e022529f9eb8ff07cf85ede683b6f;hb=1588cb795c5e849ad3a46994d12e57d54c4c0fca;hp=32fe92aa1fe61118ef2277b14f5ca3d1ea0677c3;hpb=689eb17b68eff91e0049ab3711f0411b6aba3905;p=elisp%2Fsinfo.git diff --git a/sinfo.el b/sinfo.el index 32fe92a..e78dfbd 100644 --- a/sinfo.el +++ b/sinfo.el @@ -1,9 +1,8 @@ ;;; sinfo.el --- sinfo to Texinfo converter -;; Copyright (C) 1996,1997 MORIOKA Tomohiko +;; Copyright (C) 1996,1997,1998 MORIOKA Tomohiko ;; Author: MORIOKA Tomohiko -;; Version: $Id: sinfo.el,v 3.7 1997/01/31 13:46:10 morioka Exp $ ;; Keywords: SGML, Texinfo ;; This file is part of sinfo (SGML based info system). @@ -30,15 +29,23 @@ ;;; Code: -(require 'tl-list) -(require 'tl-str) (require 'texinfmt) (require 'texi-util) +(require 'emu) + +(defun-maybe file-name-non-extension (filename) + (if (string-match "\\.[^.]+$" filename) + (substring filename 0 (match-beginning 0)) + filename)) (defvar sinfo-texi-mapping-file "/usr/local/share/sgml/rep/sinfo/texi-mapping" "*SGML mapping file to convert into Texinfo.") +(defvar sinfo-html-mapping-file + "/usr/local/share/sgml/rep/sinfo/html-mapping" + "*SGML mapping file to convert into HTML.") + (defun sinfo-texi-swap-node () (interactive) (goto-char (point-min)) @@ -48,7 +55,7 @@ (let* ((md (match-data)) (nd (last md 2)) (nb (car nd)) - (ne (second nd)) + (ne (cadr nd)) ) (replace-match (format "%s\n%s" (buffer-substring nb ne) @@ -123,9 +130,12 @@ (replace-match (concat "@" (buffer-substring (match-beginning 0) (match-end 0)))) ) - (let ((coding-system-for-read 'internal) - (coding-system-for-write 'internal) - ) + (let ((sinfo-path (getenv "SINFO_PATH")) + (coding-system-for-read 'emacs-mule) + (coding-system-for-write 'emacs-mule)) + (setenv "SGML_PATH" + (format "%s/dtd/%%N.dtd:%s/dtd/%%P.dtd:%s/rep/texi/%%N" + sinfo-path sinfo-path sinfo-path)) (setq status (call-process-region (point-min)(point-max) "sh" t t t @@ -161,7 +171,9 @@ (goto-char (point-min)) (and (re-search-forward "@setfilename$" nil t) (replace-match - (format "@setfilename %s" fname) + (format + "@c Generated automatically from %s by sinfo 3.7. +@setfilename %s" (file-name-nondirectory src-name) fname) )) (and (re-search-forward "@settitle{}" nil t) (replace-match @@ -286,6 +298,81 @@ (goto-char (point-min)) ))) +(defun sinfo-to-html () + (interactive) + (let* ((the-buf (current-buffer)) + (src-name (buffer-file-name)) + (name (file-name-non-extension src-name)) + (dst-name (concat name ".html")) + (cs buffer-file-coding-system) + status) + (find-file dst-name) + (erase-buffer) + (insert-buffer the-buf) + (let ((sinfo-path (getenv "SINFO_PATH")) + (coding-system-for-read 'emacs-mule) + (coding-system-for-write 'emacs-mule)) + (setenv "SGML_PATH" + (format "%s/dtd/%%N.dtd:%s/dtd/%%P.dtd:%s/rep/html/%%N" + sinfo-path sinfo-path sinfo-path)) + (setq status + (call-process-region (point-min)(point-max) + "sh" t t t + "-c" + (format "sgmls|sgmlsasp %s" + (expand-file-name + sinfo-html-mapping-file) + ) + ) + ) + ) + (goto-char (point-min)) + (if (and (search-forward "sgmls:" nil t) + (re-search-forward "line \\([0-9]+\\)" nil t) + ) + (let ((line (string-to-number + (buffer-substring (match-beginning 1) + (match-end 1))) + )) + (progn + (pop-to-buffer the-buf) + (goto-line line) + )) + (set-buffer-file-coding-system cs) + (goto-char (point-min)) + ) + (goto-char (point-min)) + (if (re-search-forward "" nil t) + (let ((p0 (match-end 0))) + (if (re-search-forward "" nil t) + (let ((title (buffer-substring p0 (match-beginning 0)))) + (when (re-search-forward "" nil t) + (insert "\n

") + (insert title) + (insert "

") + ))))) + (goto-char (point-min)) + (while (re-search-forward + "\\([^<]+\\)\\(\\)" + nil t) + (let* ((p0 (match-beginning 0)) + (p1 (match-beginning 1)) + (p2 (match-end 1)) + (p3 (match-end 2)) + (p4 (match-end 0)) + (h (buffer-substring (1+ (match-beginning 0)) p1)) + (desc (buffer-substring p1 p2))) + (goto-char p4) + (insert (concat "\n") + )) + (goto-char (point-min)) + )) + ;;; @ end ;;;