@@ -765,29 +765,8 @@ the children of class at point."
765
765
766
766
; ;; Binary files tweaks
767
767
768
- ;;;### autoload
769
- (defun +binary-objdump-p (filename)
770
- " Can FILENAME be recognized by \" objdump\" ."
771
- (when-let* ((file (and filename (file-truename filename))))
772
- (and +binary-objdump-executable
773
- (executable-find +binary-objdump-executable)
774
- (not (file-remote-p file))
775
- (file-exists-p file)
776
- (not (file-directory-p file))
777
- (not (zerop (file-attribute-size (file-attributes file))))
778
- (not (string-match-p " file format not recognized"
779
- (shell-command-to-string
780
- (format " %s --file-headers %s "
781
- +binary-objdump-executable
782
- (shell-quote-argument file))))))))
783
-
784
- ;;;### autoload
785
- (defun +binary-objdump-buffer-p (&optional buffer)
786
- " Can the BUFFER be viewed as a disassembled code with objdump."
787
- (and +binary-objdump-enable (+binary-objdump-p (buffer-file-name buffer))))
788
-
789
768
; ; A predicate for detecting binary files. Inspired by:
790
- ; ; emacs.stackexchange.com/q/10277/37002)
769
+ ; ; emacs.stackexchange.com/q/10277/37002
791
770
;;;### autoload
792
771
(defun +binary-buffer-p (&optional buffer)
793
772
" Return whether BUFFER or the current buffer is binary.
@@ -807,39 +786,16 @@ Returns either nil, or the position of the first null byte."
807
786
This checks the first CHUNK of bytes, defaults to 1024."
808
787
(with-temp-buffer
809
788
(insert-file-contents-literally file nil 0 (or chunk 1024 ))
810
- (goto-char (point-min ))
811
- (search-forward (string ?\x00 ) nil t 1 )))
789
+ (+binary-buffer-p)))
812
790
813
791
;;;### autoload
814
792
(defun +binary-hexl-buffer-p (&optional buffer)
815
793
" Does BUFFER (defaults to the current buffer) should be viewed using `hexl-mode' ."
816
794
(and +binary-hexl-enable
817
795
(+binary-buffer-p buffer)
818
- ; ; Executables are viewed with objdump mode
819
- (not (+binary-objdump-buffer-p buffer))))
820
-
821
- ;;;### autoload
822
- (define-derived-mode objdump-disassemble-mode
823
- special-mode " Objdump Mode"
824
- " Major mode for viewing executable files disassembled using objdump."
825
- (if-let* ((file (buffer-file-name ))
826
- (objdump-file (+binary-objdump-p file)))
827
- (let ((buffer-read-only nil ))
828
- (message " Disassembling %S using objdump. " (file-name-nondirectory file))
829
- (erase-buffer )
830
- (set-visited-file-name (file-name-with-extension file " _dias.objdump" ))
831
- (call-process " objdump" nil (current-buffer ) nil " -d" file)
832
- (goto-char (point-min ))
833
- (buffer-disable-undo )
834
- (set-buffer-modified-p nil )
835
- (view-mode 1 )
836
- (read-only-mode 1 )
837
- ; ; Apply syntax highlighting from `asm-mode'
838
- (require 'asm-mode )
839
- (set-syntax-table (make-syntax-table asm-mode-syntax-table))
840
- (modify-syntax-entry ?# " < b" ) ; use # for comments
841
- (setq-local font-lock-defaults '(asm-font-lock-keywords)))
842
- (user-error " Objdump can not be used with this buffer" )))
796
+ (not (and (fboundp 'objdump-recognizable-buffer-p )
797
+ ; ; Executables are viewed with objdump mode
798
+ (objdump-recognizable-buffer-p buffer)))))
843
799
844
800
;;;### autoload
845
801
(defun +binary-hexl-mode-maybe ()
0 commit comments