Merge from trunk
[bpt/emacs.git] / lisp / play / handwrite.el
CommitLineData
504737d5 1;;; handwrite.el --- turns your emacs buffer into a handwritten document -*- coding: iso-latin-1; -*-
1a44ec7a 2
73b0cd50 3;; Copyright (C) 1996, 2001-2011 Free Software Foundation, Inc.
1a44ec7a 4
9781053a 5;; Author: Danny Roozendaal (was: <danny@tvs.kun.nl>)
43f36b80 6;; Created: October 21 1996
0465b759 7;; Keywords: wp, print, postscript, cursive writing
1a44ec7a 8
43f36b80 9;; This file is part of GNU Emacs.
1a44ec7a 10
b1fc2b50 11;; GNU Emacs is free software: you can redistribute it and/or modify
43f36b80 12;; it under the terms of the GNU General Public License as published by
b1fc2b50
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
1a44ec7a 15
43f36b80
RS
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
1a44ec7a 20
43f36b80 21;; You should have received a copy of the GNU General Public License
b1fc2b50 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
1a44ec7a 23
43f36b80
RS
24;;; Commentary:
25;;
26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27;; The function handwrite creates PostScript output containing a
28;; handwritten version of the current buffer..
29;; Other functions that may be useful are
30;;
31;; handwrite-10pt: sets the font size to 10 and finds corresponding
32;; values for the line spacing and the number of lines
33;; on a page.
34;; handwrite-11pt: which is similar
35;; handwrite-12pt: which is also similar
36;; handwrite-13pt: which is similar, too
37;;
38;; handwrite-set-pagenumber: set and unset page numbering
39;;
40;;
41;; If you are not satisfied with the type page there are a number of
42;; variables you may want to set.
43;;
44;;
45;; Installation
46;;
47;; type at your prompt "emacs -l handwrite.el" or put this file on your
48;; Emacs-Lisp load path, add the following into your ~/.emacs startup file
49;;
50;; (require 'handwrite)
51;;
52;; "M-x handwrite" or "Write by hand" in the edit menu should work now.
53;;
54;;
55;; I tried to make it `iso_8859_1'-friendly, but there are some exotic
56;; characters missing.
57;;
58;;
59;; Known bugs: -Page feeds do not do their work, but are ignored instead.
60;; -Tabs are not always properly displayed.
61;; -Handwrite may create corrupt PostScript if it encounters
62;; unknown characters.
63;;
64;; Thanks to anyone who emailed me suggestions!
65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66
67
68;;; Code:
69
d94707e0
JB
70(defvar ps-printer-name)
71(defvar ps-lpr-command)
72
43f36b80
RS
73
74;; Variables
75
323f7c49 76(defgroup handwrite nil
283bf437 77 "Turns your Emacs buffer into a handwritten document."
323f7c49
SE
78 :prefix "handwrite-"
79 :group 'games)
80
43f36b80 81(defvar handwrite-psindex 0
a2b80428 82 "The index of the PostScript buffer.")
b016851c
SM
83(defvar menu-bar-handwrite-map
84 (let ((map (make-sparse-keymap "Handwrite functions.")))
85 (define-key map [numbering]
86 '(menu-item "Page numbering" handwrite-set-pagenumber
87 :button (:toggle . handwrite-pagenumbering)))
88 (define-key map [handwrite-separator2] '("----" . nil))
89 (define-key map [10pt] '(menu-item "10 pt" handwrite-10pt
90 :button (:radio . (eq handwrite-fontsize 10))))
91 (define-key map [11pt] '(menu-item "11 pt" handwrite-11pt
92 :button (:radio . (eq handwrite-fontsize 11))))
93 (define-key map [12pt] '(menu-item "12 pt" handwrite-12pt
94 :button (:radio . (eq handwrite-fontsize 12))))
95 (define-key map [13pt] '(menu-item "13 pt" handwrite-13pt
96 :button (:radio . (eq handwrite-fontsize 13))))
97 (define-key map [handwrite-separator1] '("----" . nil))
98 (define-key map [handwrite] '("Write by hand" . handwrite))
99 map))
100(fset 'menu-bar-handwrite-map menu-bar-handwrite-map)
43f36b80
RS
101
102
103;; User definable variables
104
323f7c49 105(defcustom handwrite-numlines 60
67d110f1 106 "The number of lines on a page of the PostScript output from `handwrite'."
323f7c49
SE
107 :type 'integer
108 :group 'handwrite)
109(defcustom handwrite-fontsize 11
67d110f1 110 "The size of the font for the PostScript output from `handwrite'."
323f7c49
SE
111 :type 'integer
112 :group 'handwrite)
113(defcustom handwrite-linespace 12
67d110f1 114 "The spacing for the PostScript output from `handwrite'."
323f7c49
SE
115 :type 'integer
116 :group 'handwrite)
117(defcustom handwrite-xstart 30
67d110f1 118 "X-axis translation in the PostScript output from `handwrite'."
323f7c49
SE
119 :type 'integer
120 :group 'handwrite)
121(defcustom handwrite-ystart 810
67d110f1 122 "Y-axis translation in the PostScript output from `handwrite'."
323f7c49
SE
123 :type 'integer
124 :group 'handwrite)
125(defcustom handwrite-pagenumbering nil
67d110f1 126 "If non-nil, number each page of the PostScript output from `handwrite'."
323f7c49
SE
127 :type 'boolean
128 :group 'handwrite)
129(defcustom handwrite-10pt-numlines 65
67d110f1 130 "The number of lines on a page for the function `handwrite-10pt'."
323f7c49
SE
131 :type 'integer
132 :group 'handwrite)
133(defcustom handwrite-11pt-numlines 60
67d110f1 134 "The number of lines on a page for the function `handwrite-11pt'."
323f7c49
SE
135 :type 'integer
136 :group 'handwrite)
137(defcustom handwrite-12pt-numlines 55
67d110f1 138 "The number of lines on a page for the function `handwrite-12pt'."
323f7c49
SE
139 :type 'integer
140 :group 'handwrite)
141(defcustom handwrite-13pt-numlines 50
67d110f1 142 "The number of lines on a page for the function `handwrite-13pt'."
323f7c49
SE
143 :type 'integer
144 :group 'handwrite)
43f36b80
RS
145
146;; Interactive functions
147
a2b80428
RS
148;;;###autoload
149(defun handwrite ()
150 "Turns the buffer into a \"handwritten\" document.
151The functions `handwrite-10pt', `handwrite-11pt', `handwrite-12pt'
152and `handwrite-13pt' set up for various sizes of output.
153
b016851c
SM
154Variables: `handwrite-linespace' (default 12)
155 `handwrite-fontsize' (default 11)
156 `handwrite-numlines' (default 60)
157 `handwrite-pagenumbering' (default nil)"
43f36b80
RS
158 (interactive)
159 (let
160 ((pmin) ; thanks, Havard
161 (lastp)
162 (cur-buf (current-buffer))
a1506d29 163 (tpoint (point))
43f36b80
RS
164 (ps-ypos 63)
165 (lcount 0)
166 (ipage 1)
167 (nlan next-line-add-newlines) ;remember the old value
168 (buf-name (buffer-name) )
169 (textp)
170 (ps-buf-name) ;name of the PostScript buffer
2f88760a
CY
171 (trans-table
172