diff options
| author | Gerd Moellmann | 2000-04-19 19:10:46 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-04-19 19:10:46 +0000 |
| commit | 9f6bff44411c75a856b3c426090c8fa7821bfcbf (patch) | |
| tree | 43b7af76f6e8d1a859d8e10fc75eb40fc893ca81 | |
| parent | 92d2bc08426a92074d0fa9bbcb12b423cee9ba7a (diff) | |
| download | emacs-9f6bff44411c75a856b3c426090c8fa7821bfcbf.tar.gz emacs-9f6bff44411c75a856b3c426090c8fa7821bfcbf.zip | |
(hexl-insert-hex-string): New command.
| -rw-r--r-- | lisp/hexl.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el index e5d55b43ca4..aca123a0ade 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el | |||
| @@ -717,6 +717,31 @@ This discards the buffer's undo information." | |||
| 717 | (error "Hex number out of range") | 717 | (error "Hex number out of range") |
| 718 | (hexl-insert-char num arg)))) | 718 | (hexl-insert-char num arg)))) |
| 719 | 719 | ||
| 720 | (defun hexl-insert-hex-string (str arg) | ||
| 721 | "Insert hexadecimal string STR at point ARG times. | ||
| 722 | Embedded whitespace, dashes, and periods in the string are ignored." | ||
| 723 | (interactive "sHex string: \np") | ||
| 724 | (setq str (replace-regexp-in-string "[- \t.]" "" str)) | ||
| 725 | (let ((chars '())) | ||
| 726 | (let ((len (length str)) | ||
| 727 | (idx 0)) | ||
| 728 | (if (eq (logand len 1) 1) | ||
| 729 | (let ((num (hexl-hex-string-to-integer (substring str 0 1)))) | ||
| 730 | (setq chars (cons num chars)) | ||
| 731 | (setq idx 1))) | ||
| 732 | (while (< idx len) | ||
| 733 | (let* ((nidx (+ idx 2)) | ||
| 734 | (num (hexl-hex-string-to-integer (substring str idx nidx)))) | ||
| 735 | (setq chars (cons num chars)) | ||
| 736 | (setq idx nidx)))) | ||
| 737 | (setq chars (nreverse chars)) | ||
| 738 | (while (> arg 0) | ||
| 739 | (let ((chars chars)) | ||
| 740 | (while chars | ||
| 741 | (hexl-insert-char (car chars) 1) | ||
| 742 | (setq chars (cdr chars)))) | ||
| 743 | (setq arg (- arg 1))))) | ||
| 744 | |||
| 720 | (defun hexl-insert-decimal-char (arg) | 745 | (defun hexl-insert-decimal-char (arg) |
| 721 | "Insert a ASCII char ARG times at point for a given decimal number." | 746 | "Insert a ASCII char ARG times at point for a given decimal number." |
| 722 | (interactive "p") | 747 | (interactive "p") |