summaryrefslogtreecommitdiff
path: root/lisp/hexl.el
diff options
context:
space:
mode:
authorJim Blandy <jimb@redhat.com>1993-06-24 01:48:59 +0000
committerJim Blandy <jimb@redhat.com>1993-06-24 01:48:59 +0000
commita0be6fb48f70aac892d6b3ae88db0fcb92c9f19a (patch)
tree30d6872fbecb6dedf6d80428bb5d4737b77a8630 /lisp/hexl.el
parentb851a98bbfd3e4d96978ba13b7e07e9ffcf8bf2b (diff)
downloademacs-a0be6fb48f70aac892d6b3ae88db0fcb92c9f19a.tar.gz
(hexl-in-save-buffer): New flag.
(hexl-save-buffer): Prevent infinite recursion.
Diffstat (limited to 'lisp/hexl.el')
-rw-r--r--lisp/hexl.el49
1 files changed, 27 insertions, 22 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el
index e8e5e430937..aa4b5c6214f 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -182,31 +182,36 @@ You can use \\[hexl-find-file] to visit a file in hexl-mode.
(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)