Skip to content

Commit

Permalink
feat(core): add +binary-file-p
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jan 28, 2024
1 parent 5b11206 commit e9fee97
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,15 @@ Returns either nil, or the position of the first null byte."
(goto-char (point-min))
(search-forward (string ?\x00) nil t 1))))

(defun +binary-file-p (file &optional chunk)
"Is FILE a binary?
This checks the first CHUNK of bytes, defaults to 1024."
(with-temp-buffer
(insert-file-contents-literally file nil 0 (or chunk 1024))
(goto-char (point-min))
(search-forward (string ?\x00) nil t 1)))

(defun +binary-hexl-buffer-p (&optional buffer)
"Does BUFFER (defaults to the current buffer) should be viewed using `hexl-mode'."
(and +binary-hexl-enable
Expand Down

0 comments on commit e9fee97

Please sign in to comment.