gnus-registry.el (gnus-registry-install-nnregistry): Rewrite so as not to use `delete...
[gnus] / lisp / pgg.el
1 ;;; pgg.el --- glue for the various PGP implementations.
2
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
4 ;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: Daiki Ueno <ueno@unixuser.org>
7 ;; Symmetric encryption added by: Sascha Wilde <wilde@sha-bang.de>
8 ;; Created: 1999/10/28
9 ;; Keywords: PGP
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
25
26 ;;; Commentary:
27
28 ;; This file is on its way to obsolescence, waiting for allout.el to
29 ;; switch to EPG.
30
31 ;;; Code:
32
33 (require 'pgg-def)
34 (require 'pgg-parse)
35 (autoload 'run-at-time "timer")
36
37 ;; Don't merge these two `eval-when-compile's.
38 (eval-when-compile
39   (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
40   (require 'cl))
41
42 ;;; @ utility functions
43 ;;;
44
45 (eval-when-compile
46   (when (featurep 'xemacs)
47     (defmacro pgg-run-at-time-1 (time repeat function args)
48       (if (condition-case nil
49               (let ((delete-itimer 'delete-itimer)
50                     (itimer-driver-start 'itimer-driver-start)
51                     (itimer-value 'itimer-value)
52                     (start-itimer 'start-itimer))
53                 (unless (or (symbol-value 'itimer-process)
54                             (symbol-value 'itimer-timer))
55                   (funcall itimer-driver-start))
56                 ;; Check whether there is a bug to which the difference of
57                 ;; the present time and the time when the itimer driver was
58                 ;; woken up is subtracted from the initial itimer value.
59                 (let* ((inhibit-quit t)
60                        (ctime (current-time))
61                        (itimer-timer-last-wakeup
62                         (prog1
63                             ctime
64                           (setcar ctime (1- (car ctime)))))
65                        (itimer-list nil)
66                        (itimer (funcall start-itimer "pgg-run-at-time"
67                                         'ignore 5)))
68                   (sleep-for 0.1) ;; Accept the timeout interrupt.
69                   (prog1
70                       (> (funcall itimer-value itimer) 0)
71                     (funcall delete-itimer itimer))))
72             (error nil))
73           `(let ((time ,time))
74              (apply #'start-itimer "pgg-run-at-time"
75                     ,function (if time (max time 1e-9) 1e-9)
76                     ,repeat nil t ,args))
77         `(let ((time ,time)
78                (itimers (list nil)))
79            (setcar
80             itimers
81             (apply #'start-itimer "pgg-run-at-time"
82        &