* pgg-gpg.el (pgg-gpg-process-region): Fix cleanup form.
authorueno <ueno>
Mon, 21 Feb 2000 15:12:14 +0000 (15:12 +0000)
committerueno <ueno>
Mon, 21 Feb 2000 15:12:14 +0000 (15:12 +0000)
* pgg-pgp.el (pgg-pgp-process-region): Ditto.
* pgg-pgp5.el (pgg-pgp5-process-region): Ditto.

ChangeLog
pgg-gpg.el
pgg-pgp.el
pgg-pgp5.el

index 3388ba5..0b58de0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2000-02-21   Daiki Ueno  <ueno@ueda.info.waseda.ac.jp>
 
+       * pgg-gpg.el (pgg-gpg-process-region): Fix cleanup form.
+
+       * pgg-pgp.el (pgg-pgp-process-region): Ditto.
+
+       * pgg-pgp5.el (pgg-pgp5-process-region): Ditto.
+
        * semi-setup.el (mime-setup-enable-inline-image): Remove checking
        of bitmap-mule; use `eval-after-load' instead of
        `call-after-loaded' to require `mime-image'.
index aa4b50c..0a715db 100644 (file)
@@ -91,42 +91,46 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
     (with-current-buffer (get-buffer-create output-buffer)
       (buffer-disable-undo)
       (erase-buffer))
