]> code.delx.au - gnu-emacs/blobdiff - lisp/play/animate.el
Update copyright year to 2015
[gnu-emacs] / lisp / play / animate.el
index 9d180a5f3380d71a76ed51759296ba5965063c1c..e869f2c124b1c18226561924a6c8e8893a4779a5 100644 (file)
@@ -1,17 +1,16 @@
 ;;; animate.el --- make text dance
 
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2015 Free Software Foundation, Inc.
 
 ;; Maintainer: Richard Stallman <rms@gnu.org>
 ;; Keywords: games
 
 ;; 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 <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
   (insert-char char 1))
 
 (defvar animate-n-steps 10
-  "Number of steps to use `animate-string'.")
+"*Number of steps `animate-string' will place a char before its last position.")
+
+(defvar animation-buffer-name nil
+  "String naming the default buffer for animations.
+When nil animations displayed in the buffer named *Animation*.")
 
 ;;;###autoload
 (defun animate-string (string vpos &optional hpos)
-  "Display STRING starting at position VPOS, HPOS, using animation.
+  "Display STRING animations starting at position VPOS, HPOS.
 The characters start at randomly chosen places,
 and all slide in parallel to their final positions,
 passing through `animate-n-steps' positions before the final ones.
@@ -107,7 +108,11 @@ in the current window."
                             (or hpos
                                 ;; HPOS unspecified, so compute
                                 ;; it so as to center the string.
-                                (max 0 (/ (- (window-width) (length string)) 2))))))
+                                (max 0 (/ (- (window-width) (length string)) 2)))))
+       (show-trailing-whitespace nil)
+       ;; Make sure indentation does not use tabs.
+       ;; They would confuse things.
+       (indent-tabs-mode nil))
     (dotimes (i animate-n-steps)
       ;; Bind buffer-undo-list so it will be unchanged when we are done.
       ;; (We're going to undo all our changes anyway.)
@@ -137,17 +142,21 @@ in the current window."
 
 ;;;###autoload
 (defun animate-sequence (list-of-strings space)
-  "Display strings from LIST-OF-STRING with animation in a new buffer.
-Strings will be separated from each other by SPACE lines."
+  "Display animation strings from LIST-OF-STRING with buffer *Animation*.
+Strings will be separated from each other by SPACE lines.
+ When the variable `animation-buffer-name' is non-nil display
+animation in the buffer named by variable's value, creating the
+buffer if one does not exist."
   (let ((vpos (/ (- (window-height)
                    1 ;; For the mode-line
                    (* (1- (length list-of-strings)) space)
                    (length list-of-strings))
                 2)))
-    (switch-to-buffer (get-buffer-create "*Animation*"))
+    (switch-to-buffer (get-buffer-create
+                       (or animation-buffer-name
+                           "*Animation*")))
     (erase-buffer)
     (sit-for 0)
-    (setq indent-tabs-mode nil)
     (while list-of-strings
       (animate-string (car list-of-strings) vpos)
       (setq vpos (+ vpos space 1))
@@ -155,22 +164,25 @@ Strings will be separated from each other by SPACE lines."
 
 ;;;###autoload
 (defun animate-birthday-present (&optional name)
-  "Display one's birthday present in a new buffer.
-You can specify the one's name by NAME; the default value is \"Sarah\"."
-  (interactive (list (read-string "Name (default Sarah): "
-                                 nil nil "Sarah")))
+  "Return a birthday present in the buffer *Birthday-Present*.
+When optional arg NAME is non-nil or called-interactively, prompt for
+NAME of birthday present receiver and return a birthday present in
+the buffer *Birthday-Present-for-Name*."
+  (interactive (list (read-string "Birthday present for: "
+                                 nil nil)))
   ;; Make a suitable buffer to display the birthday present in.
-  (switch-to-buffer (get-buffer-create (format "*%s*" name)))
+  (switch-to-buffer (get-buffer-create
+                    (if name
+                        (concat "*A-Present-for-" (capitalize name) "*")
+                      "*Birthday-Present*")))
   (erase-buffer)
   ;; Display the empty buffer.
   (sit-for 0)
-  ;; Make sure indentation does not use tabs.
-  ;; They would confuse things.
-  (setq indent-tabs-mode nil)
-
-  (animate-string "Happy Birthday," 6)
-  (animate-string (format "%s" name) 7)
 
+  (if name
+      (animate-string "Happy Birthday," 6)
+      (animate-string "Happy Birthday" 6))
+  (when name (animate-string (format "%s" (capitalize name)) 7))
   (sit-for 1)
 
   (animate-string "You are my sunshine," 10 30)
@@ -189,9 +201,6 @@ You can specify the one's name by NAME; the default value is \"Sarah\"."
   (animate-string "my sunshine" 18 34)
   (animate-string "to stay!" 19 34))
 
-(random t)
-
 (provide 'animate)
 
-;;; arch-tag: 275289a3-6ac4-41da-b527-a1147045392f
 ;;; animate.el ends here