comparison lisp/hexl.el @ 54275:f4b54db9c8ae

(hexl-mode): Set `hexl-print-current-point-info' as the callback function for eldoc. (hexl-print-current-point-info): New function. (hexl-current-address): print the address in both decimal and hexadecimal format.
author Masatake YAMATO <jet@gyve.org>
date Thu, 04 Mar 2004 18:19:19 +0000
parents 8af44ca54bdf
children 2d1d046af00a
comparison
equal deleted inserted replaced
54274:d41dd3d19ce4 54275:f4b54db9c8ae
39 ;; -iso in `hexl-options' will allow iso characters to display in the 39 ;; -iso in `hexl-options' will allow iso characters to display in the
40 ;; ASCII region of the screen (if your emacs supports this) instead of 40 ;; ASCII region of the screen (if your emacs supports this) instead of
41 ;; changing them to dots. 41 ;; changing them to dots.
42 42
43 ;;; Code: 43 ;;; Code:
44
45 (require 'eldoc)
44 46
45 ;; 47 ;;
46 ;; vars here 48 ;; vars here
47 ;; 49 ;;
48 50
234 ;; Add hooks to rehexlify or dehexlify on various events. 236 ;; Add hooks to rehexlify or dehexlify on various events.
235 (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t) 237 (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t)
236 238
237 (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t) 239 (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
238 240
241 ;; Set a callback function for eldoc.
242 (set (make-variable-buffer-local 'eldoc-print-current-symbol-info-function)
243 'hexl-print-current-point-info)
244 (eldoc-add-command-completions "hexl-")
245 (eldoc-remove-command "hexl-save-buffer"
246 "hexl-current-address")
247
239 (if hexl-follow-ascii (hexl-follow-ascii 1))) 248 (if hexl-follow-ascii (hexl-follow-ascii 1)))
240 (run-hooks 'hexl-mode-hook)) 249 (run-hooks 'hexl-mode-hook))
241 250
242 251
243 (defun hexl-isearch-search-function () 252 (defun hexl-isearch-search-function ()
359 (+ (* (/ (- (point) (point-min) -1) 68) 16) 368 (+ (* (/ (- (point) (point-min) -1) 68) 16)
360 (if (>= current-column 41) 369 (if (>= current-column 41)
361 (- current-column 41) 370 (- current-column 41)
362 (/ (- current-column (/ current-column 5)) 2)))) 371 (/ (- current-column (/ current-column 5)) 2))))
363 (when (interactive-p) 372 (when (interactive-p)
364 (message "Current address is %d" hexl-address)) 373 (message "Current address is %d/0x%08x" hexl-address hexl-address))
365 hexl-address)) 374 hexl-address))
375
376 (defun hexl-print-current-point-info ()
377 "Return current hexl-address in string.
378 This function is indented to be used as eldoc callback."
379 (let ((addr (hexl-current-address)))
380 (format "Current address is %d/0x%08x" addr addr)))
366 381
367 (defun hexl-address-to-marker (address) 382 (defun hexl-address-to-marker (address)
368 "Return buffer position for ADDRESS." 383 "Return buffer position for ADDRESS."
369 (interactive "nAddress: ") 384 (interactive "nAddress: ")
370 (+ (* (/ address 16) 68) 10 (point-min) (/ (* (% address 16) 5) 2))) 385 (+ (* (/ address 16) 68) 10 (point-min) (/ (* (% address 16) 5) 2)))