changeset 2382:030b76db285a

(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code in LCD.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Sat, 27 Mar 1993 01:58:38 +0000
parents f8ae5fc2c196
children b7941d286c3f
files lisp/lpr.el
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/lpr.el	Sat Mar 27 01:58:33 1993 +0000
+++ b/lisp/lpr.el	Sat Mar 27 01:58:38 1993 +0000
@@ -108,4 +108,20 @@
 	(insert-buffer-substring oldbuf start end)
 	(setq start (point-min) end (point-max)))))
 
+(defun printify-region (begin end)
+  "Turn nonprinting characters (other than TAB, LF, SPC, RET, and FF)
+in the current buffer into printable representations as control or
+hexadecimal escapes."
+  (interactive "r")
+  (save-excursion
+    (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)))))))
+
 ;;; lpr.el ends here