-    (as-binary-process
-     (setq process
-          (apply #'start-process-shell-command "*GnuPG*" output-buffer
-                 program args)))
-    (set-process-sentinel process #'ignore)
-    (when passphrase
-      (process-send-string process (concat passphrase "\n")))
-    (process-send-region process start end)
-    (process-send-eof process)
-    (while (eq 'run (process-status process))
-      (accept-process-output process 5))
-    (setq status (process-status process)
-         exit-status (process-exit-status process))
-    (delete-process process)
-    (with-current-buffer output-buffer
-      (pgg-convert-lbt-region (point-min)(point-max) 'LF)
+    (unwind-protect
+       (progn
+         (as-binary-process
+          (setq process
+                (apply #'start-process-shell-command "*GnuPG*" output-buffer
+                       program args)))
+         (set-process-sentinel process #'ignore)
+         (when passphrase
+           (process-send-string process (concat passphrase "\n")))
+         (process-send-region process start end)
+         (process-send-eof process)
+         (while (eq 'run (process-status process))
+           (accept-process-output process 5))
+         (setq status (process-status process)
+               exit-status (process-exit-status process))
+         (delete-process process)
+         (with-current-buffer output-buffer
+           (pgg-convert-lbt-region (point-min)(point-max) 'LF)
 
-      (if (memq status '(stop signal))
-         (error "%s exited abnormally: '%s'" program exit-status))
-      (if (= 127 exit-status)
-         (error "%s could not be found" program))
+           (if (memq status '(stop signal))
+               (error "%s exited abnormally: '%s'" program exit-status))
+           (if (= 127 exit-status)
+               (error "%s could not be found" program))
 
-      (set-buffer (get-buffer-create errors-buffer))
-      (buffer-disable-undo)
-      (erase-buffer)
-      (insert-file-contents errors-file-name)
-      (delete-file errors-file-name)
+           (set-buffer (get-buffer-create errors-buffer))
+           (buffer-disable-undo)
+           (erase-buffer)
+           (insert-file-contents errors-file-name)
       
-      (set-buffer (get-buffer-create status-buffer))
-      (buffer-disable-undo)
-      (erase-buffer)
-      (insert-file-contents status-file-name)
-      (delete-file status-file-name)
-
+           (set-buffer (get-buffer-create status-buffer))
+           (buffer-disable-undo)
+           (erase-buffer)
+           (insert-file-contents status-file-name)))
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process)))))
+         (interrupt-process process))
+      (condition-case nil
+         (progn
+           (delete-file status-file-name)
+           (delete-file errors-file-name))
+       (file-error nil)))))
 
 (luna-define-method pgg-scheme-lookup-key ((scheme pgg-scheme-gpg)
                                           string &optional type)
index f407bde..4b033e5 100644 (file)
@@ -85,36 +85,39 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
       (erase-buffer))
     (when passphrase
       (setenv "PGPPASSFD" "0"))
-    (as-binary-process
-     (setq process
-          (apply #'start-process-shell-command "*PGP*" output-buffer
-                 program args)))
-    (set-process-sentinel process #'ignore)
-    (when passphrase
-      (process-send-string process (concat passphrase "\n")))
-    (process-send-region process start end)
-    (process-send-eof process)
-    (while (eq 'run (process-status process))
-      (accept-process-output process 5))
-    (setq status (process-status process)
-         exit-status (process-exit-status process))
-    (delete-process process)
-    (with-current-buffer output-buffer
-      (pgg-convert-lbt-region (point-min)(point-max) 'LF)
-
-      (if (memq status '(stop signal))
-         (error "%s exited abnormally: '%s'" program exit-status))
-      (if (= 127 exit-status)
-         (error "%s could not be found" program))
-
-      (set-buffer (get-buffer-create errors-buffer))
-      (buffer-disable-undo)
-      (erase-buffer)
-      (insert-file-contents errors-file-name)
-      (delete-file errors-file-name)
-      
+    (unwind-protect
+       (progn
+         (as-binary-process
+          (setq process
+                (apply #'start-process-shell-command "*PGP*" output-buffer
+                       program args)))
+         (set-process-sentinel process #'ignore)
+         (when passphrase
+           (process-send-string process (concat passphrase "\n")))
+         (process-send-region process start end)
+         (process-send-eof process)
+         (while (eq 'run (process-status process))
+           (accept-process-output process 5))
+         (setq status (process-status process)
+               exit-status (process-exit-status process))
+         (delete-process process)
+         (with-current-buffer output-buffer
+           (pgg-convert-lbt-region (point-min)(point-max) 'LF)
+
+           (if (memq status '(stop signal))
+               (error "%s exited abnormally: '%s'" program exit-status))
+           (if (= 127 exit-status)
+               (error "%s could not be found" program))
+
+           (set-buffer (get-buffer-create errors-buffer))
+           (buffer-disable-undo)
+           (erase-buffer)
+           (insert-file-contents errors-file-name)))
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process)))))
+         (interrupt-process process))
+      (condition-case nil
+         (delete-file errors-file-name)
+       (file-error nil)))))
 
 (luna-define-method pgg-scheme-lookup-key ((scheme pgg-scheme-pgp)
                                                  string &optional type)
index 89aeda9..cde2b6f 100644 (file)
@@ -100,36 +100,39 @@ Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
       (erase-buffer))
     (when passphrase
       (setenv "PGPPASSFD" "0"))
-    (as-binary-process
-     (setq process
-          (apply #'start-process-shell-command "*PGP*" output-buffer
-                 program args)))
-    (set-process-sentinel process #'ignore)
-    (when passphrase
-      (process-send-string process (concat passphrase "\n")))
-    (process-send-region process start end)
-    (process-send-eof process)
-    (while (eq 'run (process-status process))
-      (accept-process-output process 5))
-    (setq status (process-status process)
-         exit-status (process-exit-status process))
-    (delete-process process)
-    (with-current-buffer output-buffer
-      (pgg-convert-lbt-region (point-min)(point-max) 'LF)
-
-      (if (memq status '(stop signal))
-         (error "%s exited abnormally: '%s'" program exit-status))
-      (if (= 127 exit-status)
-         (error "%s could not be found" program))
-
-      (set-buffer (get-buffer-create errors-buffer))
-      (buffer-disable-undo)
-      (erase-buffer)
-      (insert-file-contents errors-file-name)
-      (delete-file errors-file-name)
-      
+    (unwind-protect
+       (progn
+         (as-binary-process
+          (setq process
+                (apply #'start-process-shell-command "*PGP*" output-buffer
+                       program args)))
+         (set-process-sentinel process #'ignore)
+         (when passphrase
+           (process-send-string process (concat passphrase "\n")))
+         (process-send-region process start end)
+         (process-send-eof process)
+         (while (eq 'run (process-status process))
+           (accept-process-output process 5))
+         (setq status (process-status process)
+               exit-status (process-exit-status process))
+         (delete-process process)
+         (with-current-buffer output-buffer
+           (pgg-convert-lbt-region (point-min)(point-max) 'LF)
+
+           (if (memq status '(stop signal))
+               (error "%s exited abnormally: '%s'" program exit-status))
+           (if (= 127 exit-status)
+               (error "%s could not be found" program))
+
+           (set-buffer (get-buffer-create errors-buffer))
+           (buffer-disable-undo)
+           (erase-buffer)
+           (insert-file-contents errors-file-name)))
       (if (and process (eq 'run (process-status process)))
-         (interrupt-process process)))))
+         (interrupt-process process))
+      (condition-case nil
+         (delete-file errors-file-name)
+       (file-error nil)))))
 
 (luna-define-method pgg-scheme-lookup-key ((scheme pgg-scheme-pgp5)
                                                  string &optional type)