home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.sources
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!fly.cnuce.cnr.it!pot
- From: pot@fly.cnuce.cnr.it (Francesco Potorti`)
- Subject: hexlify-buffer
- Message-ID: <m0mpyAL-0001BGC@fly.cnuce.cnr.IT>
- Sender: daemon@cis.ohio-state.edu
- Reply-To: pot@cnuce.cnr.it
- Organization: Source only Discussion and requests in gnu.emacs.help.
- Distribution: gnu
- Date: Fri, 13 Nov 1992 12:22:00 GMT
- Lines: 34
-
- Sorry, the previously posted function contained a DEL character that
- has been deleted by mailers.
- This one should do the work.
- Again, anyone able to make it faster?
-
- (defun hexlify-buffer ()
- "Convert the current buffer to hexl format."
- (interactive)
- (goto-char (point-min))
- (let ((len 0) (address 0) (chars "")
- (print-chars
- (vconcat
- (mapcar 'char-to-string (make-string 32 ?.))
- (mapcar 'char-to-string " !\"#$%&'()*+,-./0123456789:;<=>?@")
- (mapcar 'char-to-string "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`")
- (mapcar 'char-to-string "abcdefghijklmnopqrstuvwxyz{|}~")
- (mapcar 'char-to-string (make-string 129 ?.)))))
- (while (not (eobp))
- (setq len (min 16 (- (point-max) (point))))
- (setq chars (buffer-substring (point) (+ (point) len)))
- (delete-char len)
- (insert (format "%07x0: " address)
- (mapconcat '(lambda (arg) (format "%02x" arg)) chars ""))
- (if (eobp) (insert-char ? (* 2 (- 16 len))))
- (backward-char 28)
- (looking-at
- "\\(....\\)\\(....\\)\\(....\\)\\(....\\)\\(....\\)\\(....\\)\\(....\\)")
- (replace-match " \\1 \\2 \\3 \\4 \\5 \\6 \\7 \"")
- (insert (mapconcat '(lambda (c) (aref print-chars c)) chars "") "\"\n")
- (setq address (1+ address)))))
-
- Francesco Potorti` | pot@cnuce.cnr.IT (Internet)
- | 39369::pot (DECnet)
- | +39-50-593203 (voice)
-