Skip to content

Commit

Permalink
Push prepending of "0x" up to hexify-region
Browse files Browse the repository at this point in the history
  • Loading branch information
eentzel committed Mar 14, 2014
1 parent b1abcac commit f404d3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hexify.el
Expand Up @@ -2,10 +2,10 @@
(let* ((hex (mapcar (lambda (char)
(format "%X" char))
str)))
(reduce 'concat (cons "0x" hex))))
(apply 'concat hex)))

(assert (string= "0x65726963" (hexify "eric")))
(assert (string= "0x65656E747A656C" (hexify "eentzel")))
(assert (string= "65726963" (hexify "eric")))
(assert (string= "65656E747A656C" (hexify "eentzel")))

(defun hexify-region ()
"In transient-mark-mode, put the hexadecimal represntation of
Expand All @@ -15,7 +15,7 @@ region on the kill ring, prefixed with 0x"
(let* ((start (region-beginning))
(end (region-end))
(input (buffer-substring start end)))
(kill-new (hexify input))
(kill-new (concat "0x" (hexify input)))
(setq deactivate-mark t))))

(global-set-key "\C-ch" 'hexify-region)

0 comments on commit f404d3e

Please sign in to comment.