X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/32ccc8a5747ec380a9375251e1285264356b8866..84eb0351d8be4811897c8cf62a69757ff5d14001:/lisp/play/fortune.el diff --git a/lisp/play/fortune.el b/lisp/play/fortune.el index 2e635f312d..05775c8a85 100644 --- a/lisp/play/fortune.el +++ b/lisp/play/fortune.el @@ -1,17 +1,16 @@ ;;; fortune.el --- use fortune to create signatures -;; Copyright (C) 1999, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2001-2011 Free Software Foundation, Inc. ;; Author: Holger Schauer ;; Keywords: games utils mail ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; 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 -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,9 +18,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: ;; This utility allows you to automatically cut regions to a fortune @@ -72,12 +69,12 @@ :group 'mail) (defcustom fortune-dir "~/docs/ascii/misc/fortunes/" - "*The directory to look in for local fortune cookies files." + "The directory to look in for local fortune cookies files." :type 'directory :group 'fortune) (defcustom fortune-file (expand-file-name "usenet" fortune-dir) - "*The file in which local fortune cookies will be stored." + "The file in which local fortune cookies will be stored." :type 'file :group 'fortune) (defcustom fortune-database-extension ".dat" @@ -89,9 +86,11 @@ Normally you won't have a reason to change it." "Program to select a fortune cookie." :type 'string :group 'fortune) -(defcustom fortune-program-options "" - "Options to pass to the fortune program (a string)." - :type 'string +(defcustom fortune-program-options () + "List of options to pass to the fortune program." + :type '(choice (repeat (string :tag "Option")) + (string :tag "Obsolete string of options")) + :version "23.1" :group 'fortune) (defcustom fortune-strfile "strfile" "Program to compute a new fortune database." @@ -109,7 +108,7 @@ Set this to \"\" if you would like to see the output." :group 'fortune) (defcustom fortune-always-compile t - "*Non-nil means automatically compile fortune files. + "Non-nil means automatically compile fortune files. If nil, you must invoke `fortune-compile' manually to do that." :type 'boolean :group 'fortune) @@ -127,11 +126,11 @@ No need to add an `in'." :type 'string :group 'fortune-signature) (defcustom fortune-sigstart "" - "*Some text to insert before the fortune cookie, in a mail signature." + "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." + "Some text to insert after the fortune cookie, in a mail signature." :type 'string :group 'fortune-signature) @@ -285,48 +284,41 @@ and choose the directory as the fortune-file." ;;; Display fortune (defun fortune-in-buffer (interactive &optional file) "Put a fortune cookie in the *fortune* buffer. - -INTERACTIVE is ignored. Optional argument FILE, -when supplied, specifies the file to choose the fortune from." +INTERACTIVE is ignored. Optional argument FILE, when supplied, +specifies the file to choose the fortune from." (let ((fortune-buffer (or (get-buffer fortune-buffer-name) (generate-new-buffer fortune-buffer-name))) (fort-file (expand-file-name (substitute-in-file-name (or file fortune-file))))) - (save-excursion - (set-buffer fortune-buffer) - (toggle-read-only 0) - (erase-buffer) - - (if fortune-always-compile - (fortune-compile fort-file)) - - (call-process - fortune-program ;; programm to call - nil fortune-buffer nil ;; INFILE BUFFER DISPLAYP - (concat fortune-program-options fort-file))))) - + (with-current-buffer fortune-buffer + (let ((inhibit-read-only t)) + (erase-buffer) + (if fortune-always-compile + (fortune-compile fort-file)) + (apply 'call-process + fortune-program ; program to call + nil fortune-buffer nil ; INFILE BUFFER DISPLAY + (append (if (stringp fortune-program-options) + (split-string fortune-program-options) + fortune-program-options) (list fort-file))))))) ;;;###autoload (defun fortune (&optional file) "Display a fortune cookie. - 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 - (list - (if current-prefix-arg - (fortune-ask-file) - fortune-file))) + (interactive (list (if current-prefix-arg + (fortune-ask-file) + fortune-file))) (fortune-in-buffer t file) (switch-to-buffer (get-buffer fortune-buffer-name)) - (toggle-read-only 1)) + (setq buffer-read-only t)) ;;; Provide ourselves. (provide 'fortune) -;;; arch-tag: a1e4cb8a-3792-40e7-86a7-fc75ce094bcc ;;; fortune.el ends here