From cad5d1cb5af7210154814b60825576d14740158f Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 21 Jun 2013 09:00:00 -0700 Subject: [PATCH] Use cookie functions in yow * play/cookie1.el (cookie-apropos): Add optional display argument. * obsolete/yow.el (apropos-zippy): Use cookie-apropos. (psychoanalyze-pinhead): Use cookie-doctor. --- lisp/ChangeLog | 6 ++++++ lisp/obsolete/yow.el | 38 ++------------------------------------ lisp/play/cookie1.el | 6 +++--- 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2951d4fe81..11346f8c09 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-06-21 Glenn Morris + + * 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 * emacs-lisp/package.el (tar-get-file-descriptor) diff --git a/lisp/obsolete/yow.el b/lisp/obsolete/yow.el index abada670d6..fb826d5586 100644 --- a/lisp/obsolete/yow.el +++ b/lisp/obsolete/yow.el @@ -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))) ;; 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) diff --git a/lisp/play/cookie1.el b/lisp/play/cookie1.el index 69cf4d538b..0a53d8f4e6 100644 --- a/lisp/play/cookie1.el +++ b/lisp/play/cookie1.el @@ -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 -- 2.20.1