[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5417: Patch for animate.el bugs `animate-n-steps', `animate-sequence

Subject: bug#5417: Patch for animate.el bugs `animate-n-steps', `animate-sequence', `animate-birthday-present'
Date: Mon, 18 Jan 2010 18:22:20 -0500

This is a bug report regarding play/animate.el for:

variable `animate-n-steps'
function `animate-sequence'
function `animate-birthday-present'

As there are not any customization options for this package the docstring of
variable `animate-n-steps':

 "Number of steps to use `animate-string'."

should get the asterisk leadin docstring asterisk as presumably

 (user-variable-p 'animate-n-steps)

should evaluate to t. It currently does not.

The function `animate-sequence' switches to the buffer "*Animation*" by default.
The user should have some way to bind an alternate destination.

The function `animate-birthday-present' uses a default buffer "Sarah".
This is not a good default.
Also, it should capitalize the name in the returned animated strring.

The patch below attempt to address some of these concerns without resorting to
defcustom forms which understandably might be overkill given this packages
directory location e.g. /lisp/play/animate.el

Note, it adds a variable `*animation*'.

;;; ==============================

--- /quickfixes/lisp/play/animate.el.~99304~    2010-01-18 17:44:04.000000000 
+++ /quickfixes/lisp/play/animate.el    2010-01-18 17:13:27.000000000 -0500
@@ -90,11 +90,15 @@
   (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
+(defvar *animation* nil
+  "*String naming the default buffer for animations.
+When null animations dipslayed in the buffer named *Animation*.")

 (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.
@@ -139,14 +143,20 @@

 (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*' 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))
-    (switch-to-buffer (get-buffer-create "*Animation*"))
+    (switch-to-buffer (get-buffer-create
+                       (if (and (bound-and-true-p *animation*)
+                                (stringp *animation*))
+                                *animation*
+                           (capitalize (symbol-name '*animation*)))))
     (sit-for 0)
     (while list-of-strings
@@ -156,19 +166,24 @@

 (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*")))
   ;; Display the empty buffer.
   (sit-for 0)

-  (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)

;;; ==============================

Attachment: animate.el.diff
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]