;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;
(defvar hexl-program "hexl"
- "The program that will hexlify and de-hexlify its stdin.
+ "The program that will hexlify and dehexlify its stdin.
`hexl-program' will always be concatenated with `hexl-options'
-and \"-de\" when dehexlfying a buffer.")
+and \"-de\" when dehexlifying a buffer.")
(defvar hexl-iso ""
"If your emacs can handle ISO characters, this should be set to
(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)))
(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))))
(recenter 0))))
(defun hexl-beginning-of-1k-page ()
- "Goto to beginning of 1k boundry."
+ "Go to beginning of 1k boundary."
(interactive)
(hexl-goto-address (logand (hexl-current-address) -1024)))
(defun hexl-end-of-1k-page ()
- "Goto to end of 1k boundry."
+ "Go to end of 1k boundary."
(interactive)
(hexl-goto-address (let ((address (logior (hexl-current-address) 1023)))
(if (> address hexl-max-address)
address)))
(defun hexl-beginning-of-512b-page ()
- "Goto to beginning of 512 byte boundry."
+ "Go to beginning of 512 byte boundary."
(interactive)
(hexl-goto-address (logand (hexl-current-address) -512)))
(defun hexl-end-of-512b-page ()
- "Goto to end of 512 byte boundry."
+ "Go to end of 512 byte boundary."
(interactive)
(hexl-goto-address (let ((address (logior (hexl-current-address) 511)))
(if (> address hexl-max-address)
;;;###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 ()
(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."