]> code.delx.au - gnu-emacs/commitdiff
Use cookie functions in yow
authorGlenn Morris <rgm@gnu.org>
Fri, 21 Jun 2013 16:00:00 +0000 (09:00 -0700)
committerGlenn Morris <rgm@gnu.org>
Fri, 21 Jun 2013 16:00:00 +0000 (09:00 -0700)
* play/cookie1.el (cookie-apropos): Add optional display argument.
* obsolete/yow.el (apropos-zippy): Use cookie-apropos.
(psychoanalyze-pinhead): Use cookie-doctor.

lisp/ChangeLog
lisp/obsolete/yow.el
lisp/play/cookie1.el

index 2951d4fe810e4da60bbe8d59a5411d338d384615..11346f8c09355042571e36c8a7c771f443601633 100644 (file)
@@ -1,3 +1,9 @@
+2013-06-21  Glenn Morris  <rgm@gnu.org>
+
+       * play/cookie1.el (cookie-apropos): Add optional display argument.
+       * obsolete/yow.el (apropos-zippy): Use cookie-apropos.
+       (psychoanalyze-pinhead): Use cookie-doctor.
+
 2013-06-21  Juanma Barranquero  <lekktu@gmail.com>
 
        * emacs-lisp/package.el (tar-get-file-descriptor)
index abada670d6cdd3267c565dbbb8d35c10a9e2d07d..fb826d558669683f19d5a6d067c85858eaa0c690 100644 (file)
@@ -74,33 +74,7 @@ If optional second arg is non-nil, require input to match a completion."
   "Return a list of all Zippy quotes matching REGEXP.
 If called interactively, display a list of matches."
   (interactive "sApropos Zippy (regexp): ")
-  ;; Make sure yows are loaded
-  (cookie yow-file yow-load-message yow-after-load-message)
-  (let* ((case-fold-search t)
-         (cookie-table-symbol (intern yow-file cookie-cache))
-         (string-table (symbol-value cookie-table-symbol))
-         (matches nil)
-         (len (length string-table))
-         (i 0))
-    (save-match-data
-      (while (< i len)
-        (and (string-match regexp (aref string-table i))
-             (setq matches (cons (aref string-table i) matches)))
-        (setq i (1+ i))))
-    (and matches
-         (setq matches (sort matches 'string-lessp)))
-    (and (called-interactively-p 'interactive)
-         (cond ((null matches)
-                (message "No matches found."))
-               (t
-                (let ((l matches))
-                  (with-output-to-temp-buffer "*Zippy Apropos*"
-                    (while l
-                      (princ (car l))
-                      (setq l (cdr l))
-                      (and l (princ "\n\n")))
-                   (help-print-return-message))))))
-    matches))
+  (cookie-apropos regexp yow-file (called-interactively-p 'interactive)))
 
 \f
 ;; Yowza!! Feed zippy quotes to the doctor. Watch results.
@@ -114,15 +88,7 @@ If called interactively, display a list of matches."
 (defun psychoanalyze-pinhead ()
   "Zippy goes to the analyst."
   (interactive)
-  (doctor)                             ; start the psychotherapy
-  (message "")
-  (switch-to-buffer "*doctor*")
-  (sit-for 0)
-  (while (not (input-pending-p))
-    (insert (yow))
-    (sit-for 0)
-    (doctor-ret-or-read 1)
-    (doctor-ret-or-read 1)))
+  (cookie-doctor yow-file))
 
 (provide 'yow)
 
index 69cf4d538b2aa6267f166467ddb2f5ddaca433d1..0a53d8f4e61223cf1e1e873890c198842245459c 100644 (file)
@@ -185,11 +185,11 @@ Argument REQUIRE-MATCH non-nil forces a matching cookie."
 (define-obsolete-function-alias 'shuffle-vector 'cookie-shuffle-vector "24.4")
 
 
-(defun cookie-apropos (regexp phrase-file)
+(defun cookie-apropos (regexp phrase-file &optional display)
   "Return a list of all entries matching REGEXP from PHRASE-FILE.
 Interactively, PHRASE-FILE defaults to `cookie-file', unless that
 is nil or a prefix argument is used.
-If called interactively, display a list of matches."
+If called interactively, or if DISPLAY is non-nil, display a list of matches."
   (interactive (list (read-regexp "Apropos phrase (regexp): ")
                     (if (or current-prefix-arg (not cookie-file))
                         (read-file-name "Cookie file: " nil
@@ -211,7 +211,7 @@ If called interactively, display a list of matches."
         (setq i (1+ i))))
     (and matches
          (setq matches (sort matches 'string-lessp)))
-    (and (called-interactively-p 'interactive)
+    (and (or display (called-interactively-p 'interactive))
          (cond ((null matches)
                 (message "No matches found."))
                (t