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