comparison lisp/hexl.el @ 4966:82353ffa44b7

(hexl-mode): Use `add-hook' to modify buffer local `write-contents-hooks'. (hexl-mode-exit): Remove our hook when turning off Hexl mode.
author Richard M. Stallman <rms@gnu.org>
date Wed, 10 Nov 1993 20:44:14 +0000
parents ffe273aa038e
children 8abe8fb9621c
comparison
equal deleted inserted replaced
4965:dad86ab54e36 4966:82353ffa44b7
165 (make-local-variable 'hexl-mode-old-major-mode) 165 (make-local-variable 'hexl-mode-old-major-mode)
166 (setq hexl-mode-old-major-mode major-mode) 166 (setq hexl-mode-old-major-mode major-mode)
167 (setq major-mode 'hexl-mode) 167 (setq major-mode 'hexl-mode)
168 168
169 (make-local-variable 'write-contents-hooks) 169 (make-local-variable 'write-contents-hooks)
170 (setq write-contents-hooks 170 (add-hook 'write-contents-hooks 'hexl-save-buffer)
171 (cons 'hexl-save-buffer write-contents-hooks))
172 171
173 (let ((modified (buffer-modified-p)) 172 (let ((modified (buffer-modified-p))
174 (read-only buffer-read-only) 173 (read-only buffer-read-only)
175 (original-point (1- (point)))) 174 (original-point (1- (point))))
176 (if (not (or (eq arg 1) (not arg))) 175 (if (not (or (eq arg 1) (not arg)))
231 (let ((modified (buffer-modified-p)) 230 (let ((modified (buffer-modified-p))
232 (read-only buffer-read-only) 231 (read-only buffer-read-only)
233 (original-point (1+ (hexl-current-address)))) 232 (original-point (1+ (hexl-current-address))))
234 (setq buffer-read-only nil) 233 (setq buffer-read-only nil)
235 (dehexlify-buffer) 234 (dehexlify-buffer)
235 (remove-hook 'write-contents-hook 'hexl-save-buffer)
236 (set-buffer-modified-p modified) 236 (set-buffer-modified-p modified)
237 (setq buffer-read-only read-only) 237 (setq buffer-read-only read-only)
238 (goto-char original-point))) 238 (goto-char original-point)))
239 (setq mode-name hexl-mode-old-mode-name) 239 (setq mode-name hexl-mode-old-mode-name)
240 (use-local-map hexl-mode-old-local-map) 240 (use-local-map hexl-mode-old-local-map)