(toolbar-gnus, get-charset-property, font-lock-set-defaults,
[elisp/gnus.git-] / lisp / gnus-uu.el
index 387d178..aa2e95f 100644 (file)
@@ -32,7 +32,6 @@
 (require 'gnus-art)
 (require 'message)
 (require 'gnus-msg)
-(require 'mm-decode)
 
 (defgroup gnus-extract nil
   "Extracting encoded files."
@@ -58,8 +57,8 @@
   '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
     ("\\.pas$" "cat %s | sed 's/\r$//'")
     ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
-    ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv")
-    ("\\.tga$" "tgatoppm %s | xv -")
+    ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
+    ("\\.tga$" "tgatoppm %s | ee -")
     ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
      "sox -v .5 %s -t .au -u - > /dev/audio")
     ("\\.au$" "cat %s > /dev/audio")
@@ -369,7 +368,8 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
   "k" gnus-summary-kill-process-mark
   "y" gnus-summary-yank-process-mark
   "w" gnus-summary-save-process-mark
-  "i" gnus-uu-invert-processable)
+  "i" gnus-uu-invert-processable
+  "m" gnus-summary-save-parts)
 
 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
   ;;"x" gnus-uu-extract-any
@@ -526,6 +526,7 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
                 (gnus-get-buffer-create " *gnus-uu-forward*")))
       (erase-buffer)
       (insert-file file)
+      (delete-file file)
       (let ((fs gnus-uu-digest-from-subject))
        (when fs
          (setq from (caar fs)
@@ -623,8 +624,9 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
   (interactive)
   (gnus-save-hidden-threads
     (let ((level (gnus-summary-thread-level)))
-      (while (and (gnus-summary-set-process-mark (gnus-summary-article-number))
-                 (zerop (gnus-summary-next-subject 1))
+      (while (and (gnus-summary-set-process-mark
+                  (gnus-summary-article-number))
+                 (zerop (gnus-summary-next-subject 1 nil t))
                  (> (gnus-summary-thread-level) level)))))
   (gnus-summary-position-point))
 
@@ -954,7 +956,8 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
        (beginning-of-line)
        (forward-line 1)
        (when (file-exists-p gnus-uu-binhex-article-name)
-         (append-to-file start-char (point) gnus-uu-binhex-article-name))))
+         (write-region-as-binary start-char (point)
+                                 gnus-uu-binhex-article-name 'append))))
     (if (memq 'begin state)
        (cons gnus-uu-binhex-article-name state)
       state)))
@@ -1207,7 +1210,7 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
        (gnus-inhibit-treatment t)
        has-been-begin article result-file result-files process-state
        gnus-summary-display-article-function
-       gnus-article-prepare-hook
+       gnus-article-display-hook gnus-article-prepare-hook gnus-display-mime-function
        article-series files)
 
     (while (and articles
@@ -1348,9 +1351,12 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
   (when gnus-uu-default-dir
     (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
                           (file-name-nondirectory file))))
-      (rename-file file to-file)
-      (unless (file-exists-p file)
-       (make-symbolic-link to-file file)))))
+      (cond ((fboundp 'make-symbolic-link)
+            (rename-file file to-file)
+            (unless (file-exists-p file)
+              (make-symbolic-link to-file file)))
+           (t
+            (copy-file file to-file))))))
 
 (defun gnus-uu-part-number (article)
   (let* ((header (gnus-summary-article-header article))
@@ -1398,7 +1404,7 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
          ;; We replace certain characters that could make things messy.
          (setq gnus-uu-file-name
                (let ((nnheader-file-name-translation-alist
-                      '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
+                      '((?/ . ?,) (?  . ?_) (?* . ?_) (?$ . ?_))))
                  (nnheader-translate-file-chars (match-string 1))))
           (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
 
@@ -1700,11 +1706,23 @@ didn't work, and overwrite existing files.  Otherwise, ask each time."
     (when (setq buf (get-buffer gnus-uu-output-buffer-name))
       (kill-buffer buf))))
 
+(defun gnus-quote-arg-for-sh-or-csh (arg)
+  (let ((pos 0) new-pos accum)
+    ;; *** bug: we don't handle newline characters properly
+    (while (setq new-pos (string-match "[!`\"$\\& \t{}]" arg pos))
+      (push (substring arg pos new-pos) accum)
+      (push "\\" accum)
+      (push (list (aref arg new-pos)) accum)
+      (setq pos (1+ new-pos)))
+    (if (= pos 0)
+        arg
+      (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))
+
 ;; Inputs an action and a filename and returns a full command, making sure
 ;; that the filename will be treated as a single argument when the shell
 ;; executes the command.
 (defun gnus-uu-command (action file)
-  (let ((quoted-file (mm-quote-arg file)))
+  (let ((quoted-file (gnus-quote-arg-for-sh-or-csh file)))
     (if (string-match "%s" action)
        (format action quoted-file)
       (concat action " " quoted-file))))