home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.sources
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.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: <m0mpOE6-0001D3C@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: Thu, 12 Nov 1992 12:10:00 GMT
- Lines: 36
-
- This version of hexlify-buffer is twice as fast as the original one in
- hexl.el.
-
- Anyone out there is able to make it better (it is always too S L O W)?
-
- (defun hexlify-buffer ()
- "Convert a binary buffer to hexl format"
- (interactive)
- (goto-char (point-min))
- (let (len
- (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 128 ?.)))))
- (while (not (eobp))
- (setq len (min 16 (- (point-max) (point))))
- (setq chars (buffer-substring (point) (+ (point) len)))
- (delete-char len)
- (insert (format "%08x: " 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 (+ address 16)))))
-
- Francesco Potorti` | pot@cnuce.cnr.IT (Internet)
- | 39369::pot (DECnet)
- | +39-50-593203 (voice)
-