From 590e05e5c3b1e8b799caa0a23c69c4bfc923b98d Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 5 Sep 2006 04:03:11 +0000 Subject: [PATCH] * epg-config.el (epg-debug): Moved from epg.el. (epg-configuration): Parse group configuration. (epg-expand-group): New function. --- ChangeLog | 6 ++++++ epg-config.el | 51 ++++++++++++++++++++++++++++++++++++++++----------- epg.el | 1 - 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53b3aaa..0fd818b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-05 Daiki Ueno + + * epg-config.el (epg-debug): Moved from epg.el. + (epg-configuration): Parse group configuration. + (epg-expand-group): New function. + 2006-09-04 Daiki Ueno * EasyPG: Version 0.0.5 released. diff --git a/epg-config.el b/epg-config.el index 2c4e566..ae4fe00 100644 --- a/epg-config.el +++ b/epg-config.el @@ -48,6 +48,12 @@ :group 'epg :type 'symbol) +(defcustom epg-debug nil + "If non-nil, debug output goes to the \" *epg-debug*\" buffer. +Note that the buffer name starts with a space." + :group 'epg + :type 'boolean) + (defconst epg-version-number "0.0.5") (defconst epg-gpg-minimum-version "1.4.3") @@ -55,7 +61,7 @@ ;;;###autoload (defun epg-configuration () "Return a list of internal configuration parameters of `epg-gpg-program'." - (let (config type) + (let (config groups type args) (with-temp-buffer (apply #'call-process epg-gpg-program nil (list t nil) nil (append (if epg-gpg-home-directory @@ -64,16 +70,31 @@ (goto-char (point-min)) (while (re-search-forward "^cfg:\\([^:]+\\):\\(.*\\)" nil t) (setq type (intern (match-string 1)) - config (cons (cons type - (if (memq type - '(pubkey cipher digest compress)) - (mapcar #'string-to-number - (delete "" (split-string - (match-string 2) - ";"))) - (match-string 2))) - config)))) - config)) + 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))))))) + (if groups + (cons (cons 'groups groups) config) + config))) (defun epg-config--parse-version (string) (let ((index 0) @@ -104,6 +125,14 @@ (unless (>= (epg-config--compare-version version minimum-version) 0) (error "Unsupported version: %s" (cdr entry))))) +;;;###autoload +(defun epg-expand-group (config group) + "Look at CONFIG and try to expand GROUP." + (let ((entry (assq 'groups config))) + (if (and entry + (setq entry (assoc (downcase group) (cdr entry)))) + (cdr entry)))) + (provide 'epg-config) ;;; epg-config.el ends here diff --git a/epg.el b/epg.el index 0191a01..29f78f8 100644 --- a/epg.el +++ b/epg.el @@ -38,7 +38,6 @@ (defvar epg-pending-status-list nil) (defvar epg-key-id nil) (defvar epg-context nil) -(defvar epg-debug nil) (defvar epg-debug-buffer nil) ;; from gnupg/include/cipher.h -- 1.7.10.4