Bug fix for vc-dispatcher split.
[bpt/emacs.git] / lisp / hexl.el
index f63ed0a..245f895 100644 (file)
@@ -1,7 +1,7 @@
 ;;; hexl.el --- edit a file in a hex dump format using the hexl filter
 
 ;; Copyright (C) 1989, 1994, 1998, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Keith Gabryelski <ag@wheaties.ai.mit.edu>
 ;; Maintainer: FSF
@@ -11,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -120,6 +120,7 @@ Quoting cannot be used, so the arguments cannot themselves contain spaces."
 (defvar hexl-mode-old-require-final-newline)
 (defvar hexl-mode-old-syntax-table)
 (defvar hexl-mode-old-font-lock-keywords)
+(defvar hexl-mode-old-eldoc-documentation-function)
 
 (defvar hexl-ascii-overlay nil
   "Overlay used to highlight ASCII element corresponding to current point.")
@@ -279,7 +280,6 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
 
     (make-local-variable 'hexl-mode-old-font-lock-keywords)
     (setq hexl-mode-old-font-lock-keywords font-lock-defaults)
-    (make-local-variable 'font-lock-defaults)
     (setq font-lock-defaults '(hexl-font-lock-keywords t))
 
     ;; Add hooks to rehexlify or dehexlify on various events.
@@ -289,6 +289,10 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
     (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
 
     ;; Set a callback function for eldoc.
+    (make-local-variable 'hexl-mode-old-eldoc-documentation-function)
+    (setq hexl-mode-old-eldoc-documentation-function
+         (bound-and-true-p eldoc-documentation-function))
+
     (set (make-local-variable 'eldoc-documentation-function)
         'hexl-print-current-point-info)
     (eldoc-add-command-completions "hexl-")
@@ -406,6 +410,10 @@ With arg, don't unhexlify buffer."
   (when (boundp 'hexl-mode-old-hl-line-face)
     (setq hl-line-face hexl-mode-old-hl-line-face))
 
+  (when (boundp 'hexl-mode-old-eldoc-documentation-function)
+    (setq eldoc-documentation-function
+         hexl-mode-old-eldoc-documentation-function))
+
   (setq require-final-newline hexl-mode-old-require-final-newline)
   (setq mode-name hexl-mode-old-mode-name)
   (setq isearch-search-fun-function hexl-mode-old-isearch-search-fun-function)
@@ -457,7 +465,7 @@ This function is intended to be used as eldoc callback."
   (+ (* (/ address 16) 68) 10 (point-min) (/ (* (% address 16) 5) 2)))
 
 (defun hexl-goto-address (address)
-  "Goto hexl-mode (decimal) address ADDRESS.
+  "Go to hexl-mode (decimal) address ADDRESS.
 Signal error if ADDRESS is out of range."
   (interactive "nAddress: ")
   (if (or (< address 0) (> address hexl-max-address))
@@ -1104,6 +1112,43 @@ This function is assumed to be used as callback function for `hl-line-mode'."
   (define-key hexl-mode-map "\C-x\C-s" 'hexl-save-buffer)
   (define-key hexl-mode-map "\C-x\C-t" 'undefined))
 
+(easy-menu-define hexl-menu hexl-mode-map "Hexl Mode menu"
+  `("Hexl"
+    :help "Hexl-specific Features"
+
+    ["Backward short" hexl-backward-short
+     :help "Move to left a short"]
+    ["Forward short" hexl-forward-short
+     :help "Move to right a short"]
+    ["Backward word" hexl-backward-short
+     :help "Move to left a word"]
+    ["Forward word" hexl-forward-short
+     :help "Move to right a word"]
+    "-"
+    ["Beginning of 512b page" hexl-beginning-of-512b-page
+     :help "Go to beginning of 512 byte boundary"]
+    ["End of 512b page" hexl-end-of-512b-page
+     :help "Go to end of 512 byte boundary"]
+    ["Beginning of 1K page" hexl-beginning-of-1k-page
+     :help "Go to beginning of 1KB boundary"]
+    ["End of 1K page" hexl-end-of-1k-page
+     :help "Go to end of 1KB boundary"]
+    "-"
+    ["Go to address" hexl-goto-address
+     :help "Go to hexl-mode (decimal) address"]
+    ["Go to address" hexl-goto-hex-address
+     :help "Go to hexl-mode (hex string) address"]
+    "-"
+    ["Insert decimal char" hexl-insert-decimal-char
+     :help "Insert a character given by its decimal code"]
+    ["Insert hex char" hexl-insert-hex-char
+     :help "Insert a character given by its hexadecimal code"]
+    ["Insert octal char" hexl-insert-octal-char
+     :help "Insert a character given by its octal code"]
+    "-"
+    ["Exit hexl mode" hexl-mode-exit
+     :help "Exit hexl mode returning to previous mode"]))
+
 (provide 'hexl)
 
 ;; arch-tag: d5a7aa8a-9bce-480b-bcff-6c4c7ca5ea4a