Commit | Line | Data |
---|---|---|
504737d5 | 1 | ;;; handwrite.el --- turns your emacs buffer into a handwritten document -*- coding: iso-latin-1; -*- |
1a44ec7a | 2 | |
44e97401 | 3 | ;; Copyright (C) 1996, 2001-2012 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 | |
865fe16f | 48 | ;; Emacs-Lisp load path, add the following into your init file: |
43f36b80 RS |
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 | ||
121656e9 | 70 | ;; From ps-print.el |
d94707e0 JB |
71 | (defvar ps-printer-name) |
72 | (defvar ps-lpr-command) | |
121656e9 | 73 | (defvar ps-lpr-switches) |
d94707e0 | 74 | |
43f36b80 RS |
75 | |
76 | ;; Variables | |
77 | ||
323f7c49 | 78 | (defgroup handwrite nil |
283bf437 | 79 | "Turns your Emacs buffer into a handwritten document." |
323f7c49 SE |
80 | :prefix "handwrite-" |
81 | :group 'games) | |
82 | ||
43f36b80 | 83 | (defvar handwrite-psindex 0 |
a2b80428 | 84 | "The index of the PostScript buffer.") |
b016851c SM |
85 | (defvar menu-bar-handwrite-map |
86 | (let ((map (make-sparse-keymap "Handwrite functions."))) | |
87 | (define-key map [numbering] | |
88 | '(menu-item "Page numbering" handwrite-set-pagenumber | |
89 | :button (:toggle . handwrite-pagenumbering))) | |
90 | (define-key map [handwrite-separator2] '("----" . nil)) | |
91 | (define-key map [10pt] '(menu-item "10 pt" handwrite-10pt | |
92 | :button (:radio . (eq handwrite-fontsize 10)))) | |
93 | (define-key map [11pt] '(menu-item "11 pt" handwrite-11pt | |
94 | :button (:radio . (eq handwrite-fontsize 11)))) | |
95 | (define-key map [12pt] '(menu-item "12 pt" handwrite-12pt | |
96 | :button (:radio . (eq handwrite-fontsize 12)))) | |
97 | (define-key map [13pt] '(menu-item "13 pt" handwrite-13pt | |
98 | :button (:radio . (eq handwrite-fontsize 13)))) | |
99 | (define-key map [handwrite-separator1] '("----" . nil)) | |
100 | (define-key map [handwrite] '("Write by hand" . handwrite)) | |
101 | map)) | |
102 | (fset 'menu-bar-handwrite-map menu-bar-handwrite-map) | |
43f36b80 RS |
103 | |
104 | ||
105 | ;; User definable variables | |
106 | ||
323f7c49 | 107 | (defcustom handwrite-numlines 60 |
67d110f1 | 108 | "The number of lines on a page of the PostScript output from `handwrite'." |
323f7c49 SE |
109 | :type 'integer |
110 | :group 'handwrite) | |
111 | (defcustom handwrite-fontsize 11 | |
67d110f1 | 112 | "The size of the font for the PostScript output from `handwrite'." |
323f7c49 SE |
113 | :type 'integer |
114 | :group 'handwrite) | |
115 | (defcustom handwrite-linespace 12 | |
67d110f1 | 116 | "The spacing for the PostScript output from `handwrite'." |
323f7c49 SE |
117 | :type 'integer |
118 | :group 'handwrite) | |
119 | (defcustom handwrite-xstart 30 | |
67d110f1 | 120 | "X-axis translation in the PostScript output from `handwrite'." |
323f7c49 SE |
121 | :type 'integer |
122 | :group 'handwrite) | |
123 | (defcustom handwrite-ystart 810 | |
67d110f1 | 124 | "Y-axis translation in the PostScript output from `handwrite'." |
323f7c49 SE |
125 | :type 'integer |
126 | :group 'handwrite) | |
127 | (defcustom handwrite-pagenumbering nil | |
67d110f1 | 128 | "If non-nil, number each page of the PostScript output from `handwrite'." |
323f7c49 SE |
129 | :type 'boolean |
130 | :group 'handwrite) | |
131 | (defcustom handwrite-10pt-numlines 65 | |
67d110f1 | 132 | "The number of lines on a page for the function `handwrite-10pt'." |
323f7c49 SE |
133 | :type 'integer |
134 | :group 'handwrite) | |
135 | (defcustom handwrite-11pt-numlines 60 | |
67d110f1 | 136 | "The number of lines on a page for the function `handwrite-11pt'." |
323f7c49 SE |
137 | :type 'integer |
138 | :group 'handwrite) | |
139 | (defcustom handwrite-12pt-numlines 55 | |
67d110f1 | 140 | "The number of lines on a page for the function `handwrite-12pt'." |
323f7c49 SE |
141 | :type 'integer |
142 | :group 'handwrite) | |
143 | (defcustom handwrite-13pt-numlines 50 | |
67d110f1 | 144 | "The number of lines on a page for the function `handwrite-13pt'." |
323f7c49 SE |
145 | :type 'integer |
146 | :group 'handwrite) | |
43f36b80 RS |
147 | |
148 | ;; Interactive functions | |
149 | ||
a2b80428 RS |
150 | ;;;###autoload |
151 | (defun handwrite () | |
152 | "Turns the buffer into a \"handwritten\" document. | |
153 | The functions `handwrite-10pt', `handwrite-11pt', `handwrite-12pt' | |
154 | and `handwrite-13pt' set up for various sizes of output. | |
155 | ||
b016851c SM |
156 | Variables: `handwrite-linespace' (default 12) |
157 | `handwrite-fontsize' (default 11) | |
158 | `handwrite-numlines' (default 60) | |
159 | `handwrite-pagenumbering' (default nil)" | |
43f36b80 RS |
160 | (interactive) |
161 | (let | |
121656e9 | 162 | (;(pmin) ; thanks, Havard |
43f36b80 | 163 | (cur-buf (current-buffer)) |
a1506d29 | 164 | (tpoint (point)) |
43f36b80 RS |
165 | (ps-ypos 63) |
166 | (lcount 0) | |
167 | (ipage 1) | |
168 | (nlan next-line-add-newlines) ;remember the old value | |
169 | (buf-name (buffer-name) ) | |
170 | (textp) | |
171 | (ps-buf-name) ;name of the PostScript buffer | |
2f88760a CY |
172 | (trans-table |
173 |