Function: epg-config--make-gpg-configuration

epg-config--make-gpg-configuration is a byte-compiled function defined in epg-config.el.gz.

Signature

(epg-config--make-gpg-configuration PROGRAM)

Source Code

;; Defined in /usr/src/emacs/lisp/epg-config.el.gz
;; Create an `epg-configuration' object for `gpg', using PROGRAM.
(defun epg-config--make-gpg-configuration (program)
  (let (config groups type args)
    (with-temp-buffer
      ;; The caller might have bound coding-system-for-* to something
      ;; like 'no-conversion, but the below needs to call PROGRAM
      ;; expecting human-readable text in both directions (since we
      ;; are going to parse the output as text), so let Emacs guess
      ;; the encoding of that text by its usual encoding-detection
      ;; machinery.
      (let ((coding-system-for-read 'undecided)
            (coding-system-for-write 'undecided))
        (apply #'call-process program nil (list t nil) nil
	       (append (if epg-gpg-home-directory
			   (list "--homedir" epg-gpg-home-directory))
		       '("--with-colons" "--list-config"))))
      (goto-char (point-min))
      (while (re-search-forward "^cfg:\\([^:]+\\):\\(.*\\)" nil t)
	(setq type (intern (match-string 1))
	      args (match-string 2))
	(cond
	 ((eq type 'group)
	  (if (string-match "\\`\\([^:]+\\):" args)
	      (setq groups
		    (cons (cons (downcase (match-string 1 args))
				(delete "" (split-string
					    (substring args
						       (match-end 0))
					    ";")))
			  groups))
	    (if epg-debug
		(message "Invalid group configuration: %S" args))))
	 ((memq type '(pubkey cipher digest compress))
	  (if (string-match "\\`\\([0-9]+\\)\\(;[0-9]+\\)*" args)
	      (setq config
		    (cons (cons type
				(mapcar #'string-to-number
					(delete "" (split-string args ";"))))
			  config))
	    (if epg-debug
		(message "Invalid %S algorithm configuration: %S"
			 type args))))
	 (t
	  (setq config (cons (cons type args) config))))))
    (push (cons 'program program) config)
    (if groups
	(cons (cons 'groups groups) config)
      config)))