]> code.delx.au - gnu-emacs/blobdiff - lisp/play/fortune.el
Changes from arch/CVS synchronization
[gnu-emacs] / lisp / play / fortune.el
index 1166c5f6592265114ee349887c8931dbde9b7a91..306cf7daac15b1fd2bf258fdaa4bcb3e6db4c922 100644 (file)
@@ -1,10 +1,11 @@
-;;; fortune.el --- Use fortune to create signatures
-;; Copyright (C) 1999 Free Software Foundation, Inc.
+;;; fortune.el --- use fortune to create signatures
+
+;; Copyright (C) 1999, 2001 Free Software Foundation, Inc.
 
 ;; Author: Holger Schauer <Holger.Schauer@gmx.de>
 ;; Keywords: games utils mail
 
-;; This file is part of Emacs.
+;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -33,8 +34,8 @@
 
 ;;; Installation:
 
-;; Please check the customize settings - you will at least have to modify the
-;; values of `fortune-dir' and `fortune-file'.
+;; Please check the customize settings -- you will at least have to
+;; modify the values of `fortune-dir' and `fortune-file'.
 
 ;; I then use this in my .gnus:
 ;;(message "Making new signature: %s" (fortune-to-signature "~/fortunes/"))
@@ -44,9 +45,7 @@
 
 ;; If you like to get a new signature for every message, you can also hook
 ;; it into message-mode:
-;; (add-hook 'message-setup-hook
-;;           '(lambda ()
-;;              (fortune-to-signature)))      
+;; (add-hook 'message-setup-hook 'fortune-to-signature)
 ;; This time no fortune-file is specified, so fortune-to-signature would use
 ;; the default-file as specified by fortune-file.
 
