changeset 3891:f457e67ddb6b

(hexl-in-save-buffer): New flag. (hexl-save-buffer): Prevent infinite recursion.
author Jim Blandy <jimb@redhat.com>
date Thu, 24 Jun 1993 01:48:59 +0000
parents ab295012a818
children ad7559755428
files lisp/hexl.el
diffstat 1 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/hexl.el	Thu Jun 24 01:34:33 1993 +0000
+++ b/lisp/hexl.el	Thu Jun 24 01:48:59 1993 +0000
@@ -182,31 +182,36 @@
         (setq buffer-read-only read-only)
         (hexl-goto-address original-point)))))
 
+(defvar hexl-in-save-buffer nil)
+
 (defun hexl-save-buffer ()
   "Save a hexl format buffer as binary in visited file if modified."
   (interactive)
-  (set-buffer-modified-p (if (buffer-modified-p)
-			     (save-excursion
-			       (let ((buf (generate-new-buffer " hexl"))
-				     (name (buffer-name))
-				     (file-name (buffer-file-name))
-				     (start (point-min))
-				     (end (point-max))
-				     modified)
-				 (set-buffer buf)
-				 (insert-buffer-substring name start end)
-				 (set-buffer name)
-				 (dehexlify-buffer)
-				 (save-buffer)
-				 (setq modified (buffer-modified-p))
-				 (delete-region (point-min) (point-max))
-				 (insert-buffer-substring buf start end)
-				 (kill-buffer buf)
-				 modified))
-			   (message "(No changes need to be saved)")
-			   nil))
-  ;; Return t to indicate we have saved t
-  t)
+  (if hexl-in-save-buffer nil
+    (set-buffer-modified-p (if (buffer-modified-p)
+			       (save-excursion
+				 (let ((buf (generate-new-buffer " hexl"))
+				       (name (buffer-name))
+				       (file-name (buffer-file-name))
+				       (start (point-min))
+				       (end (point-max))
+				       modified)
+				   (set-buffer buf)
+				   (insert-buffer-substring name start end)
+				   (set-buffer name)
+				   (dehexlify-buffer)
+				   ;; Prevent infinite recursion.
+				   (let ((hexl-in-save-buffer t))
+				     (save-buffer))
+				   (setq modified (buffer-modified-p))
+				   (delete-region (point-min) (point-max))
+				   (insert-buffer-substring buf start end)
+				   (kill-buffer buf)
+				   modified))
+			     (message "(No changes need to be saved)")
+			     nil))
+    ;; Return t to indicate we have saved t
+    t))
 
 ;;;###autoload
 (defun hexl-find-file (filename)