This package implements a minor mode named hexl-inspect-mode
to be used in
conjunction with a buffer set to hexl-mode
. When activated, the minor mode will
create a data inspection buffer, window, and display to the side of the
hexl-mode
buffer. As the point moves around in the parent buffer, the contents
will update to reflect the point’s position.
The mode depends on the variable state of hexl-inspect--big-endian-p
which
determines how the data under the point is to be interpreted.
The automated update structure and the mode structure was patterned after the
explore mode in treesit-explore-mode
in treesit.el
as that was the closest
analog to what I was attempting to accomplish.
This package is not available on any package site as of yet, however may be
cloned and loaded with the following code (and alter the load-path
as needed to
match your local directories.)
(use-package hexl-inspect
:load-path "~/.emacs.d/site-lisp/hexl-inspect")
There’s currently only one keybind associated with the minor mode.
Keybind | Function |
C-c h | Toggles the endianness of the data inspection. |
It may be useful to add a keybind to hexl-mode
to activate the data inspection.
(add-hook 'hexl-mode-hook
(lambda () (define-key hexl-mode-map (kbd "C-c i") 'hexl-inspect-mode)))
It should be as easy as activating the mode and moving the point around. A buffer
will appear alongside the hexl-mode
buffer with the following contents (as a sample).
The endian mode will change when toggled via C-c h
.
-------------------- Data Inspection ------------------- -------------------- Little endian ------------------- Byte (Hex): 0x48 Byte (Binary): 0b01001000 uint8: 72 int8: 72 char: H 16-bit word (Hex): 0x4348 16-bit word (Binary): 0b0100001101001000 uint16: 17224 int16: 17224 chars: CH 32-bit word (Hex): 0x43594348 32-bit word (Binary): 0b01000011010110010100001101001000 uint32: 1129923400 int32: 1129923400 chars: CYCH 64-bit word (Hex): 0x000f424143594348 uint64: 4294972720890696 int64: 4294972720890696 --------------------------------------------------------
At the moment, this suits my needs fairly well. I suspect before it’s released for general consumption some additional safety measures may need to be added. It’s also not wildly aesthetically appealing so that might be something to think about. I welcome suggestions on how to improve the module.
Current things to address:
- [X] Does not compile cleanly. Investigate compilation and address warnings/errors
- [ ] Implement more customizable parameters (timer, output products, etc.)
- [ ] Create keybind to bring the buffer back after a user hits
q
. - [ ] Possibly create a keybind for dismissing the buffer like
q
because the point is actually in the parent buffer for operations. - [X] Detect when the point was placed on the second nibble of an address and account for that when performing the character acquisition (foolproofing)
I deeply appreciate the aid rendered by /u/artherno1
on the Emacs subreddit in
discussing the intricaties of string and buffer manipulation in Elisp.