Synch with the emacs-25 branch; the changes will be merged to the trunk (soon?)
[gnus] / lisp / hashcash.el
index 735ff83..1e57119 100644 (file)
@@ -1,7 +1,6 @@
 ;;; hashcash.el --- Add hashcash payments to email
 
-;; Copyright (C) 2003-2005, 2007-2011
-;;   Free Software Foundation
+;; Copyright (C) 2003-2005, 2007-2015 Free Software Foundation, Inc.
 
 ;; Written by: Paul Foley <mycroft@actrix.gen.nz> (1997-2002)
 ;; Maintainer: Paul Foley <mycroft@actrix.gen.nz>
 
 ;;; Code:
 
-;; For Emacs <22.2 and XEmacs.
-(eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
-
 (eval-when-compile (require 'cl))      ; for case
 
 (defgroup hashcash nil
   :group 'mail)
 
 (defcustom hashcash-default-payment 20
-  "*The default number of bits to pay to unknown users.
+  "The default number of bits to pay to unknown users.
 If this is zero, no payment header will be generated.
 See `hashcash-payment-alist'."
   :type 'integer
   :group 'hashcash)
 
 (defcustom hashcash-payment-alist '()
-  "*An association list mapping email addresses to payment amounts.
+  "An association list mapping email addresses to payment amounts.
 Elements may consist of (ADDR AMOUNT) or (ADDR STRING AMOUNT), where
 ADDR is the email address of the intended recipient and AMOUNT is
 the value of hashcash payment to be made to that user.  STRING, if
@@ -81,33 +76,38 @@ present, is the string to be hashed; if not present ADDR will be used."
   :group 'hashcash)
 
 (defcustom hashcash-default-accept-payment 20
-  "*The default minimum number of bits to accept on incoming payments."
+  "The default minimum number of bits to accept on incoming payments."
   :type 'integer
   :group 'hashcash)
 
 (defcustom hashcash-accept-resources `((,user-mail-address nil))
-  "*An association list mapping hashcash resources to payment amounts.
+  "An association list mapping hashcash resources to payment amounts.
 Resources named here are to be accepted in incoming payments.  If the
 corresponding AMOUNT is NIL, the value of `hashcash-default-accept-payment'
 is used instead."
+  :type 'alist
   :group 'hashcash)
 
-(defcustom hashcash-path (executable-find "hashcash")
-  "*The path to the hashcash binary."
+(define-obsolete-variable-alias 'hashcash-path 'hashcash-program "24.4")
+(defcustom hashcash-program "hashcash"
+  "The name of the hashcash executable.
+If this is not in your PATH, specify an absolute file name."
+  :type '(choice (const nil) file)
   :group 'hashcash)
 
 (defcustom hashcash-extra-generate-parameters nil
-  "*A list of parameter strings passed to `hashcash-path' when minting.
-For example, you may want to set this to '(\"-Z2\") to reduce header length."
+  "A list of parameter strings passed to `hashcash-program' when minting.
+For example, you may want to set this to (\"-Z2\") to reduce header length."
   :type '(repeat string)
   :group 'hashcash)
 
 (defcustom hashcash-double-spend-database "hashcash.db"
-  "*The path to the double-spending database."
+  "The name of the double-spending database file."
+  :type 'file
   :group 'hashcash)
 
 (defcustom hashcash-in-news nil
-  "*Specifies whether or not hashcash payments should be made to newsgroups."
+  "Specifies whether or not hashcash payments should be made to newsgroups."
   :type 'boolean
   :group 'hashcash)
 
@@ -160,10 +160,10 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length."
 (defun hashcash-generate-payment (str val)
   "Generate a hashcash payment by finding a VAL-bit collison on STR."
   (if (and (> val 0)
-          hashcash-path)
+          hashcash-program)
       (with-current-buffer (get-buffer-create " *hashcash*")
        (erase-buffer)
-       (apply 'call-process hashcash-path nil t nil
+       (apply 'call-process hashcash-program nil t nil
               "-m" "-q" "-b" (number-to-string val) str
               hashcash-extra-generate-parameters)
        (goto-char (point-min))
@@ -174,9 +174,9 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length."
   "Generate a hashcash payment by finding a VAL-bit collison on STR.
 Return immediately.  Call CALLBACK with process and result when ready."
   (if (and (> val 0)
-          hashcash-path)
+          hashcash-program)
       (let ((process (apply 'start-process "hashcash" nil
-                           hashcash-path "-m" "-q"
+                           hashcash-program "-m" "-q"
                            "-b" (number-to-string val) str
                            hashcash-extra-generate-parameters)))
        (setq hashcash-process-alist (cons
@@ -188,8 +188,8 @@ Return immediately.  Call CALLBACK with process and result when ready."
 
 (defun hashcash-check-payment (token str val)
   "Check the validity of a hashcash payment."
-  (if hashcash-path
-      (zerop (call-process hashcash-path nil nil nil "-c"
+  (if hashcash-program
+      (zerop (call-process hashcash-program nil nil nil "-c"
                           "-d" "-f" hashcash-double-spend-database
                           "-b" (number-to-string val)
                           "-r" str