- (let ((context (ad-get-arg 0))
- (plain (ad-get-arg 1))
- (mode (ad-get-arg 2)))
- (epg-context-set-operation context 'sign)
- (epg-context-set-result context nil)
- (unless (memq mode '(t detached nil normal))
- (epg-context-set-armor context t))
- (epg-pgp50i--start context
- epg-pgp50i-pgps-program
- (append (list (if (memq mode '(t detached))
- "-b"))
- (apply #'nconc
- (mapcar
- (lambda (signer)
- (list "-u"
- (epg-sub-key-id
- (car (epg-key-sub-key-list signer)))))
- (epg-context-signers context)))
- (if (epg-data-file plain)
- (list (epg-data-file plain)))))
- ;; `gpgsm' does not read passphrase from stdin, so waiting is not needed.
- (unless (eq (epg-context-protocol context) 'CMS)
- (epg-wait-for-status context '("BEGIN_SIGNING")))
- (when (epg-data-string plain)
- (if (eq (process-status (epg-context-process context)) 'run)
- (process-send-string (epg-context-process context)
- (epg-data-string plain)))
- (if (eq (process-status (epg-context-process context)) 'run)
- (process-send-eof (epg-context-process context)))))
- ))