Function: handwrite
handwrite is an autoloaded, interactive and byte-compiled function
defined in handwrite.el.gz.
Signature
(handwrite)
Documentation
Turn the buffer into a "handwritten" document.
The functions handwrite-10pt, handwrite-11pt, handwrite-12pt
and handwrite-13pt set up for various sizes of output.
Variables: handwrite-linespace (default 12)
handwrite-fontsize (default 11)
handwrite-numlines (default 60)
handwrite-pagenumbering (default nil)
Probably introduced at or before Emacs version 20.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/handwrite.el.gz
;; Interactive functions
;;;###autoload
(defun handwrite ()
"Turn the buffer into a \"handwritten\" document.
The functions `handwrite-10pt', `handwrite-11pt', `handwrite-12pt'
and `handwrite-13pt' set up for various sizes of output.
Variables: `handwrite-linespace' (default 12)
`handwrite-fontsize' (default 11)
`handwrite-numlines' (default 60)
`handwrite-pagenumbering' (default nil)"
(interactive)
(setq handwrite-psindex (1+ handwrite-psindex))
(let
((cur-buf (current-buffer))
(tpoint (point))
(ps-ypos 63)
(lcount 0)
(ipage 1)
(next-line-add-newlines t)
(buf-name (buffer-name) )
(textp)
(ps-buf-name (format "*handwritten%d.ps*" handwrite-psindex))
(trans-table
'(("ÿ" . "264") ("á" . "207") ("à" . "210") ("â" . "211")
("ä" . "212") ("ã" . "213") ("å" . "214") ("é" . "216")
("è" . "217") ("ê" . "220") ("ë" . "221") ("í" . "222")
("ì" . "223") ("î" . "224") ("ï" . "225") ("ó" . "227")
("ò" . "230") ("ô" . "231") ("ö" . "232") ("õ" . "233")
("ú" . "234") ("ù" . "235") ("û" . "236") ("ü" . "237")
("ß" . "247") ("°" . "241") ("®" . "250") ("©" . "251")
("ij" . "264") ("ç" . "215") ("§" . "244") ("ñ" . "226")
("£" . "243")))
(escape-table '("\\\\" "(" ")")) ; \\ comes first to not work
; on inserted backslashes
line)
(goto-char (point-min)) ;start at beginning
(switch-to-buffer ps-buf-name)
(handwrite-insert-header buf-name)
(insert "%%Creator: GNU Emacs's handwrite version " emacs-version "\n")
(handwrite-insert-preamble)
(handwrite-insert-info)
(handwrite-insert-font)
(setq textp (point))
(insert "%%Page: 1 1\n")
(insert "Hwjst\n")
(insert "/Hwsave save def\n")
(if handwrite-pagenumbering (insert "20 30 m\nxym(page 1)a\n"))
(insert "44 63 m\n")
(insert "xym( )a")
(backward-char 3)
(switch-to-buffer cur-buf)
(goto-char (point-min)) ;start at beginning
(save-excursion
(while (not (eobp))
(setq line (thing-at-point 'line))
(dolist (escape escape-table)
(setq line (replace-regexp-in-string escape
(concat "\\\\" escape) line)))
(dolist (trans trans-table)
(setq line (replace-regexp-in-string (car trans)
(concat "\\\\" (cdr trans))
line)))
(switch-to-buffer ps-buf-name)
(insert (string-replace "\n" "" line))
(message "write write write...")
(setq ps-ypos (+ ps-ypos handwrite-linespace))
(end-of-line)
(insert "\n")
(setq lcount (+ lcount 1))
(when (= lcount handwrite-numlines)
(setq ipage (+ ipage 1))
(insert "0 0 m\n")
(insert "showpage exec Hwsave restore\n")
(insert "%%Page: " (number-to-string ipage) " "
(number-to-string ipage) "\n")
(insert "Hwjst\n")
(insert "/Hwsave save def\n")
(if handwrite-pagenumbering
(insert "20 30 m\nxym(page "
(number-to-string ipage) ")a\n"))
(setq ps-ypos 63)
(setq lcount 0))
(insert "44 " (number-to-string ps-ypos) " m\n")
(insert "xym( )a")
(backward-char 3)
(switch-to-buffer cur-buf)
(forward-line 1)
))
(switch-to-buffer ps-buf-name)
(forward-line 1)
(insert " showpage exec Hwsave restore\n\n")
(insert "%%Pages " (number-to-string ipage) " 0\n")
(insert "%%EOF\n")
;;To avoid cumbersome code we simply ignore formfeeds
(goto-char textp)
(while (search-forward "\f" nil t)
(replace-match "" nil t) )
(untabify textp (point-max)) ; this may result in strange tabs
(when (y-or-n-p "Send this to the printer? ")
(let* ((coding-system-for-write 'raw-text-unix)
(printer-name (or ps-printer-name printer-name))
(lpr-printer-switch ps-printer-name-option)
(print-region-function ps-print-region-function)
(lpr-command ps-lpr-command))
(lpr-print-region (point-min) (point-max) ps-lpr-switches nil)))
(message "")
(bury-buffer ())
(switch-to-buffer cur-buf)
(goto-char tpoint)))