Function: pgg-gpg-process-region
pgg-gpg-process-region is a byte-compiled function defined in
pgg-gpg.el.gz.
Signature
(pgg-gpg-process-region START END PASSPHRASE PROGRAM ARGS)
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/pgg-gpg.el.gz
(defun pgg-gpg-process-region (start end passphrase program args)
(let* ((use-agent (and (null passphrase) (pgg-gpg-use-agent-p)))
(output-file-name (pgg-make-temp-file "pgg-output"))
(args
`("--status-fd" "2"
,@(if use-agent '("--use-agent")
(if passphrase '("--passphrase-fd" "0")))
"--yes" ; overwrite
"--output" ,output-file-name
,@pgg-gpg-extra-args ,@args))
(output-buffer pgg-output-buffer)
(errors-buffer pgg-errors-buffer)
(orig-mode (default-file-modes))
(process-connection-type nil)
(inhibit-redisplay t)
process status exit-status
passphrase-with-newline
encoded-passphrase-with-new-line)
(with-current-buffer (get-buffer-create errors-buffer)
(buffer-disable-undo)
(erase-buffer))
(unwind-protect
(progn
(set-default-file-modes 448)
(let ((coding-system-for-write 'binary))
(setq process
(apply #'start-process "*GnuPG*" errors-buffer
program args)))
(set-process-sentinel process #'ignore)
(when passphrase
(setq passphrase-with-newline (concat passphrase "\n"))
(if pgg-passphrase-coding-system
(progn
(setq encoded-passphrase-with-new-line
(encode-coding-string
passphrase-with-newline
(coding-system-change-eol-conversion
pgg-passphrase-coding-system 'unix)))
(clear-string passphrase-with-newline))
(setq encoded-passphrase-with-new-line passphrase-with-newline
passphrase-with-newline nil))
(process-send-string process encoded-passphrase-with-new-line))
(process-send-region process start end)
(process-send-eof process)
(while (eq 'run (process-status process))
(accept-process-output process 5))
;; Accept any remaining pending output coming after the
;; status change.
(accept-process-output process 5)
(setq status (process-status process)
exit-status (process-exit-status process))
(delete-process process)
(with-current-buffer (get-buffer-create output-buffer)
(buffer-disable-undo)
(erase-buffer)
(if (file-exists-p output-file-name)
(let ((coding-system-for-read (if pgg-text-mode
'raw-text
'binary)))
(insert-file-contents output-file-name)))
(set-buffer errors-buffer)
(if (memq status '(stop signal))
(error "%s exited abnormally: `%s'" program exit-status))
(if (= 127 exit-status)
(error "%s could not be found" program))))
(if passphrase-with-newline
(clear-string passphrase-with-newline))
(if encoded-passphrase-with-new-line
(clear-string encoded-passphrase-with-new-line))
(if (and process (eq 'run (process-status process)))
(interrupt-process process))
(if (file-exists-p output-file-name)
(delete-file output-file-name))
(set-default-file-modes orig-mode))))