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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
;;; ept-outline.el -- outline processor for Elpoint.
;; 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:
(require 'ept)
(require 'outline)
(defcustom ept-outline-process-item-alist
'(((string-match "^ *<\\([^>]+\\)> *$" string)
.
(list 'ept-align-center
(list 'ept-inline
(substring string (match-beginning 1)
(match-end 1)))
(list 'ept-text "\n")))
((string-match "^ *(" string)
.
(read string)))
"An alist of process outline item string.
Each cons cell is a form like:
\(CONDITION . ACTION)
A symbol `string' is bound while evaluation."
:group 'ept
:type '(repeat (cons (sexp :tag "Condition")
(sexp :tag "Action"))))
(defun ept-outline-heading-string (string)
(save-match-data
(if (string-match (concat outline-regexp "[ \t]*") string)
(substring string (match-end 0))
string)))
(defun ept-outline-text-string (string)
(if (string-match "^\n*" string)
(substring string (match-end 0))
string))
(defun ept-outline-process-item (string level)
(or (catch 'done
(dolist (pair ept-outline-process-item-alist)
(when (eval (car pair))
(throw 'done (eval (cdr pair))))))
(let ((item string))
(setq item (list 'ept-item item))
(dotimes (i (1- level))
(setq item (list 'ept-itemize item)))
item)))
(defun ept-outline-number ()
0)
(defun ept-outline-play-buffer (start-page &optional dump)
(let (text level start pend end presentation page item inline)
(goto-char (point-min))
;; Cover page.
(outline-next-heading)
(setq presentation
`((ept-page
(ept-align-center
(ept-text "\n\n\n\n\n" ; FIXME
'(,(buffer-substring (point-min) (point)) .
ept-title-face)
"\n\n\n" ; FIXME
,user-full-name
" "
,user-mail-address)))))
(while (not (eobp))
(setq start (point))
(setq level (funcall outline-level))
(save-excursion (outline-end-of-heading)
(setq end (point)))
(setq text
(ept-outline-heading-string
(buffer-substring start end)))
(save-excursion
(outline-forward-same-level 1)
(setq pend (point)))
(if (string= text "")
(goto-char pend)
(setq page (list (list 'ept-title text)))
(setq page
(nconc page
(list
(list 'ept-text
(ept-outline-text-string
(buffer-substring end
(save-excursion
(outline-next-heading)
(point))))))))
(outline-next-heading)
(while (/= (point) pend)
(save-excursion
(outline-next-heading)
(setq end (point)))
(setq start (point))
(setq level (funcall outline-level))
(outline-end-of-heading)
(setq item (ept-outline-heading-string
(buffer-substring start (point))))
(setq item (ept-outline-process-item item level))
(setq page (nconc page (list item)))
(setq page
(nconc page
(list
(list 'ept-text
(ept-outline-text-string
(buffer-substring (point)
(save-excursion
(outline-next-heading)
(point))))))))
(goto-char end))
(setq presentation (cons
(nconc (list 'ept-page) page) presentation))))
(ept-play (nreverse presentation) start-page dump)))
(provide 'ept-outline)
;;; ept-outline.el ends here
|