home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / xp / html-to-pc.el < prev    next >
Encoding:
Text File  |  1998-04-08  |  3.0 KB  |  97 lines

  1. ;;; -*- Mode: Emacs-Lisp -*-
  2. ;;;
  3. ;;; The contents of this file are subject to the Netscape Public License
  4. ;;; Version 1.0 (the "NPL"); you may not use this file except in
  5. ;;; compliance with the NPL.  You may obtain a copy of the NPL at
  6. ;;; http://www.mozilla.org/NPL/
  7. ;;;
  8. ;;; Software distributed under the NPL is distributed on an "AS IS" basis,
  9. ;;; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10. ;;; for the specific language governing rights and limitations under the
  11. ;;; NPL.
  12. ;;;
  13. ;;; The Initial Developer of this code under the NPL is Netscape
  14. ;;; Communications Corporation.  Portions created by Netscape are
  15. ;;; Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16. ;;; Reserved.
  17. ;;;  
  18.  
  19. (defun html-to-pc (name input output)
  20.   (save-excursion
  21.     (set-buffer (let ((font-lock-mode nil))
  22.           (find-file-noselect output)))
  23.     (fundamental-mode)
  24.     (erase-buffer)
  25.     (insert-file-contents input)
  26.     (goto-char (point-min))
  27.     (while (search-forward "x_cbug" nil t)
  28.       (goto-char (match-beginning 0))
  29.       (delete-char 1)
  30.       (insert "win"))
  31.     (goto-char (point-min))
  32.  
  33.     ;; refill the paragraphs for small PC screens...
  34.     (if (equal name "LICENSE")
  35.     (let ((fill-column 67))
  36.       (save-restriction
  37.         (goto-char (point-max))
  38.         (forward-paragraph -1) ; skip last one
  39.         (narrow-to-region (point-min) (point))
  40.         (goto-char (point-min))
  41.         (while (not (eobp))
  42.           (fill-paragraph nil)
  43.           (forward-paragraph 1)))))
  44.  
  45.     (goto-char (point-min))
  46.     (let ((line 0)
  47.       (char 0))
  48.       (while (not (eobp))
  49.     (cond ((= char 0)
  50.            (if (= line 0)
  51.            (insert "STRINGTABLE DISCARDABLE\nBEGIN\n")
  52.           ;else
  53.            (insert "\"\n"))
  54.            (insert (upcase (format "IDS_%s_%x\t\"!" name line)))
  55.            (setq line (1+ line))))
  56.     (cond ((= (following-char) ?\")
  57.            (setq char (1+ char))
  58.            (insert "\"")
  59.            (forward-char 1))
  60.           ((= (following-char) ?\n)
  61.            (delete-char 1)
  62.  
  63.            (insert "\\r\\n")
  64.  
  65. ;           (cond ((= (following-char) ?\n)
  66. ;              (delete-char 1)
  67. ;              (insert "\\r\\n\\r\\n"))
  68. ;             (t
  69. ;              (insert " ")))
  70.            )
  71.           (t
  72.            (forward-char 1)))
  73.     (setq char (1+ char))
  74.     (if (> char 190)
  75.         (setq char 0))))
  76.     (insert "\"\nEND\n")
  77.     (forward-line -2)
  78.     (search-forward "\"" nil t)
  79.     (delete-char 1)
  80.     (save-buffer)
  81.     ))
  82.  
  83. (defun batch-html-to-pc ()
  84.   (defvar command-line-args-left)    ;Avoid 'free variable' warning
  85.   (if (not noninteractive)
  86.       (error "batch-html-to-pc is to be used only with -batch"))
  87.   (let ((name (nth 0 command-line-args-left))
  88.     (in  (expand-file-name (nth 1 command-line-args-left)))
  89.     (out (expand-file-name (nth 2 command-line-args-left)))
  90.     (version-control 'never))
  91.     (or (and in out)
  92.     (error
  93.      "usage: emacs -batch -f batch-html-to-pc input-file output-file"))
  94.     (setq command-line-args-left (cdr (cdr command-line-args-left)))
  95.     (let ((auto-mode-alist nil))
  96.       (html-to-pc name in out))))
  97.