From: morioka Date: Tue, 15 Sep 1998 01:17:01 +0000 (+0000) Subject: Don't require `tl-list' and `tl-str'. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=00530ba8dcedbcd035f730344892d74167692715;p=elisp%2Fsinfo.git Don't require `tl-list' and `tl-str'. (sinfo-texi-swap-node): Use `cadr' instead of `second'. (sinfo-to-texi): Refer environment variable `SINFO_PATH'; set `SGML_PATH'. (sinfo-to-html): New function. --- diff --git a/sinfo.el b/sinfo.el index 32fe92a..4695897 100644 --- a/sinfo.el +++ b/sinfo.el @@ -30,15 +30,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 +56,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 +131,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 @@ -286,6 +297,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 ;;;