]> code.delx.au - gnu-emacs/blobdiff - lisp/hexl.el
(mail-abbrev-expand-hook): Disable abbrev mode temporarily while working,
[gnu-emacs] / lisp / hexl.el
index 358b1f2ff39374edf3a0703ac4bac2142841c648..d804d5b514f2b9d8c7a5fe6942eab97eb4918d5b 100644 (file)
@@ -269,7 +269,7 @@ With arg, don't unhexlify buffer."
            (inhibit-read-only t)
            (original-point (1+ (hexl-current-address))))
        (dehexlify-buffer)
-       (remove-hook 'write-contents-hook 'hexl-save-buffer)
+       (remove-hook 'write-contents-hooks 'hexl-save-buffer)
        (set-buffer-modified-p modified)
        (goto-char original-point)))
 
@@ -292,7 +292,7 @@ Ask the user for confirmation."
            (inhibit-read-only t)
            (original-point (1+ (hexl-current-address))))
        (dehexlify-buffer)
-       (remove-hook 'write-contents-hook 'hexl-save-buffer)
+       (remove-hook 'write-contents-hooks 'hexl-save-buffer)
        (set-buffer-modified-p modified)
        (goto-char original-point))))
 
@@ -554,17 +554,29 @@ You may also type up to 3 octal digits, to insert a character with that code"
 
 ;;;###autoload
 (defun hexlify-buffer ()
-  "Convert a binary buffer to hexl format."
+  "Convert a binary buffer to hexl format.
+This discards the buffer's undo information."
   (interactive)
+  (and buffer-undo-list
+       (or (y-or-n-p "Converting to hexl format discards undo info; ok? ")
+          (error "Aborted")))
+  (setq buffer-undo-list nil)
   (let ((binary-process-output nil) ; for Ms-Dos
-       (binary-process-input t))
+       (binary-process-input t)
+       (buffer-undo-list t))
     (shell-command-on-region (point-min) (point-max) hexlify-command t)))
 
 (defun dehexlify-buffer ()
-  "Convert a hexl format buffer to binary."
+  "Convert a hexl format buffer to binary.
+This discards the buffer's undo information."
   (interactive)
+  (and buffer-undo-list
+       (or (y-or-n-p "Converting from hexl format discards undo info; ok? ")
+          (error "Aborted")))
+  (setq buffer-undo-list nil)
   (let ((binary-process-output t) ; for Ms-Dos
-       (binary-process-input nil))
+       (binary-process-input nil)
+       (buffer-undo-list t))
     (shell-command-on-region (point-min) (point-max) dehexlify-command t)))
 
 (defun hexl-char-after-point ()
@@ -584,13 +596,13 @@ You may also type up to 3 octal digits, to insert a character with that code"
     (let ((ch (logior character 32)))
       (if (and (>= ch ?a) (<= ch ?f))
          (- ch (- ?a 10))
-       (error (format "Invalid hex digit `%c'." ch))))))
+       (error "Invalid hex digit `%c'." ch)))))
 
 (defun hexl-oct-char-to-integer (character)
   "Take a char and return its value as if it was a octal digit."
   (if (and (>= character ?0) (<= character ?7))
       (- character ?0)
-    (error (format "Invalid octal digit `%c'." character))))
+    (error "Invalid octal digit `%c'." character)))
 
 (defun hexl-printable-character (ch)
   "Return a displayable string for character CH."