1 ;;; pgg.el --- glue for the various PGP implementations.
3 ;; Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
5 ;; Author: Daiki Ueno <ueno@unixuser.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
32 (autoload 'run-at-time "timer")
34 ;; Don't merge these two `eval-when-compile's.
37 ;; Fixme: This would be better done with an autoload for
38 ;; `url-insert-file-contents', and the url stuff rationalized.
39 ;; (`locate-library' can say whether the url code is available.)
45 ;; Fixme: Avoid this and use mm-make-temp-file (especially for
46 ;; something sensitive like pgp).
47 (defvar pgg-temporary-file-directory
48 (cond ((fboundp 'temp-directory) (temp-directory))
49 ((boundp 'temporary-file-directory) temporary-file-directory)
52 ;;; @ utility functions
55 (defvar pgg-fetch-key-function (if (fboundp 'url-insert-file-contents)
56 (function pgg-fetch-key-with-w3)))
58 (defun pgg-invoke (func scheme &rest args)
60 (require (intern (format "pgg-%s" scheme)))
61 (apply 'funcall (intern (format "pgg-%s-%s" scheme func)) args)))
63 (put 'pgg-save-coding-system 'lisp-indent-function 2)
65 (defmacro pgg-save-coding-system (start end &rest body)
67 (let ((buffer (current-buffer)))
69 (let (buffer-undo-list)
70 (insert-buffer-substring buffer ,start ,end)
71 (encode-coding-region (point-min)(point-max)
72 buffer-file-coding-system)
73 (prog1 (save-excursion ,@body)
74 (push nil buffer-undo-list)
75 (ignore-errors (undo))))))
77 (narrow-to-region ,start ,end)
80 (defun pgg-temp-buffer-show-function (buffer)
81 (let ((window (split-window-vertically)))
82 (set-window-buffer window buffer)
83 (shrink-window-if-larger-than-buffer window)))
85 (defun pgg-display-output-buffer (start end status)
88 (delete-region start end)
89 (insert-buffer-substring pgg-output-buffer)
90 (decode-coding-region start (point) buffer-file-coding-system))
91 (let ((temp-buffer-show-function
92 (function pgg-temp-buffer-show-function)))