emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

eldoc support in hexl mode


From: Masatake YAMATO
Subject: eldoc support in hexl mode
Date: Mon, 09 Feb 2004 16:27:42 +0900 (JST)

I've written eldoc support in hexl mode.
With my patch, the address of the point in hexl mode buffer
is displayed real time.

Masatake YAMATO

2004-02-09  Masatake YAMATO  <address@hidden>

        * hexl.el (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.

Index: lisp/hexl.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/hexl.el,v
retrieving revision 1.83
diff -u -r1.83 hexl.el
--- lisp/hexl.el        8 Feb 2004 22:36:31 -0000       1.83
+++ lisp/hexl.el        9 Feb 2004 07:17:46 -0000
@@ -42,6 +42,8 @@
 
 ;;; Code:
 
+(require 'eldoc)
+
 ;;
 ;; vars here
 ;;
@@ -236,6 +238,13 @@
 
     (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
 
+    ;; Set a callback function for eldoc.
+    (set (make-variable-buffer-local 'eldoc-print-current-symbol-info-function)
+        'hexl-print-current-point-info)
+    (eldoc-add-command-completions "hexl-")
+    (eldoc-remove-command "hexl-save-buffer" 
+                         "hexl-current-address")
+
     (if hexl-follow-ascii (hexl-follow-ascii 1)))
   (run-hooks 'hexl-mode-hook))
 
@@ -361,8 +370,14 @@
                 (- current-column 41)
               (/ (- current-column  (/ current-column 5)) 2))))
     (when (interactive-p)
-      (message "Current address is %d" hexl-address))
+      (message "Current address is %d/0x%08x" hexl-address hexl-address))
     hexl-address))
+
+(defun hexl-print-current-point-info ()
+  "Return current hexl-address in string.
+This function is indented to be used as eldoc callback."
+  (let ((addr (hexl-current-address)))
+    (format "Current address is %d/0x%08x" addr addr)))
 
 (defun hexl-address-to-marker (address)
   "Return buffer position for ADDRESS."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]