-;;; handwrite.el --- turns your emacs buffer into a handwritten document.
+;;; handwrite.el --- turns your emacs buffer into a handwritten document -*- coding: iso-latin-1; -*-
-;; (C) Copyright 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-;; Author: Danny Roozendaal (danny@tvs.kun.nl)
+;; Author: Danny Roozendaal (was: <danny@tvs.kun.nl>)
;; Created: October 21 1996
-;; Keywords: cursive writing
+;; Keywords: wp, print, postscript, cursive writing
;; This file is part of GNU Emacs.
;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; Variables
+(defgroup handwrite nil
+ "Turns your emacs buffer into a handwritten document."
+ :prefix "handwrite-"
+ :group 'games)
+
(defvar handwrite-psindex 0
- "The index of the PostScript buffer")
+ "The index of the PostScript buffer.")
(defvar menu-bar-handwrite-map (make-sparse-keymap "Handwrite functions."))
(fset 'menu-bar-handwrite-map (symbol-value 'menu-bar-handwrite-map))
;; User definable variables
-(defvar handwrite-numlines 60
- "*The number of lines on a page of the PostScript output")
-(defvar handwrite-fontsize 11
- "*The size of the font for the PostScript output")
-(defvar handwrite-linespace 12
- "*The spacing for the PostScript output")
-(defvar handwrite-xstart 30
- "*Translation in the x-direction of the origin in the PostScript output")
-(defvar handwrite-ystart 810
- "*Translation in the y-direction of the origin in the PostScript output")
-(defvar handwrite-pagenumbering nil
- "*If t then number each page of the PostScript output")
-(defvar handwrite-10pt-numlines 65
- "*The number of lines on a page for the function handwrite-10pt")
-(defvar handwrite-11pt-numlines 60
- "*The number of lines on a page for the function handwrite-11pt")
-(defvar handwrite-12pt-numlines 55
- "*The number of lines on a page for the function handwrite-12pt")
-(defvar handwrite-13pt-numlines 50
- "*The number of lines on a page for the function handwrite-13pt")
-
+(defcustom handwrite-numlines 60
+ "*The number of lines on a page of the PostScript output from `handwrite'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-fontsize 11
+ "*The size of the font for the PostScript output from `handwrite'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-linespace 12
+ "*The spacing for the PostScript output from `handwrite'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-xstart 30
+ "*X-axis translation in the PostScript output from `handwrite'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-ystart 810
+ "*Y-axis translation in the PostScript output from `handwrite'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-pagenumbering nil
+ "*If non-nil, number each page of the PostScript output from `handwrite'."
+ :type 'boolean
+ :group 'handwrite)
+(defcustom handwrite-10pt-numlines 65
+ "*The number of lines on a page for the function `handwrite-10pt'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-11pt-numlines 60
+ "*The number of lines on a page for the function `handwrite-11pt'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-12pt-numlines 55
+ "*The number of lines on a page for the function `handwrite-12pt'."
+ :type 'integer
+ :group 'handwrite)
+(defcustom handwrite-13pt-numlines 50
+ "*The number of lines on a page for the function `handwrite-13pt'."
+ :type 'integer
+ :group 'handwrite)
;; Interactive functions
-(defun handwrite ()
- "Turns the buffer into a handwritten document.
+;;;###autoload
+(defun handwrite ()
+ "Turns 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)
((pmin) ; thanks, Havard
(lastp)
(cur-buf (current-buffer))
- (tpoint (point))
+ (tpoint (point))
(ps-ypos 63)
(lcount 0)
(ipage 1)
(setq next-line-add-newlines t)
(switch-to-buffer ps-buf-name)
(handwrite-insert-header buf-name)
- (insert "\n(\\nCreated by Gnu Emacs' handwrite version "
- emacs-version "\\n\\n)=print flush\n")
+ (insert "%%Creator: GNU Emacs' handwrite version " emacs-version "\n")
(handwrite-insert-preamble)
(handwrite-insert-info)
(handwrite-insert-font)
(switch-to-buffer cur-buf)
(goto-char (point-min)) ;start at beginning
(save-excursion
- ;;as long as we see a newline the document is not ended.
+ ;;as long as we see a newline the document is not ended.
(while (re-search-forward "\n" nil t)
(previous-line 1)
(beginning-of-line)
(replace-match "" nil t) )
(untabify textp (point-max)) ; this may result in strange tabs
(if (y-or-n-p "Send this to the printer? ")
- (call-process-region (point-min)
- (point-max) lpr-command nil nil nil))
+ (progn
+ (require 'ps-print)
+ (let* ((coding-system-for-write 'raw-text-unix)
+ (ps-printer-name (or ps-printer-name
+ (and (boundp 'printer-name)
+ printer-name)))
+ (ps-lpr-switches
+ (if (stringp ps-printer-name)
+ (list (concat "-P" ps-printer-name)))))
+ (apply (or ps-print-region-function 'call-process-region)
+ (point-min) (point-max) ps-lpr-command nil nil nil))))
(message "")
(bury-buffer ())
(switch-to-buffer cur-buf)
(defun handwrite-set-pagenumber ()
- "Toggle the value of handwrite-pagenumbering"
+ "Toggle the value of `handwrite-pagenumbering'."
(interactive)
(if handwrite-pagenumbering
(handwrite-set-pagenumber-off)(handwrite-set-pagenumber-on)))
(defun handwrite-10pt ()
- "Sets the variable `handwrite-fontsize' to 10 and finds correct
-values for `handwrite-linespace' and `handwrite-numlines'"
+ "Specify 10-point output for `handwrite.
+This sets `handwrite-fontsize' to 10 and finds correct
+values for `handwrite-linespace' and `handwrite-numlines'."
(interactive)
(setq handwrite-fontsize 10)
(setq handwrite-linespace 11)
'("12 pt" . handwrite-12pt))
(define-key menu-bar-handwrite-map [13pt]
'("13 pt" . handwrite-13pt))
- (message "Joepie set to 10 points"))
+ (message "Handwrite output size set to 10 points"))
(defun handwrite-11pt ()
- "Sets the variable `handwrite-fontsize' to 11 and finds correct
-values for `handwrite-linespace' and `handwrite-numlines'"
+ "Specify 11-point output for `handwrite.
+This sets `handwrite-fontsize' to 11 and finds correct
+values for `handwrite-linespace' and `handwrite-numlines'."
(interactive)
(setq handwrite-fontsize 11)
(setq handwrite-linespace 12)
- (setq handwrite-numlines handwrite-11pt-numlines )
+ (setq handwrite-numlines handwrite-11pt-numlines)
(define-key menu-bar-handwrite-map [10pt]
'("10 pt" . handwrite-10pt))
(define-key menu-bar-handwrite-map [11pt]
'("12 pt" . handwrite-12pt))
(define-key menu-bar-handwrite-map [13pt]
'("13 pt" . handwrite-13pt))
- (message "Joepie set to 11 points"))
+ (message "Handwrite output size set to 11 points"))
(defun handwrite-12pt ()
- "Sets the variable `handwrite-fontsize' to 12 and finds correct
-values for `handwrite-linespace' and `handwrite-numlines'"
+ "Specify 12-point output for `handwrite.
+This sets `handwrite-fontsize' to 12 and finds correct
+values for `handwrite-linespace' and `handwrite-numlines'."
(interactive)
(setq handwrite-fontsize 12)
(setq handwrite-linespace 13)
'("12 pt *" . handwrite-12pt))
(define-key menu-bar-handwrite-map [13pt]
'("13 pt" . handwrite-13pt))
- (message "Joepie set to 12 points"))
+ (message "Handwrite output size set to 12 points"))
(defun handwrite-13pt ()
- "Sets the variable `handwrite-fontsize' to 13 and finds correct
-values for `handwrite-linespace' and `handwrite-numlines'"
+ "Specify 13-point output for `handwrite.
+This sets `handwrite-fontsize' to 13 and finds correct
+values for `handwrite-linespace' and `handwrite-numlines'."
(interactive)
(setq handwrite-fontsize 13)
(setq handwrite-linespace 14)
'("12 pt" . handwrite-12pt))
(define-key menu-bar-handwrite-map [13pt]
'("13 pt *" . handwrite-13pt))
- (message "Joepie set to 13 points"))
+ (message "Handwrite output size set to 13 points"))
;; Internal Functions
}def
%%EndPreamble\n"))
-;;The the font size for the PostScript output.
+;;The font size for the PostScript output.
;;Also the x-y-translations of the PostScript stuff.
(defun handwrite-insert-info ()
(insert "\n%%BeginSizeTranslate\n")
;; Key bindings
-(define-key-after
- (lookup-key global-map [menu-bar edit])
- [handwrite]
- '("Write by hand" . menu-bar-handwrite-map)
- 'spell)
+;;; I'd rather not fill up the menu bar menus with
+;;; lots of random miscellaneous features. -- rms.
+;;;(define-key-after
+;;; (lookup-key global-map [menu-bar edit])
+;;; [handwrite]
+;;; '("Write by hand" . menu-bar-handwrite-map)
+;;; 'spell)
(define-key menu-bar-handwrite-map [numbering]
'("Page numbering Off" . handwrite-set-pagenumber))
(provide 'handwrite)
+;;; arch-tag: f2285ae9-e41b-4c96-8343-87dce41e44b7
;;; handwrite.el ends here