@@ -54,7 +53,7 @@
 ;;(add-hook 'gnus-article-mode-hook
 ;;       '(lambda ()
 ;;          (define-key gnus-article-mode-map "i" 'fortune-from-region)))
-;; which allows marking a region and then pressing "i" so that the marked 
+;; which allows marking a region and then pressing "i" so that the marked
 ;; region will be automatically added to my favourite fortune-file.
 
 ;;; Code:
 ;;; Customizable Settings
 (defgroup fortune nil
   "Settings for fortune."
+  :link '(emacs-commentary-link "fortune.el")
+  :version "21.1"
   :group 'games)
 (defgroup fortune-signature nil
   "Settings for use of fortune for signatures."
-  :group 'fortune 
+  :group 'fortune
   :group 'mail)
 
 (defcustom fortune-dir "~/docs/ascii/misc/fortunes/"
   "*The directory to look in for local fortune cookies files."
+  :type 'directory
   :group 'fortune)
-(defcustom fortune-file 
+(defcustom fortune-file
   (expand-file-name "usenet" fortune-dir)
   "*The file in which local fortune cookies will be stored."
+  :type 'file
   :group 'fortune)
 (defcustom fortune-database-extension  ".dat"
-  "The extension of the corresponding fortune database. 
+  "The extension of the corresponding fortune database.
 Normally you won't have a reason to change it."
+  :type 'string
   :group 'fortune)
 (defcustom fortune-program "fortune"
   "Program to select a fortune cookie."
+  :type 'string
   :group 'fortune)
 (defcustom fortune-program-options ""
-  "Options to pass to the fortune program."
+  "Options to pass to the fortune program (a string)."
+  :type 'string
   :group 'fortune)
 (defcustom fortune-strfile "strfile"
   "Program to compute a new fortune database."
+  :type 'string
   :group 'fortune)
 (defcustom fortune-strfile-options ""
-  "Options to pass to the strfile program."
+  "Options to pass to the strfile program (a string)."
+  :type 'string
   :group 'fortune)
 (defcustom fortune-quiet-strfile-options "> /dev/null"
   "Text added to the command for running `strfile'.
 By default it discards the output produced by `strfile'.
 Set this to \"\" if you would like to see the output."
+  :type 'string
   :group 'fortune)
 
 (defcustom fortune-always-compile t
   "*Non-nil means automatically compile fortune files.
 If nil, you must invoke `fortune-compile' manually to do that."
+  :type 'boolean
   :group 'fortune)
 (defcustom fortune-author-line-prefix "                  -- "
   "Prefix to put before the author name of a fortunate."
+  :type 'string
   :group 'fortune-signature)
 (defcustom fortune-fill-column fill-column
   "Fill column for fortune files."
+  :type 'integer
   :group 'fortune-signature)
 (defcustom fortune-from-mail "private e-mail"
   "String to use to characterize that the fortune comes from an e-mail.
@@ -115,27 +127,29 @@ No need to add an `in'."
   :group 'fortune-signature)
 (defcustom fortune-sigstart ""
   "*Some text to insert before the fortune cookie, in a mail signature."
+  :type 'string
   :group 'fortune-signature)
 (defcustom fortune-sigend ""
   "*Some text to insert after the fortune cookie, in a mail signature."
+  :type 'string
   :group 'fortune-signature)
 
 
 ;; not customizable settings
 (defvar fortune-buffer-name "*fortune*")
-(defconst fortune-end-sep "\n%\n")  
+(defconst fortune-end-sep "\n%\n")
 
 
 ;;; **************
 ;;; Inserting a new fortune
 (defun fortune-append (string &optional interactive file)
-  "Appends STRING to the fortune FILE. 
+  "Appends STRING to the fortune FILE.
 
 If INTERACTIVE is non-nil, don't compile the fortune file afterwards."
-  (setq file (expand-file-name 
+  (setq file (expand-file-name
              (substitute-in-file-name (or file fortune-file))))
   (if (file-directory-p file)
-      (error "Cannot append fortune to directory %s." file))
+      (error "Cannot append fortune to directory %s" file))
   (if interactive ; switch to file and return buffer
       (find-file-other-frame file)
     (find-file-noselect file))
@@ -154,12 +168,12 @@ If INTERACTIVE is non-nil, don't compile the fortune file afterwards."
 
 (defun fortune-ask-file ()
   "Asks the user for a file-name."
-  (expand-file-name 
+  (expand-file-name
    (read-file-name
     "Fortune file to use: "
     fortune-dir nil nil "")))
 
-;;; ###autoload
+;;;###autoload
 (defun fortune-add-fortune (string file)
   "Add STRING to a fortune file FILE.
 
@@ -170,13 +184,13 @@ read the file name to use.  Otherwise use the value of `fortune-file'."
         (if current-prefix-arg (fortune-ask-file))))
   (fortune-append string t file))
 
-;;; ###autoload
+;;;###autoload
 (defun fortune-from-region (beg end file)
-  "Appends the current region to a local fortune-like data file.  
+  "Append the current region to a local fortune-like data file.
 
 Interactively, if called with a prefix argument,
 read the file name to use.  Otherwise use the value of `fortune-file'."
-  (interactive 
+  (interactive
    (list (region-beginning) (region-end)
         (if current-prefix-arg (fortune-ask-file))))
   (let ((string (buffer-substring beg end))
@@ -184,12 +198,12 @@ read the file name to use.  Otherwise use the value of `fortune-file'."
     ;; try to determine author ...
     (save-excursion
       (goto-char (point-min))
-      (setq help-point 
+      (setq help-point
            (search-forward-regexp
             "^From: \\(.*\\)$"
             (point-max) t))
-      (if help-point 
-         (setq author (buffer-substring (match-beginning 1) help-point)) 
+      (if help-point
+         (setq author (buffer-substring (match-beginning 1) help-point))
        (setq author "An unknown author")))
     ;; ... and newsgroup
     (save-excursion
@@ -198,11 +212,11 @@ read the file name to use.  Otherwise use the value of `fortune-file'."
            (search-forward-regexp
             "^Newsgroups: \\(.*\\)$"
             (point-max) t))
-      (if help-point 
+      (if help-point
          (setq newsgroup (buffer-substring (match-beginning 1) help-point))
-       (setq newsgroup (if (or (eql major-mode 'gnus-article-mode)
-                               (eql major-mode 'vm-mode)
-                               (eql major-mode 'rmail-mode))
+       (setq newsgroup (if (or (eq major-mode 'gnus-article-mode)
+                               (eq major-mode 'vm-mode)
+                               (eq major-mode 'rmail-mode))
                            fortune-from-mail
                          "unknown"))))
 
@@ -216,34 +230,34 @@ read the file name to use.  Otherwise use the value of `fortune-file'."
 
 ;;; **************
 ;;; Compile new database with strfile
-;;; ###autoload
+;;;###autoload
 (defun fortune-compile (&optional file)
   "Compile fortune file.
 
 If called with a prefix asks for the FILE to compile, otherwise uses
 the value of `fortune-file'.  This currently cannot handle directories."
-  (interactive 
+  (interactive
     (list
      (if current-prefix-arg
         (fortune-ask-file)
        fortune-file)))
   (let* ((fortune-file (expand-file-name (substitute-in-file-name file)))
-        (fortune-dat (expand-file-name 
+        (fortune-dat (expand-file-name
                       (substitute-in-file-name
                        (concat fortune-file fortune-database-extension)))))
   (cond ((file-exists-p fortune-file)
         (if (file-exists-p fortune-dat)
             (cond ((file-newer-than-file-p fortune-file fortune-dat)
                    (message "Compiling new fortune database %s" fortune-dat)
-                   (shell-command 
+                   (shell-command
                     (concat fortune-strfile fortune-strfile-options
                             " " fortune-file fortune-quiet-strfile-options))))))
        (t (error "Can't compile fortune file %s" fortune-file)))))
-  
-        
+
+
 ;;; **************
 ;;; Use fortune for signature
-;;; ###autoload
+;;;###autoload
 (defun fortune-to-signature (&optional file)
   "Create signature from output of the fortune program.
 
@@ -251,7 +265,7 @@ If called with a prefix asks for the FILE to choose the fortune from,
 otherwise uses the value of `fortune-file'.  If you want to have fortune
 choose from a set of files in a directory, call interactively with prefix
 and choose the directory as the fortune-file."
-  (interactive 
+  (interactive
     (list
      (if current-prefix-arg
         (fortune-ask-file)
@@ -292,7 +306,7 @@ when supplied, specifies the file to choose the fortune from."
        (concat fortune-program-options fort-file)))))
 
 
-;;; ###autoload
+;;;###autoload
 (defun fortune (&optional file)
   "Display a fortune cookie.
 
@@ -300,7 +314,7 @@ If called with a prefix asks for the FILE to choose the fortune from,
 otherwise uses the value of `fortune-file'.  If you want to have fortune
 choose from a set of files in a directory, call interactively with prefix
 and choose the directory as the fortune-file."
-  (interactive 
+  (interactive
     (list
      (if current-prefix-arg
         (fortune-ask-file)
@@ -313,5 +327,5 @@ and choose the directory as the fortune-file."
 ;;; Provide ourselves.
 (provide 'fortune)
 
+;;; arch-tag: a1e4cb8a-3792-40e7-86a7-fc75ce094bcc
 ;;; fortune.el ends here
-