File: ept-dump.el

package info (click to toggle)
elpoint 0.2.0-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,820 kB
  • ctags: 121
  • sloc: lisp: 910; makefile: 66; sh: 34
file content (102 lines) | stat: -rw-r--r-- 3,036 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
;;; ept-dump.el --- Dump utils for elpoint presentation.

;; Copyright (C) 2002 Yuuichi Teranishi <teranisi@gohome.org>

;; Author: Yuuichi Teranishi <teranisi@gohome.org>
;; Keywords: Presentation

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;

;;; Commentary:
;; 

;;; History:
;; 

;;; Code:

(eval-when-compile
  (require 'cl))

(defcustom ept-dump-page-size "320x240"
  "Argument for convert's geometry."
  :type 'string
  :group 'ept)

(defvar ept-xwd-program "xwd")
(defvar ept-dump-directory "~")

(defun ept-xwd-dump-page ()
  (apply 'call-process ept-xwd-program nil nil nil
	 (list "-root" "-out"
	       (expand-file-name
		(format "ept%d.xwd" (symbol-value 'ept-current-position))
		ept-dump-directory))))

(defun ept-imagick-convert-dumped-page (number)
  (apply 'call-process (symbol-value 'ept-imagick-convert-program) nil nil nil
	 (list "-geometry" ept-dump-page-size
	       (expand-file-name
		(format "ept%d.xwd" number)
		ept-dump-directory)
	       (expand-file-name
		(format "ept%d.png" number)
		ept-dump-directory))))

(defun ept-dump-page ()
  (ept-xwd-dump-page))

(defun ept-dump-convert ()
  (interactive)
  (let ((number 0))
    (while (< number (length (symbol-value 'ept-current-presentation)))
      (message "Converting...%d" number)
      (ept-imagick-convert-dumped-page number)
      (incf number))))

(defun ept-make-dump-page ()
  (interactive)
  (let ((p 0) file)
    (with-temp-buffer
      (insert "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
<html>
  <head>
    <title>Presentation dump by Elpoint</title>
    <LINK REV=\"MADE\" HREF=\"mailto:" user-mail-address
    "\">
    <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; CHARSET=iso-2022-jp\">
  </head>
 <body BGCOLOR=\"#D9FFD9\">
 <table>")
      (dotimes (i (length (symbol-value 'ept-current-presentation)))
	(setq file (format "ept%d.png" i))
	(when (file-exists-p (expand-file-name file ept-dump-directory))
	  (insert (format
		   (if (zerop (% p 2))
		       "<tr><td><img src=\"%s\"></td>"
		     "<td><img src=\"%s\"></td></tr>\n")
		   file)))
	(incf p))
      (insert " </table></body>\n<hr>\n\
Dump created by <i>Elpoint -- Yet Another Presentation Tool for Emacsen</i>.
</html>")
      (write-region (point-min) (point-max)
		    (expand-file-name "index.html" ept-dump-directory)))))

(provide 'ept-dump)

;;; ept-dump.el ends here