- (goto-char begin)
- (let (c)
- (while (re-search-forward "[\^@-\^h\^k\^n-\^_\177-\377]" end t)
- (setq c (preceding-char))
- (delete-backward-char 1)
- (insert
- (if (< c ?\ )
- (format "\\^%c" (+ c ?@))
- (format "\\%02x" c)))))))
+ (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))))