Check empty validity.
authorueno <ueno>
Mon, 17 Apr 2006 09:28:51 +0000 (09:28 +0000)
committerueno <ueno>
Mon, 17 Apr 2006 09:28:51 +0000 (09:28 +0000)
epa.el
epg.el

diff --git a/epa.el b/epa.el
index 49ddd4a..75b8934 100644 (file)
--- a/epa.el
+++ b/epa.el
     (?n . epa-validity-low-face)
     (?m . epa-validity-medium-face)
     (?f . epa-validity-high-face)
-    (?u . epa-validity-high-face))
+    (?u . epa-validity-high-face)
+    (?  . epa-validity-high-face))
   "An alist mapping marks on epa-keys-buffer to faces."
   :type 'list
   :group 'epa)
 
 (defcustom epa-font-lock-keywords
-  '(("^[* ]\\(\\([oidreqnmfu-]\\) .*\\)"
+  '(("^[* ]\\(\\([oidreqnmfu -]\\) .*\\)"
      (1 (cdr (assq (aref (match-string 2) 0)
                   epa-validity-face-alist))))
     ("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
 (defvar epa-keys-buffer nil)
 (defvar epa-key-buffer-alist nil)
 (defvar epa-key nil)
+(defvar epa-customize-buffer nil)
 
 (defvar epa-keys-mode-map
   (let ((keymap (make-sparse-keymap)))
     (setq epa-keys-buffer (generate-new-buffer "*Keys*")))
   (set-buffer epa-keys-buffer)
   (erase-buffer)
-  (epa-list-keys-1 name)
+  (epa-list-keys-1 name nil)
   (epa-keys-mode)
   (goto-char (point-min))
   (pop-to-buffer (current-buffer)))
 
-(defun epa-list-keys-1 (name)
+(defun epa-list-keys-1 (name mode)
   (let ((inhibit-read-only t)
        buffer-read-only
        keys point primary-sub-key primary-user-id)
-    (setq keys (epg-list-keys name))
+    (setq keys (epg-list-keys name mode))
     (while keys
       (setq point (point)
            primary-sub-key (car (epg-key-sub-key-list (car keys)))
       (if names
          (while names
            (setq point (point))
-           (epa-list-keys-1 (car names))
+           (epa-list-keys-1 (car names) nil)
            (goto-char point)
            (epa-mark)
            (goto-char (point-max))
            (setq names (cdr names)))
-       (epa-list-keys-1 nil))
+       (epa-list-keys-1 nil nil))
       (epa-keys-mode)
       (goto-char (point-min))
       (pop-to-buffer (current-buffer))
              (epg-sub-key-creation-time (car pointer))
              (if (epg-sub-key-expiration-time (car pointer))
                  (format "\n\tExpires: %s" (epg-sub-key-expiration-time
-                                                 (car pointer)))
+                                            (car pointer)))
                "")
              "\n\tCapabilities: "
              (mapconcat #'symbol-name
@@ -418,6 +420,53 @@ If no one is selected, symmetric encryption will be performed.  "))))
                      cipher)
     (message "Encrypting %s...done" (file-name-nondirectory file))))
 
+(defun epa-customize ()
+  (interactive)
+  (unless (and epa-customize-buffer
+              (buffer-live-p epa-customize-buffer))
+    (setq epa-customize-buffer (generate-new-buffer "*Customize*")))
+  (let ((inhibit-read-only t)
+       buffer-read-only
+       (configuration (epg-configuration)))
+    (set-buffer epa-customize-buffer)
+    (erase-buffer)
+    (insert (format "GnuPG %s\n\n" (cdr (assq 'version configuration))))
+    (insert "Cipher:\n")
+    (apply #'widget-create 'radio-button-choice
+          :notify (lambda (widget &rest ignore)
+                    (message "Set %s" (widget-value widget)))
+          (mapcar
+           (lambda (algorithm)
+             (list 'item
+                   :tag (cdr (assq algorithm epg-cipher-algorithm-alist))
+                   algorithm))
+           (cdr (assq 'cipher configuration))))
+    (insert "Digest:\n")
+    (apply #'widget-create 'radio-button-choice
+          :notify (lambda (widget &rest ignore)
+                    (message "Set %s" (widget-value widget)))
+          (mapcar
+           (lambda (algorithm)
+             (list 'item
+                   :tag (cdr (assq algorithm epg-digest-algorithm-alist))
+                   algorithm))
+           (cdr (assq 'digest configuration))))
+    (insert "Compress:\n")
+    (apply #'widget-create 'radio-button-choice
+          :notify (lambda (widget &rest ignore)
+                    (message "Set %s" (widget-value widget)))
+          (mapcar
+           (lambda (algorithm)
+             (list 'item
+                   :tag (cdr (assq algorithm epg-compress-algorithm-alist))
+                   algorithm))
+           (cdr (assq 'compress configuration))))
+    (insert "\n")
+    (epa-list-keys-1 nil t)
+    (epa-keys-mode)
+    (goto-char (point-min))
+    (pop-to-buffer (current-buffer))))
+
 (provide 'epa)
 
 ;;; epa.el ends here
diff --git a/epg.el b/epg.el
index 243b0a3..abd5d85 100644 (file)
--- a/epg.el
+++ b/epg.el
     (?n . never)
     (?m . marginal)
     (?f . full)
-    (?u . ultimate)))
+    (?u . ultimate)
+    (?  . empty)))
 
 (defvar epg-key-capablity-alist
   '((?e . encrypt)
@@ -755,7 +756,9 @@ This function is for internal use only."
 
 (defun epg-make-sub-key-1 (line)
   (epg-make-sub-key
-   (cdr (assq (string-to-char (aref line 1)) epg-key-validity-alist))
+   (if (aref line 1)
+       (cdr (assq (string-to-char (aref line 1)) epg-key-validity-alist))
+     'empty)
    (delq nil
         (mapcar (lambda (char) (cdr (assq char epg-key-capablity-alist)))
                 (aref line 11)))
@@ -780,8 +783,10 @@ This function is for internal use only."
           (car keys)
           (nreverse (epg-key-user-id-list (car keys)))))
        (setq keys (cons (epg-make-key
-                         (cdr (assq (string-to-char (aref (car lines) 8))
-                                    epg-key-validity-alist)))
+                         (if (aref (car lines) 8)
+                             (cdr (assq (string-to-char (aref (car lines) 8))
+                                        epg-key-validity-alist))
+                           'empty))
                         keys))
        (epg-key-set-sub-key-list
         (car keys)
@@ -796,8 +801,10 @@ This function is for internal use only."
        (epg-key-set-user-id-list
         (car keys)
         (cons (epg-make-user-id
-               (cdr (assq (string-to-char (aref (car lines) 1))
-                          epg-key-validity-alist))
+               (if (aref (car lines) 1)
+                   (cdr (assq (string-to-char (aref (car lines) 1))
+                              epg-key-validity-alist))
+                 'empty)
                (aref (car lines) 9))
               (epg-key-user-id-list (car keys)))))
        ((equal (aref (car lines) 0) "fpr")