gnus-art.el (gnus-mime-buttonize-attachments-in-header): Improve criterion that finds...
[gnus] / lisp / mml1991.el
index ad9f957..2663107 100644 (file)
@@ -1,10 +1,10 @@
 ;;; mml1991.el --- Old PGP message format (RFC 1991) support for MML
 
-;; Copyright (C) 1998-201 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
 
-;; Author: Sascha Lüdecke <sascha@meta-x.de>,
+;; Author: Sascha Lüdecke <sascha@meta-x.de>,
 ;;     Simon Josefsson <simon@josefsson.org> (Mailcrypt interface, Gnus glue)
-;; Keywords PGP
+;; Keywords: PGP
 
 ;; This file is part of GNU Emacs.
 
@@ -26,9 +26,6 @@
 ;;; Code:
 
 (eval-and-compile
-  ;; For Emacs <22.2 and XEmacs.
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
-
   (if (locate-library "password-cache")
       (require 'password-cache)
     (require 'password)))
@@ -50,6 +47,8 @@
 (autoload 'message-options-get "message")
 (autoload 'message-options-set "message")
 
+(require 'mml2015)
+
 (defvar mml1991-use mml2015-use
   "The package used for PGP.")
 
@@ -282,13 +281,16 @@ Whether the passphrase is cached at all is controlled by
   (catch 'found
     (while keys
       (let ((pointer (epg-key-sub-key-list (car keys))))
-       (while pointer
-         (if (and (memq usage (epg-sub-key-capability (car pointer)))
-                  (not (memq 'disabled (epg-sub-key-capability (car pointer))))
-                  (not (memq (epg-sub-key-validity (car pointer))
-                             '(revoked expired))))
-             (throw 'found (car keys)))
-         (setq pointer (cdr pointer))))
+       ;; The primary key will be marked as disabled, when the entire
+       ;; key is disabled (see 12 Field, Format of colon listings, in
+       ;; gnupg/doc/DETAILS)
+       (unless (memq 'disabled (epg-sub-key-capability (car pointer)))
+         (while pointer
+           (if (and (memq usage (epg-sub-key-capability (car pointer)))
+                    (not (memq (epg-sub-key-validity (car pointer))
+                               '(revoked expired))))
+               (throw 'found (car keys)))
+           (setq pointer (cdr pointer)))))
       (setq keys (cdr keys)))))
 
 ;; XXX: since gpg --list-secret-keys does not return validity of each
@@ -477,7 +479,7 @@ If no one is selected, default secret key is used.  "
 (provide 'mml1991)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
 
 ;;; mml1991.el ends here