* epg-package-info.el.in (epg-bug-report-address): New constant.
[elisp/epg.git] / epa.el
diff --git a/epa.el b/epa.el
index 6a6b422..8c7305b 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -48,101 +48,124 @@ the separate window."
   "Faces for epa-mode."
   :group 'epa)
 
-(defface epa-validity-high-face
-  '((((class color) (background dark))
-     (:foreground "PaleTurquoise" :bold t))
+(defface epa-validity-high
+  `((((class color) (background dark))
+     (:foreground "PaleTurquoise"
+                 ,@(if (assq ':weight custom-face-attributes)
+                       '(:weight bold)
+                     '(:bold t))))
     (t
-     (:bold t)))
+     (,@(if (assq ':weight custom-face-attributes)
+           '(:weight bold)
+         '(:bold t)))))
   "Face used for displaying the high validity."
   :group 'epa-faces)
-(defvar epa-validity-high-face 'epa-validity-high-face)
 
-(defface epa-validity-medium-face
-  '((((class color) (background dark))
-     (:foreground "PaleTurquoise" :italic t))
+(defface epa-validity-medium
+  `((((class color) (background dark))
+     (:foreground "PaleTurquoise"
+                 ,@(if (assq ':slant custom-face-attributes)
+                       '(:slant italic)
+                     '(:italic t))))
     (t
-     ()))
+     (,@(if (assq ':slant custom-face-attributes)
+           '(:slant italic)
+         '(:italic t)))))
   "Face used for displaying the medium validity."
   :group 'epa-faces)
-(defvar epa-validity-medium-face 'epa-validity-medium-face)
 
-(defface epa-validity-low-face
-  '((t
-     (:italic t)))
+(defface epa-validity-low
+  `((t
+     (,@(if (assq ':slant custom-face-attributes)
+           '(:slant italic)
+         '(:italic t)))))
   "Face used for displaying the low validity."
   :group 'epa-faces)
-(defvar epa-validity-low-face 'epa-validity-low-face)
 
-(defface epa-validity-disabled-face
-  '((t
-     (:italic t :inverse-video t)))
+(defface epa-validity-disabled
+  `((t
+     (,@(if (assq ':slant custom-face-attributes)
+           '(:slant italic)
+         '(:italic t))
+       :inverse-video t)))
   "Face used for displaying the disabled validity."
   :group 'epa-faces)
-(defvar epa-validity-disabled-face 'epa-validity-disabled-face)
 
-(defface epa-string-face
-  '((((class color)
-      (background dark))
+(defface epa-string
+  '((((class color) (background dark))
      (:foreground "lightyellow"))
-    (((class color)
-      (background light))
-     (:foreground "blue4"))
-    (t
-     ()))
+    (((class color) (background light))
+     (:foreground "blue4")))
   "Face used for displaying the string."
   :group 'epa-faces)
-(defvar epa-string-face 'epa-string-face)
 
-(defface epa-mark-face
-  '((((class color) (background dark))
-     (:foreground "orange" :bold t))
+(defface epa-mark
+  `((((class color) (background dark))
+     (:foreground "orange"
+                 ,@(if (assq ':weight custom-face-attributes)
+                       '(:weight bold)
+                     '(:bold t))))
+    (((class color) (background light))
+     (:foreground "red"
+                 ,@(if (assq ':weight custom-face-attributes)
+                       '(:weight bold)
+                     '(:bold t))))
     (t
-     (:foreground "red" :bold t)))
+     (,@(if (assq ':weight custom-face-attributes)
+           '(:weight bold)
+         '(:bold t)))))
   "Face used for displaying the high validity."
   :group 'epa-faces)
-(defvar epa-mark-face 'epa-mark-face)
 
-(defface epa-field-name-face
-  '((((class color) (background dark))
-     (:foreground "PaleTurquoise" :bold t))
-    (t (:bold t)))
+(defface epa-field-name
+  `((((class color) (background dark))
+     (:foreground "PaleTurquoise"
+                 ,@(if (assq ':weight custom-face-attributes)
+                       '(:weight bold)
+                     '(:bold t))))
+    (t
+     (,@(if (assq ':weight custom-face-attributes)
+           '(:weight bold)
+         '(:bold t)))))
   "Face for the name of the attribute field."
   :group 'epa)
-(defvar epa-field-name-face 'epa-field-name-face)
 
-(defface epa-field-body-face
-  '((((class color) (background dark))
-     (:foreground "turquoise" :italic t))
-    (t (:italic t)))
+(defface epa-field-body
+  `((((class color) (background dark))
+     (:foreground "turquoise"
+                 ,@(if (assq ':slant custom-face-attributes)
+                       '(:slant italic)
+                     '(:italic t))))
+    (t
+     (,@(if (assq ':slant custom-face-attributes)
+           '(:slant italic)
+         '(:italic t)))))
   "Face for the body of the attribute field."
   :group 'epa)
-(defvar epa-field-body-face 'epa-field-body-face)
 
 (defcustom epa-validity-face-alist
-  '((unknown . epa-validity-disabled-face)
-    (invalid . epa-validity-disabled-face)
-    (disabled . epa-validity-disabled-face)
-    (revoked . epa-validity-disabled-face)
-    (expired . epa-validity-disabled-face)
-    (none . epa-validity-low-face)
-    (undefined . epa-validity-low-face)
-    (never . epa-validity-low-face)
-    (marginal . epa-validity-medium-face)
-    (full . epa-validity-high-face)
-    (ultimate . epa-validity-high-face))
+  '((unknown . epa-validity-disabled)
+    (invalid . epa-validity-disabled)
+    (disabled . epa-validity-disabled)
+    (revoked . epa-validity-disabled)
+    (expired . epa-validity-disabled)
+    (none . epa-validity-low)
+    (undefined . epa-validity-low)
+    (never . epa-validity-low)
+    (marginal . epa-validity-medium)
+    (full . epa-validity-high)
+    (ultimate . epa-validity-high))
   "An alist mapping validity values to faces."
-  :type 'list
+  :type '(repeat (cons symbol face))
   :group 'epa)
 
-(defcustom epa-font-lock-keywords
+(defvar epa-font-lock-keywords
   '(("^\\*"
-     (0 epa-mark-face))
+     (0 'epa-mark))
     ("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
-     (1 epa-field-name-face)
-     (2 epa-field-body-face)))
-  "Default expressions to addon in epa-mode."
-  :type '(repeat (list string))
-  :group 'epa)
+     (1 'epa-field-name)
+     (2 'epa-field-body)))
+  "Default expressions to addon in epa-mode.")
 
 (defconst epa-pubkey-algorithm-letter-alist
   '((1 . ?R)
@@ -548,13 +571,17 @@ If SECRET is non-nil, list secret keys instead of public keys."
              (cdr (assq (epg-sub-key-algorithm (car pointer))
                         epg-pubkey-algorithm-alist))
              "\n\tCreated: "
-             (format-time-string "%Y-%m-%d"
-                                 (epg-sub-key-creation-time (car pointer)))
+             (condition-case nil
+                 (format-time-string "%Y-%m-%d"
+                                     (epg-sub-key-creation-time (car pointer)))
+               (error "????-??-??"))
              (if (epg-sub-key-expiration-time (car pointer))
                  (format "\n\tExpires: %s"
-                         (format-time-string "%Y-%m-%d"
-                                             (epg-sub-key-expiration-time
-                                              (car pointer))))
+                         (condition-case nil
+                             (format-time-string "%Y-%m-%d"
+                                                 (epg-sub-key-expiration-time
+                                                  (car pointer)))
+                           (error "????-??-??")))
                "")
              "\n\tCapabilities: "
              (mapconcat #'symbol-name
@@ -833,23 +860,28 @@ Don't use this command in Lisp programs!"
     (epg-context-set-progress-callback context
                                       #'epa-progress-callback-function
                                       "Verifying...")
+    (message "Verifying...")
     (setq plain (epg-verify-string
                 context
                 (epa--encode-coding-string
                  (buffer-substring start end)
                  (or coding-system-for-write
-                     (get-text-property start
-                                        'epa-coding-system-used)))))
+                     (get-text-property start 'epa-coding-system-used)))))
+    (message "Verifying...done")
+    (setq plain (epa--decode-coding-string
+                plain
+                (or coding-system-for-read
+                    (get-text-property start 'epa-coding-system-used))))
     (if (y-or-n-p "Replace the original text? ")
        (let ((inhibit-read-only t)
              buffer-read-only)
          (delete-region start end)
          (goto-char start)
          (insert plain))
-       (with-output-to-temp-buffer "*Temp*"
-         (set-buffer standard-output)
-         (insert plain)
-         (epa-info-mode)))
+      (with-output-to-temp-buffer "*Temp*"
+       (set-buffer standard-output)
+       (insert plain)
+       (epa-info-mode)))
     (if (epg-context-result-for context 'verify)
        (epa-display-info (epg-verify-result-to-string
                           (epg-context-result-for context 'verify))))))