* epg.el (epg-process-filter-running): New variable.
authorueno <ueno>
Tue, 18 Jul 2006 00:56:56 +0000 (00:56 +0000)
committerueno <ueno>
Tue, 18 Jul 2006 00:56:56 +0000 (00:56 +0000)
(epg--start): Setup epg-process-filter-running.
(epg--process-filter): Allow only one status handler to run at a
time.

ChangeLog
epg.el

index 7abc7a8..76da7f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-18  Daiki Ueno  <ueno@unixuser.org>
+
+       * epg.el (epg-process-filter-running): New variable.
+       (epg--start): Setup epg-process-filter-running.
+       (epg--process-filter): Allow only one status handler to run at a
+       time.
+
 2006-07-14  Daiki Ueno  <ueno@unixuser.org>
 
        * epg-pgp50i.el: New file.
diff --git a/epg.el b/epg.el
index 599948f..82d5cb6 100644 (file)
--- a/epg.el
+++ b/epg.el
@@ -48,6 +48,7 @@
   "An alist mapping from key ID to user ID.")
 
 (defvar epg-read-point nil)
+(defvar epg-process-filter-running nil)
 (defvar epg-pending-status-list nil)
 (defvar epg-key-id nil)
 (defvar epg-context nil)
@@ -828,6 +829,8 @@ This function is for internal use only."
     (with-current-buffer buffer
       (make-local-variable 'epg-read-point)
       (setq epg-read-point (point-min))
+      (make-local-variable 'epg-process-filter-running)
+      (setq epg-process-filter-running nil)
       (make-local-variable 'epg-pending-status-list)
       (setq epg-pending-status-list nil)
       (make-local-variable 'epg-key-id)
@@ -860,21 +863,27 @@ This function is for internal use only."
        (set-buffer (process-buffer process))
        (goto-char (point-max))
        (insert input)
-       (goto-char epg-read-point)
-       (beginning-of-line)
-       (while (looking-at ".*\n")      ;the input line finished
-         (save-excursion
-           (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)")
-               (let* ((status (match-string 1))
-                      (string (match-string 2))
-                      (symbol (intern-soft (concat "epg--status-" status))))
-                 (if (member status epg-pending-status-list)
-                     (setq epg-pending-status-list nil))
-                 (if (and symbol
-                          (fboundp symbol))
-                     (funcall symbol epg-context string)))))
-         (forward-line))
-       (setq epg-read-point (point)))))
+       (unless epg-process-filter-running
+         (unwind-protect
+             (progn
+               (setq epg-process-filter-running t)
+               (goto-char epg-read-point)
+               (beginning-of-line)
+               (while (looking-at ".*\n") ;the input line finished
+                 (save-excursion
+                   (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)")
+                       (let* ((status (match-string 1))
+                              (string (match-string 2))
+                              (symbol (intern-soft (concat "epg--status-"
+                                                           status))))
+                         (if (member status epg-pending-status-list)
+                             (setq epg-pending-status-list nil))
+                         (if (and symbol
+                                  (fboundp symbol))
+                             (funcall symbol epg-context string)))))
+                 (forward-line))
+               (setq epg-read-point (point)))
+           (setq epg-process-filter-running nil))))))
 
 (defun epg-read-output (context)
   "Read the output file CONTEXT and return the content as a string."