:group 'epa-faces)
(defvar epa-string-face 'epa-string-face)
+(defface epa-mark-face
+ '((((class color) (background dark))
+ (:foreground "orange" :bold t))
+ (t
+ (:foreground "red" :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))
(defvar epa-field-body-face 'epa-field-body-face)
(defcustom epa-validity-face-alist
- '((?o . epa-validity-disabled-face)
- (?i . epa-validity-disabled-face)
- (?d . epa-validity-disabled-face)
- (?r . epa-validity-disabled-face)
- (?e . epa-validity-disabled-face)
- (?- . epa-validity-low-face)
- (?q . epa-validity-low-face)
- (?n . epa-validity-low-face)
- (?m . epa-validity-medium-face)
- (?f . epa-validity-high-face)
- (?u . epa-validity-high-face)
- (? . epa-validity-high-face))
- "An alist mapping marks on epa-keys-buffer to faces."
+ '((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))
+ "An alist mapping validity values to faces."
:type 'list
:group 'epa)
(defcustom epa-font-lock-keywords
- '(("^[* ]\\(\\([oidreqnmfu -]\\) .*\\)"
- (1 (cdr (assq (aref (match-string 2) 0)
- epa-validity-face-alist))))
+ '(("^\\*"
+ (0 epa-mark-face))
("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
(1 epa-field-name-face)
(2 epa-field-body-face)))
(define-key keymap "q" 'bury-buffer)
keymap))
+(define-widget 'epa-key 'push-button
+ "Button for representing a epg-key object."
+ :format "%[%v%]"
+ :button-face-get 'epa-key-widget-button-face-get
+ :value-create 'epa-key-widget-value-create
+ :action 'epa-key-widget-action
+ :help-echo 'epa-key-widget-help-echo)
+
+(defun epa-key-widget-action (widget &optional event)
+ (epa-show-key (widget-get widget :value)))
+
+(defun epa-key-widget-value-create (widget)
+ (let* ((key (widget-get widget :value))
+ (primary-sub-key (car (epg-key-sub-key-list key)))
+ (primary-user-id (car (epg-key-user-id-list key))))
+ (insert (format "%c "
+ (if (epg-sub-key-validity primary-sub-key)
+ (car (rassq (epg-sub-key-validity primary-sub-key)
+ epg-key-validity-alist))
+ ? ))
+ (epg-sub-key-id primary-sub-key)
+ " "
+ (epg-user-id-name primary-user-id))))
+
+(defun epa-key-widget-button-face-get (widget)
+ (let ((validity (epg-sub-key-validity (car (epg-key-sub-key-list
+ (widget-get widget :value))))))
+ (if validity
+ (cdr (assq validity epa-validity-face-alist))
+ 'default)))
+
+(defun epa-key-widget-help-echo (widget)
+ (format "Show %s"
+ (epg-sub-key-id (car (epg-key-sub-key-list
+ (widget-get widget :value))))))
+
(defun epa-keys-mode ()
"Major mode for `epa-list-keys'."
(kill-all-local-variables)
(run-hooks 'epa-key-mode-hook))
;;;###autoload
-(defun epa-list-keys (&optional name)
- (interactive "sPattern: ")
+(defun epa-list-keys (&optional name mode)
+ (interactive
+ (let ((name (read-string "Pattern: ")))
+ (list (if (equal name "") nil name)
+ current-prefix-arg)))
(unless (and epa-keys-buffer
(buffer-live-p epa-keys-buffer))
(setq epa-keys-buffer (generate-new-buffer "*Keys*")))
(set-buffer epa-keys-buffer)
- (erase-buffer)
- (epa-list-keys-1 name nil)
- (epa-keys-mode)
+ (let ((inhibit-read-only t)
+ buffer-read-only)
+ (erase-buffer)
+ (epa-list-keys-1 name nil)
+ (epa-keys-mode))
(goto-char (point-min))
(pop-to-buffer (current-buffer)))
(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 mode))
+ (keys (epg-list-keys name mode))
+ point)
(while keys
- (setq point (point)
- primary-sub-key (car (epg-key-sub-key-list (car keys)))
- primary-user-id (car (epg-key-user-id-list (car keys))))
- (insert " " (or (char-to-string
- (car (rassq (epg-sub-key-validity primary-sub-key)
- epg-key-validity-alist)))
- " ") " ")
- (widget-create 'link
- :tag (epg-sub-key-id primary-sub-key)
- :notify 'epa-show-key-notify
- :help-echo
- (format "Show key %s"
- (epg-sub-key-id primary-sub-key))
- (car keys))
- (insert " " (epg-user-id-name primary-user-id) "\n")
+ (setq point (point))
+ (insert " ")
(put-text-property point (point) 'epa-key (car keys))
+ (widget-create 'epa-key :value (car keys))
+ (insert "\n")
(setq keys (cdr keys)))))
(defun epa-select-keys (prompt &optional names)
(setq pointer (epg-key-user-id-list key))
(while pointer
(insert " "
- (char-to-string
- (car (rassq (epg-user-id-validity (car pointer))
- epg-key-validity-alist)))
+ (if (epg-user-id-validity (car pointer))
+ (char-to-string
+ (car (rassq (epg-user-id-validity (car pointer))
+ epg-key-validity-alist)))
+ " ")
" "
(epg-user-id-name (car pointer))
"\n")
(setq pointer (epg-key-sub-key-list key))
(while pointer
(insert " "
- (char-to-string
- (car (rassq (epg-sub-key-validity (car pointer))
- epg-key-validity-alist)))
+ (if (epg-sub-key-validity (car pointer))
+ (char-to-string
+ (car (rassq (epg-sub-key-validity (car pointer))
+ epg-key-validity-alist)))
+ " ")
" "
(epg-sub-key-id (car pointer))
" "
(epa-key-mode)))
(defun epa-show-key-notify (widget &rest ignore)
- (epa-show-key (widget-value widget)))
+ (epa-show-key (widget-get widget :value)))
(defun epa-mark (&optional arg)
"Mark the current line."
(insert "Cipher:\n")
(apply #'widget-create 'radio-button-choice
:notify (lambda (widget &rest ignore)
- (message "Set %s" (widget-value widget)))
+ (message "Set %s" (widget-get widget :value)))
(mapcar
(lambda (algorithm)
(list 'item
(insert "Digest:\n")
(apply #'widget-create 'radio-button-choice
:notify (lambda (widget &rest ignore)
- (message "Set %s" (widget-value widget)))
+ (message "Set %s" (widget-get widget :value)))
(mapcar
(lambda (algorithm)
(list 'item
(insert "Compress:\n")
(apply #'widget-create 'radio-button-choice
:notify (lambda (widget &rest ignore)
- (message "Set %s" (widget-value widget)))
+ (message "Set %s" (widget-get widget :value)))
(mapcar
(lambda (algorithm)
(list 'item
+ :inline t
:tag (cdr (assq algorithm epg-compress-algorithm-alist))
algorithm))
(cdr (assq 'compress configuration))))
(?n . never)
(?m . marginal)
(?f . full)
- (?u . ultimate)
- (? . empty)))
+ (?u . ultimate)))
(defvar epg-key-capablity-alist
'((?e . encrypt)
(orig-mode (default-file-modes))
(buffer (generate-new-buffer " *epg*"))
process)
+ (if epg-debug
+ (save-excursion
+ (set-buffer (get-buffer-create " *epg-debug*"))
+ (goto-char (point-max))
+ (insert (format "%s %s\n" epg-gpg-program
+ (mapconcat #'identity args " ")))))
(with-current-buffer buffer
(make-local-variable 'epg-read-point)
(setq epg-read-point (point-min))
(defun epg-make-sub-key-1 (line)
(epg-make-sub-key
(if (aref line 1)
- (cdr (assq (string-to-char (aref line 1)) epg-key-validity-alist))
- 'empty)
+ (cdr (assq (string-to-char (aref line 1)) epg-key-validity-alist)))
(delq nil
(mapcar (lambda (char) (cdr (assq char epg-key-capablity-alist)))
(aref line 11)))
(setq keys (cons (epg-make-key
(if (aref (car lines) 8)
(cdr (assq (string-to-char (aref (car lines) 8))
- epg-key-validity-alist))
- 'empty))
+ epg-key-validity-alist))))
keys))
(epg-key-set-sub-key-list
(car keys)
(cons (epg-make-user-id
(if (aref (car lines) 1)
(cdr (assq (string-to-char (aref (car lines) 1))
- epg-key-validity-alist))
- 'empty)
+ epg-key-validity-alist)))
(aref (car lines) 9))
(epg-key-user-id-list (car keys)))))
((equal (aref (car lines) 0) "fpr")
(if (epg-data-file plain)
(list (epg-data-file plain)))))
(if sign
- (epg-wait-for-status context '("BEGIN_SIGNING"))
- (if (null recipients)
- (epg-wait-for-status context '("BEGIN_ENCRYPTION"))))
+ (epg-wait-for-status context '("BEGIN_SIGNING")))
+ (epg-wait-for-status context '("BEGIN_ENCRYPTION"))
(if (and (epg-data-string plain)
(eq (process-status (epg-context-process context)) 'run))
(process-send-string (epg-context-process context)