]> git.eshelyaron.com Git - emacs.git/commitdiff
Make epa-file progress message user-friendly.
authorDaiki Ueno <ueno@unixuser.org>
Fri, 12 Aug 2011 03:30:18 +0000 (12:30 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Fri, 12 Aug 2011 03:30:18 +0000 (12:30 +0900)
* epa.el (epa-progress-callback-function): Fix the logic of
displaying progress.
* epa-file.el (epa-file-insert-file-contents): Make progress
display more user-friendly.
(epa-file-write-region): Ditto.

lisp/ChangeLog
lisp/epa-file.el
lisp/epa.el

index ad300b10f4707a419890d3165ffe828a13991576..27515f767fbeae6cd66ef0bebe38e5be088d1226 100644 (file)
@@ -1,3 +1,11 @@
+2011-08-12  Daiki Ueno  <ueno@unixuser.org>
+
+       * epa.el (epa-progress-callback-function): Fix the logic of
+       displaying progress.
+       * epa-file.el (epa-file-insert-file-contents): Make progress
+       display more user-friendly.
+       (epa-file-write-region): Ditto.
+
 2011-08-10  Chong Yidong  <cyd@stupidchicken.com>
 
        * subr.el (string-mark-left-to-right): New function.
index aa9915d8cfab5eeac7dc74efddb57175c12e6a7a..118f44854cf5c3792a985b8621a7b693574f2501 100644 (file)
@@ -137,8 +137,10 @@ encryption is used."
      context
      (cons #'epa-file-passphrase-callback-function
           local-file))
-    (epg-context-set-progress-callback context
-                                      #'epa-progress-callback-function)
+    (epg-context-set-progress-callback
+     context
+     (cons #'epa-progress-callback-function
+          (format "Decrypting %s" file)))
     (unwind-protect
        (progn
          (if replace
@@ -211,8 +213,10 @@ encryption is used."
      context
      (cons #'epa-file-passphrase-callback-function
           file))
-    (epg-context-set-progress-callback context
-                                      #'epa-progress-callback-function)
+    (epg-context-set-progress-callback
+     context
+     (cons #'epa-progress-callback-function
+          (format "Encrypting %s" file)))
     (epg-context-set-armor context epa-armor)
     (condition-case error
        (setq string
index d4f4fab2eedae25615310250d80e6acfb5603619..e2fafc753d7064b797d7236ac30f834c64eccd38 100644 (file)
@@ -651,10 +651,17 @@ If SECRET is non-nil, list secret keys instead of public keys."
 
 (defun epa-progress-callback-function (_context what _char current total
                                               handback)
-  (message "%s%d%% (%d/%d)" (or handback
-                               (concat what ": "))
-          (if (> total 0) (floor (* (/ current (float total)) 100)) 0)
-          current total))
+  (let ((prompt (or handback
+                   (format "Processing %s: " what))))
+    ;; According to gnupg/doc/DETAIL: a "total" of 0 indicates that
+    ;; the total amount is not known. The condition TOTAL && CUR ==
+    ;; TOTAL may be used to detect the end of an operation.
+    (if (> total 0)
+       (if (= current total)
+           (message "%s...done" prompt)
+         (message "%s...%d%%" prompt
+                  (floor (* (/ current (float total)) 100))))
+      (message "%s..." prompt))))
 
 ;;;###autoload
 (defun epa-decrypt-file (file)