-;; into a new buffer, makes that buffer current,
-;; and sets start and end to the buffer bounds.
-;; start and end are used free.
-(defun print-region-new-buffer ()
- (or (string= (buffer-name) " *spool temp*")
- (let ((oldbuf (current-buffer)))
- (set-buffer (get-buffer-create " *spool temp*"))
- (widen) (erase-buffer)
- (insert-buffer-substring oldbuf start end)
- (setq start (point-min) end (point-max)))))
+;; into a new buffer, makes that buffer current.
+;; It returns the new range to print from the new current buffer
+;; as (START . END).
+
+(defun print-region-new-buffer (ostart oend)
+ (if (string= (buffer-name) " *spool temp*")
+ (cons ostart oend)
+ (let ((oldbuf (current-buffer)))
+ (set-buffer (get-buffer-create " *spool temp*"))
+ (widen)
+ (erase-buffer)
+ (insert-buffer-substring oldbuf ostart oend)
+ (cons (point-min) (point-max)))))
+
+(defun printify-region (begin end)
+ "Replace nonprinting characters in region with printable representations.
+The printable representations use ^ (for ASCII control characters) or hex.
+The characters tab, linefeed, space, return and formfeed are not affected."
+ (interactive "r")
+ (save-excursion
+ (save-restriction
+ (narrow-to-region begin end)
+ (goto-char (point-min))
+ (let (c)
+ (while (re-search-forward "[\^@-\^h\^k\^n-\^_\177-\377]" nil t)
+ (setq c (preceding-char))
+ (delete-backward-char 1)
+ (insert (if (< c ?\s)
+ (format "\\^%c" (+ c ?@))
+ (format "\\%02x" c))))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Functions hacked from `ps-print' package.
+
+;; Dynamic evaluation
+(defun lpr-eval-switch (arg)
+ (cond ((stringp arg) arg)
+ ((functionp arg) (apply arg nil))
+ ((symbolp arg) (symbol-value arg))
+ ((consp arg) (apply (car arg) (cdr arg)))
+ (t nil)))
+
+;; `lpr-flatten-list' is defined here (copied from "message.el" and
+;; enhanced to handle dotted pairs as well) until we can get some
+;; sensible autoloads, or `flatten-list' gets put somewhere decent.
+
+;; (lpr-flatten-list '((a . b) c (d . e) (f g h) i . j))
+;; => (a b c d e f g h i j)
+
+(defun lpr-flatten-list (&rest list)
+ (lpr-flatten-list-1 list))
+
+(defun lpr-flatten-list-1 (list)
+ (cond
+ ((null list) (list))
+ ((consp list)
+ (append (lpr-flatten-list-1 (car list))
+ (lpr-flatten-list-1 (cdr list))))
+ (t (list list))))
+
+(provide 'lpr)
+
+;;; arch-tag: 21c3f821-ebec-4ca9-ac67-a81e4b75c62a
+;;; lpr.el ends here