Mercurial > emacs
comparison lisp/hexl.el @ 209:f501afd0a375
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 06 Mar 1991 18:33:25 +0000 |
parents | 0fa7fc093c4e |
children | 08eb386dd0f3 |
comparison
equal
deleted
inserted
replaced
208:0fa7fc093c4e | 209:f501afd0a375 |
---|---|
193 (message "(No changes need to be saved)") | 193 (message "(No changes need to be saved)") |
194 nil))) | 194 nil))) |
195 | 195 |
196 (defun hexl-find-file (filename) | 196 (defun hexl-find-file (filename) |
197 "Edit file FILENAME in hexl-mode. | 197 "Edit file FILENAME in hexl-mode. |
198 | |
199 Switch to a buffer visiting file FILENAME, creating one in none exists." | 198 Switch to a buffer visiting file FILENAME, creating one in none exists." |
200 (interactive "fFilename: ") | 199 (interactive "fFilename: ") |
201 (find-file filename) | 200 (find-file filename) |
202 (if (not (eq major-mode 'hexl-mode)) | 201 (if (not (eq major-mode 'hexl-mode)) |
203 (hexl-mode))) | 202 (hexl-mode))) |
244 (if (or (< address 0) (> address hexl-max-address)) | 243 (if (or (< address 0) (> address hexl-max-address)) |
245 (error "Out of hexl region.")) | 244 (error "Out of hexl region.")) |
246 (goto-char (hexl-address-to-marker address))) | 245 (goto-char (hexl-address-to-marker address))) |
247 | 246 |
248 (defun hexl-goto-hex-address (hex-address) | 247 (defun hexl-goto-hex-address (hex-address) |
249 "Goto hexl-mode address (hex string) HEX-ADDRESS. | 248 "Go to hexl-mode address (hex string) HEX-ADDRESS. |
250 | 249 |
251 Signal error if HEX-ADDRESS is out of range." | 250 Signal error if HEX-ADDRESS is out of range." |
252 (interactive "sHex Address: ") | 251 (interactive "sHex Address: ") |
253 (hexl-goto-address (hexl-hex-string-to-integer hex-address))) | 252 (hexl-goto-address (hexl-hex-string-to-integer hex-address))) |
254 | 253 |
362 "Move right ARG words (left if ARG negative) in hexl-mode." | 361 "Move right ARG words (left if ARG negative) in hexl-mode." |
363 (interactive "p") | 362 (interactive "p") |
364 (hexl-backward-word (- arg))) | 363 (hexl-backward-word (- arg))) |
365 | 364 |
366 (defun hexl-previous-line (arg) | 365 (defun hexl-previous-line (arg) |
367 "Move vertically up ARG lines [16 bytes] (down if ARG negative) in | 366 "Move vertically up ARG lines [16 bytes] (down if ARG negative) in hexl-mode. |
368 hexl-mode. | 367 If there is byte at the target address move to the last byte in that line." |
369 | |
370 If there is byte at the target address move to the last byte in that | |
371 line." | |
372 (interactive "p") | 368 (interactive "p") |
373 (hexl-next-line (- arg))) | 369 (hexl-next-line (- arg))) |
374 | 370 |
375 (defun hexl-next-line (arg) | 371 (defun hexl-next-line (arg) |
376 "Move vertically down ARG lines [16 bytes] (up if ARG negative) in | 372 "Move vertically down ARG lines [16 bytes] (up if ARG negative) in hexl-mode. |
377 hexl-mode. | 373 If there is no byte at the target address move to the last byte in that line." |
378 | |
379 If there is no byte at the target address move to the last byte in that | |
380 line." | |
381 (interactive "p") | 374 (interactive "p") |
382 (hexl-goto-address (let ((address (+ (hexl-current-address) (* arg 16)) t)) | 375 (hexl-goto-address (let ((address (+ (hexl-current-address) (* arg 16)) t)) |
383 (if (and (< arg 0) (< address 0)) | 376 (if (and (< arg 0) (< address 0)) |
384 (progn (message "Out of hexl region.") | 377 (progn (message "Out of hexl region.") |
385 (setq address | 378 (setq address |
394 (+ (logand hexl-max-address -16) | 387 (+ (logand hexl-max-address -16) |
395 (% (hexl-current-address) 16))))))) | 388 (% (hexl-current-address) 16))))))) |
396 address))) | 389 address))) |
397 | 390 |
398 (defun hexl-beginning-of-buffer (arg) | 391 (defun hexl-beginning-of-buffer (arg) |
399 "Move to the beginning of the hexl buffer; leave hexl-mark at previous | 392 "Move to the beginning of the hexl buffer. |
400 posistion. | 393 Leaves `hexl-mark' at previous position. |
401 | 394 With prefix arg N, puts point N bytes of the way from the true beginning." |
402 With arg N, put point N bytes of the way from the true beginning." | |
403 (interactive "p") | 395 (interactive "p") |
404 (push-mark (point)) | 396 (push-mark (point)) |
405 (hexl-goto-address (+ 0 (1- arg)))) | 397 (hexl-goto-address (+ 0 (1- arg)))) |
406 | 398 |
407 (defun hexl-end-of-buffer (arg) | 399 (defun hexl-end-of-buffer (arg) |
408 "Goto hexl-max-address minus ARG." | 400 "Go to `hexl-max-address' minus ARG." |
409 (interactive "p") | 401 (interactive "p") |
410 (push-mark (point)) | 402 (push-mark (point)) |
411 (hexl-goto-address (- hexl-max-address (1- arg)))) | 403 (hexl-goto-address (- hexl-max-address (1- arg)))) |
412 | 404 |
413 (defun hexl-beginning-of-line () | 405 (defun hexl-beginning-of-line () |
628 (define-key hexl-mode-map "\e\C-u" 'undefined) | 620 (define-key hexl-mode-map "\e\C-u" 'undefined) |
629 | 621 |
630 (define-key hexl-mode-map "\e\C-w" 'undefined) | 622 (define-key hexl-mode-map "\e\C-w" 'undefined) |
631 (define-key hexl-mode-map "\e\C-x" 'hexl-insert-hex-char) | 623 (define-key hexl-mode-map "\e\C-x" 'hexl-insert-hex-char) |
632 (define-key hexl-mode-map "\e\C-y" 'undefined) | 624 (define-key hexl-mode-map "\e\C-y" 'undefined) |
633 | |
634 | 625 |
635 (define-key hexl-mode-map "\ea" 'hexl-beginning-of-1k-page) | 626 (define-key hexl-mode-map "\ea" 'hexl-beginning-of-1k-page) |
636 (define-key hexl-mode-map "\eb" 'hexl-backward-word) | 627 (define-key hexl-mode-map "\eb" 'hexl-backward-word) |
637 (define-key hexl-mode-map "\ec" 'undefined) | 628 (define-key hexl-mode-map "\ec" 'undefined) |
638 (define-key hexl-mode-map "\ed" 'undefined) | 629 (define-key hexl-mode-map "\ed" 'undefined) |