# HG changeset patch # User Gerd Moellmann # Date 956171446 0 # Node ID 02edb3ce6745f30d475c323cd5dd22a1ae8b4925 # Parent ebc349d16eb975af8d0db6de23831eabf659808d (hexl-insert-hex-string): New command. diff -r ebc349d16eb9 -r 02edb3ce6745 lisp/hexl.el --- a/lisp/hexl.el Wed Apr 19 19:08:28 2000 +0000 +++ b/lisp/hexl.el Wed Apr 19 19:10:46 2000 +0000 @@ -717,6 +717,31 @@ (error "Hex number out of range") (hexl-insert-char num arg)))) +(defun hexl-insert-hex-string (str arg) + "Insert hexadecimal string STR at point ARG times. +Embedded whitespace, dashes, and periods in the string are ignored." + (interactive "sHex string: \np") + (setq str (replace-regexp-in-string "[- \t.]" "" str)) + (let ((chars '())) + (let ((len (length str)) + (idx 0)) + (if (eq (logand len 1) 1) + (let ((num (hexl-hex-string-to-integer (substring str 0 1)))) + (setq chars (cons num chars)) + (setq idx 1))) + (while (< idx len) + (let* ((nidx (+ idx 2)) + (num (hexl-hex-string-to-integer (substring str idx nidx)))) + (setq chars (cons num chars)) + (setq idx nidx)))) + (setq chars (nreverse chars)) + (while (> arg 0) + (let ((chars chars)) + (while chars + (hexl-insert-char (car chars) 1) + (setq chars (cdr chars)))) + (setq arg (- arg 1))))) + (defun hexl-insert-decimal-char (arg) "Insert a ASCII char ARG times at point for a given decimal number." (interactive "p")