+;;;###autoload
+(defun ps-spool-region (from to)
+ "Generate a PostScript image of the region and spool locally.
+Like `ps-spool-buffer', but spools just the current region.
+
+Use the command `ps-despool' to send the spooled images to the printer."
+ (interactive "r")
+ (ps-spool-without-faces from to t))
+
+
+;;;###autoload
+(defun ps-spool-region-with-faces (from to)
+ "Generate a PostScript image of the region and spool locally.
+Like `ps-spool-region', but includes font, color, and underline information in
+the generated image. This command works only if you are using a window system,
+so it has a way to determine color values.
+
+Use the command `ps-despool' to send the spooled images to the printer."
+ (interactive "r")
+ (ps-spool-with-faces from to t))
+
+;;;###autoload
+(defun ps-despool (&optional filename)
+ "Send the spooled PostScript to the printer.
+
+Interactively, when you use a prefix argument (\\[universal-argument]), the command prompts the
+user for a file name, and saves the spooled PostScript image in that file
+instead of sending it to the printer.
+
+Noninteractively, the argument FILENAME is treated as follows: if it is nil,
+send the image to the printer. If FILENAME is a string, save the PostScript
+image in a file with that name."
+ (interactive (list (ps-print-preprint current-prefix-arg)))
+ (ps-do-despool filename))
+
+;;;###autoload
+(defun ps-line-lengths ()
+ "Display the correspondence between a line length and a font size.
+Done using the current ps-print setup.
+Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
+ (interactive)
+ (ps-line-lengths-internal))
+
+;;;###autoload
+(defun ps-nb-pages-buffer (nb-lines)
+ "Display number of pages to print this buffer, for various font heights.
+The table depends on the current ps-print setup."
+ (interactive (ps-count-lines-preprint (point-min) (point-max)))
+ (ps-nb-pages nb-lines))
+
+;;;###autoload
+(defun ps-nb-pages-region (nb-lines)
+ "Display number of pages to print the region, for various font heights.
+The table depends on the current ps-print setup."
+ (interactive (ps-count-lines-preprint (mark) (point)))
+ (ps-nb-pages nb-lines))
+
+(defvar ps-prefix-quote nil
+ "Used for `ps-print-quote' (which see).")
+
+;;;###autoload
+(defun ps-setup ()
+ "Return the current PostScript-generation setup."
+ (let (ps-prefix-quote)
+ (mapconcat
+ #'ps-print-quote
+ (list
+ (concat "\n;;; (" (if (featurep 'xemacs) "XEmacs" "Emacs")
+ ") ps-print version " ps-print-version "\n")
+ ";; internal vars"
+ (ps-comment-string "emacs-version " emacs-version)
+ (ps-comment-string "ps-windows-system " ps-windows-system)
+ (ps-comment-string "ps-lp-system " ps-lp-system)
+ nil
+ '(25 . ps-print-color-p)
+ '(25 . ps-lpr-command)
+ '(25 . ps-lpr-switches)
+ '(25 . ps-printer-name)
+ '(25 . ps-printer-name-option)
+ '(25 . ps-print-region-function)
+ '(25 . ps-manual-feed)
+ '(25 . ps-end-with-control-d)
+ nil
+ '(23 . ps-paper-type)
+ '(23 . ps-warn-paper-type)
+ '(23 . ps-landscape-mode)
+ '(23 . ps-print-upside-down)
+ '(23 . ps-number-of-columns)
+ nil
+ '(23 . ps-zebra-stripes)
+ '(23 . ps-zebra-stripe-height)
+ '(23 . ps-zebra-stripe-follow)
+ '(23 . ps-zebra-color)
+ '(23 . ps-line-number)
+ '(23 . ps-line-number-step)
+ '(23 . ps-line-number-start)
+ nil
+ '(17 . ps-default-fg)
+ '(17 . ps-default-bg)
+ '(17 . ps-razzle-dazzle)
+ nil
+ '(23 . ps-use-face-background)
+ nil
+ '(28 . ps-print-control-characters)
+ nil
+ '(26 . ps-print-background-image)
+ nil
+ '(25 . ps-print-background-text)
+ nil
+ '(29 . ps-error-handler-message)
+ '(29 . ps-user-defined-prologue)
+ '(29 . ps-print-prologue-header)
+ '(29 . ps-postscript-code-directory)
+ '(29 . ps-adobe-tag)
+ nil
+ '(30 . ps-left-margin)
+ '(30 . ps-right-margin)
+ '(30 . ps-inter-column)
+ '(30 . ps-bottom-margin)
+ '(30 . ps-top-margin)
+ '(30 . ps-print-only-one-header)
+ '(30 . ps-switch-header)
+ '(30 . ps-print-header)
+ '(30 . ps-header-lines)
+ '(30 . ps-header-offset)
+ '(30 . ps-header-line-pad)
+ '(30 . ps-print-header-frame)
+ '(30 . ps-header-frame-alist)
+ '(30 . ps-print-footer)
+ '(30 . ps-footer-lines)
+ '(30 . ps-footer-offset)
+ '(30 . ps-footer-line-pad)
+ '(30 . ps-print-footer-frame)
+ '(30 . ps-footer-frame-alist)
+ '(30 . ps-show-n-of-n)
+ '(30 . ps-spool-config)
+ '(30 . ps-spool-duplex)
+ '(30 . ps-spool-tumble)
+ '(30 . ps-banner-page-when-duplexing)
+ '(30 . ps-left-header)
+ '(30 . ps-right-header)
+ '(30 . ps-left-footer)
+ '(30 . ps-right-footer)
+ nil
+ '(23 . ps-n-up-printing)
+ '(23 . ps-n-up-margin)
+ '(23 . ps-n-up-border-p)
+ '(23 . ps-n-up-filling)
+ nil
+ '(26 . ps-multibyte-buffer)
+ '(26 . ps-font-family)
+ '(26 . ps-font-size)
+ '(26 . ps-header-font-family)
+ '(26 . ps-header-font-size)
+ '(26 . ps-header-title-font-size)
+ '(26 . ps-footer-font-family)
+ '(26 . ps-footer-font-size)
+ '(26 . ps-line-number-color)
+ '(26 . ps-line-number-font)
+ '(26 . ps-line-number-font-size)
+ '(26 . ps-line-spacing)
+ '(26 . ps-paragraph-spacing)
+ '(26 . ps-paragraph-regexp)
+ '(26 . ps-begin-cut-regexp)
+ '(26 . ps-end-cut-regexp)
+ nil
+ '(23 . ps-even-or-odd-pages)
+ '(23 . ps-selected-pages)
+ '(23 . ps-last-selected-pages)
+ nil
+ '(31 . ps-build-face-reference)
+ '(31 . ps-always-build-face-reference)
+ nil
+ '(20 . ps-auto-font-detect)
+ '(20 . ps-bold-faces)
+ '(20 . ps-italic-faces)
+ '(20 . ps-underlined-faces)
+ '(20 . ps-black-white-faces)
+ " )\n
+;; The following customized variables have long lists and are seldom modified:
+;; ps-page-dimensions-database
+;; ps-font-info-database
+
+\;;; ps-print - end of settings\n")
+ "\n")))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Utility functions and variables:
+
+
+(defun ps-print-quote (elt)
+ "Quote ELT for printing (used for showing settings).
+
+If ELT is nil, return an empty string.
+If ELT is string, return it.
+Otherwise, ELT should be a cons (LEN . SYM) where SYM is a variable symbol and
+LEN is the field length where SYM name will be inserted. The variable
+`ps-prefix-quote' is used to form the string, if `ps-prefix-quote' is nil, it's
+used \"(setq \" as prefix; otherwise, it's used \" \". So, the string
+generated is:
+
+ * If `ps-prefix-quote' is nil:
+ \"(setq SYM-NAME SYM-VALUE\"
+ |<------->|
+ LEN
+
+ * If `ps-prefix-quote' is non-nil:
+ \" SYM-NAME SYM-VALUE\"
+ |<------->|
+ LEN
+
+If `ps-prefix-quote' is nil, it's set to t after generating string."
+ (cond
+ ((stringp elt) elt)
+ ((and (consp elt) (integerp (car elt))
+ (symbolp (cdr elt)) (boundp (cdr elt)))
+ (let* ((col (car elt))
+ (sym (cdr elt))
+ (key (symbol-name sym))
+ (len (length key))
+ (val (symbol-value sym)))
+ (concat (if ps-prefix-quote
+ " "
+ (setq ps-prefix-quote t)
+ "(setq ")
+ key
+ (if (> col len)
+ (make-string (- col len) ?\s)
+ " ")
+ (ps-value-string val))))
+ (t "")
+ ))
+
+
+(defun ps-value-string (val)
+ "Return a string representation of VAL. Used by `ps-print-quote'."
+ (cond ((null val)
+ "nil")
+ ((eq val t)
+ "t")
+ ((or (symbolp val) (listp val))
+ (format "'%S" val))
+ (t
+ (format "%S" val))))
+
+
+(defun ps-comment-string (str value)
+ "Return a comment string like \";; STR = VALUE\"."
+ (format ";; %s = %s" str (ps-value-string value)))
+
+
+(defun ps-value (alist-sym key)
+ "Return value from association list ALIST-SYM which car is `eq' to KEY."
+ (cdr (assq key (symbol-value alist-sym))))
+
+
+(defun ps-get (alist-sym key)
+ "Return element from association list ALIST-SYM which car is `eq' to KEY."
+ (assq key (symbol-value alist-sym)))
+
+
+(defun ps-put (alist-sym key value)
+ "Store element (KEY . VALUE) into association list ALIST-SYM.
+If KEY already exists in ALIST-SYM, modify cdr to VALUE.
+It can be retrieved with `(ps-get ALIST-SYM KEY)'."
+ (let ((elt: (assq key (symbol-value alist-sym)))) ; to avoid name conflict
+ (if elt:
+ (setcdr elt: value)
+ (setq elt: (cons key value))
+ (set alist-sym (cons elt: (symbol-value alist-sym))))
+ elt:))
+
+
+(defun ps-del (alist-sym key)
+ "Delete by side effect element KEY from association list ALIST-SYM."
+ (let ((a:list: (symbol-value alist-sym)) ; to avoid name conflict
+ old)
+ (while a:list:
+ (if (eq key (car (car a:list:)))
+ (progn
+ (if old
+ (setcdr old (cdr a:list:))
+ (set alist-sym (cdr a:list:)))
+ (setq a:list: nil))
+ (setq old a:list:
+ a:list: (cdr a:list:)))))
+ (symbol-value alist-sym))
+
+
+(defun ps-time-stamp-locale-default ()
+ "Return the locale's \"preferred\" date as, for example, \"06/18/01\"."
+ (format-time-string "%x"))
+
+
+(defun ps-time-stamp-mon-dd-yyyy ()
+ "Return date as \"Jun 18 2001\"."
+ (format-time-string "%b %d %Y"))
+
+
+(defun ps-time-stamp-yyyy-mm-dd ()
+ "Return date as \"2001-06-18\" (ISO date)."
+ (format-time-string "%Y-%m-%d"))
+
+
+;; Alias for `ps-time-stamp-yyyy-mm-dd' (which see).
+(defalias 'ps-time-stamp-iso8601 'ps-time-stamp-yyyy-mm-dd)
+
+
+(defun ps-time-stamp-hh:mm:ss ()
+ "Return time as \"17:28:31\"."
+ (format-time-string "%T"))
+