Synch with Gnus.
[elisp/gnus.git-] / lisp / binhex.el
index 9137a0a..1a181a3 100644 (file)
@@ -1,14 +1,11 @@
 ;;; binhex.el -- elisp native binhex decode
-;; Copyright (c) 1998 by Shenghuo Zhu <zsh@cs.rochester.edu>
+;; Copyright (c) 1998 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Create Date: Oct 1, 1998
-;; $Revision: 1.1.2.7 $
-;; Time-stamp: <Tue Oct  6 23:48:38 EDT 1998 zsh>
-;; Keywords: binhex
+;; Keywords: binhex news
 
-;; This file is not part of GNU Emacs, but the same permissions
-;; apply.
+;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (if (not (fboundp 'char-int))
-    (fset 'char-int 'identity))
+    (defalias 'char-int 'identity))
 
 (defvar binhex-decoder-program "hexbin"
   "*Non-nil value should be a string that names a uu decoder.
@@ -68,7 +67,7 @@ input and write the converted data to its standard output.")
        ((boundp 'temporary-file-directory) temporary-file-directory)
        ("/tmp/")))
 
-(if (string-match "XEmacs" emacs-version)
+(if (featurep 'xemacs)
     (defalias 'binhex-insert-char 'insert-char)
   (defun binhex-insert-char (char &optional count ignored buffer)
     (if (or (null buffer) (eq buffer (current-buffer)))
@@ -199,15 +198,8 @@ If HEADER-ONLY is non-nil only decode header and return filename."
        (save-excursion
          (goto-char start)
          (when (re-search-forward binhex-begin-line end t)
-           (if (boundp 'enable-multibyte-characters)
-               (let ((multibyte
-                      (default-value 'enable-multibyte-characters)))
-                 (setq-default enable-multibyte-characters nil)
-                 (setq work-buffer
-                       (generate-new-buffer " *binhex-work*"))
-                 (setq-default enable-multibyte-characters multibyte))
+           (let (default-enable-multibyte-characters)
              (setq work-buffer (generate-new-buffer " *binhex-work*")))
-           (buffer-disable-undo work-buffer)
            (beginning-of-line)
            (setq bits 0 counter 0)
            (while tmp
@@ -251,21 +243,21 @@ If HEADER-ONLY is non-nil only decode header and return filename."
             ((= counter 2)
              (binhex-push-char (logand (lsh bits -10) 255) 1 nil
                                work-buffer))))
-      (if header-only nil
-       (binhex-verify-crc work-buffer
-                          data-fork-start
-                          (+ data-fork-start (aref header 6) 2))
-       (or (markerp end) (setq end (set-marker (make-marker) end)))
-       (goto-char start)
-       (insert-buffer-substring work-buffer
-                                data-fork-start (+ data-fork-start
-                                                   (aref header 6)))
-       (delete-region (point) end)))
+         (if header-only nil
+           (binhex-verify-crc work-buffer
+                              data-fork-start
+                              (+ data-fork-start (aref header 6) 2))
+           (or (markerp end) (setq end (set-marker (make-marker) end)))
+           (goto-char start)
+           (insert-buffer-substring work-buffer
+                                    data-fork-start (+ data-fork-start
+                                                       (aref header 6)))
+           (delete-region (point) end)))
       (and work-buffer (kill-buffer work-buffer)))
     (if header (aref header 1))))
 
 (defun binhex-decode-region-external (start end)
-  "Binhex decode region between START and END using external decoder"
+  "Binhex decode region between START and END using external decoder."
   (interactive "r")
   (let ((cbuf (current-buffer)) firstline work-buffer status
        (file-name (concat binhex-temporary-file-directory