5

If you know the file extensions are working with, the best solution is to just use the auto-mode-alist to startup hexl-mode. If not, and you take what you have said literally: It's probably sufficient to define "binary" as "contains a null byte" You can do this by adding a function that turns on hexl-mode if a file contain a null byte to the find-file-...


4

You can simply run M-x eval-expression and type ?O. You will get the following output in the minibuffer: 79 (#o117, #x4f, ?O)


4

I think the most simple answer is "no, there is no way to make hexl-mode do that". Mostly because hexl-mode is by nature very limited in what it can and can't do (or more specifically, to let it do other things, you'd have to change it substantially). I'm not sure what you mean by "display hex values as floats", but if you mean "take 4-byte chunks and ...


3

I recomend you try nhexl-mode (install it from M-x package-install or M-x package-list). It does do what you want. This said, hexl-mode almost does what you want, since it places the cursor right in front of the byte you want highlighted.


3

This answer doesn't really involve emacs per se, but you can use the Unix or GNU od command to solve your problem. In particular, od -f is probably what you are looking for regarding floats and od -t fD will format doubles. You could always use M-! to get the command output into a buffer if you really need it inside of emacs. ;)


3

That sounds like a missing feature in vlf-mode, and quite possibly some missing customization in hexl-mode. The way hexl-mode works if by running the hexl program (shipped with Emacs, see hexl-program), and displaying the output. This output already contains the offsets, they're just made non-editable. So, vlf-mode should add vlf-start-pos to all of those. ...


2

Here's my own function. It seems to do the trick. (defun hexl-hex-forward-char (hex-offset) "Move to right HEX-OFFSET bytes (left if negative) in Hexl mode." (interactive "sHex Offset: ") (hexl-goto-address (+ (hexl-current-address) (hexl-hex-string-to-integer hex-offset)))) And the following overwrites the key binding for hexl-forward-word ...


2

Change the user option hexl-bits from 16 (2 bytes) to 8 (1 byte): (setq hexl-bits 8) Or any other better hex edit package available for emacs? Maybe https://elpa.gnu.org/packages/nhexl-mode.html


2

If you use nhexl-mode (available from your neighborly GNU ELPA archive), then you can do C-s f9beb4d9 and it will search for the sequence of 4 bytes with codes f9 be b4 d9 (as well as for the 8 bytes text f9beb4d9 of course, and also the bytes at addresses that include f9beb4d9 in their hex representation).


2

The following lisp code puts an entry "Hexl Isearch Mode" into the "Hexl" menu. That menu item (de-)activates the minor mode hexl-isearch-mode. If you activate that mode isearch searches in the binary data instead of the hexl buffer. The search string is read with read. So all escape sequences for lisp strings do work. As an example you can search for \x0a\...


2

One simple way to hide the ascii-part of the hexl buffer is customizing the foreground of the face hexl-ascii-region to the background value (e.g., white). For using this method make sure that font-lock-mode is active in the hexl-mode. It may be that you need (add-hook 'hexl-mode-hook #'font-lock-mode) in your init-file.


1

I don't see such an option in hexl.el, no. You can do that in nhexl-mode, OTOH: just set the nhexl-line-width variable accordingly (or set it to t which lets it adjust to your window width).


1

Maybe no so elegant but should do the trick. Note I have assigned it to "C-." which might be used by other functions in your setup. Reassign as you wish: (defun hexify() (interactive) (setq hx (format "%x" (char-before))) (delete-backward-char 1) (insert hx)) (global-set-key (kbd "C-.") 'hexify) Calling the function, replaces the character before ...


1

The upcoming nhexl-mode-1.0 (in GNU ELPA) changes C-u so it takes hexadecimal input. IOW C-u 10 C-f will advance by 16 chars instead of 10.


1

The following call to emacs inserts the hexadecimal number \x0b at character position 10 of the files 1st.bin and 2nd.bin. emacs --batch --eval '(dolist (file-name (list "1st.bin" "2nd.bin")) (find-file-literally file-name) (goto-char 10) (insert "\x0b") (save-buffer 0) (kill-buffer))'


1

I implemented such a variant of overwrite-mode as part of nhexl-mode-0.4 (available from GNU ELPA), which I called nhexl-overwrite-only-mode. It also works in "normal" editing modes (i.e. outside of nhexl-mode) but it won't work for hexl-mode, I'm afraid.


1

You could try something like (guaranteed 100% untested): (defvar hexl-hex-insert-mode-map (let ((map (make-sparse-keymap))) (mapc (lambda (c) (define-key map (vector c) 'hexl-hex-self-insert)) "0123456789abcdef") map)) (defvar hexl-hex--last-char nil) (defun hexl-hex-self-insert () (interactive) "Self-insert \"nibble\"."...


1

The following elisp code defines a new minor mode hexl-bin-mode that replaces the ascii-region with spaces. That should avoid side-effects caused by faces as they may appear in my first answer. You can switch on the binary hexl mode by M-x hexl-bin-mode or bind the command hexl-bin-mode to any key you want with local-set-key in hexl-mode-hook. (require '...


Only top voted, non community-wiki answers of a minimum length are eligible