Remove xetla pkg
[packages] / xemacs-packages / zenirc / src / zenirc-yow.el
1 ;;; zenirc-yow.el --- important pinheadery for ZenIRC
2
3 ;; Copyright (C) 1994, 1995, 1997 Noah S. Friedman
4 ;; Copyright (C) 1996 Per Persson
5
6 ;; Author: Noah Friedman <friedman@prep.ai.mit.edu>
7 ;; Maintainer: friedman@prep.ai.mit.edu
8 ;; Keywords: zenirc, extensions, oink, yow
9 ;; Created: 1994-06-30
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15 ;;
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
25
26 ;;; Commentary:
27
28 ;; ANN JILLIAN'S HAIR makes LONI ANDERSON'S HAIR look like
29 ;; RICARDO MONTALBAN'S HAIR!
30
31 ;;; Code:
32
33 (require 'zenirc-trigger)
34
35 ;; v18 yow.el didn't have a `provide'
36 (or (fboundp 'yow) (load "yow"))
37
38 ;; Strip newlines and excess whitespace from string.
39 (defun zenirc-yow-format-string (s)
40   (save-match-data
41     (cond ((string-match "[ \t\n\r][ \t\n\r]+" s)
42            (let ((orig-buffer (current-buffer))
43                  (temp-buffer (generate-new-buffer " *Yow*")))
44              (unwind-protect
45                  (progn
46                    (set-buffer temp-buffer)
47                    ;; don't make undo records in temp buffer
48                    (let ((buffer-undo-list t))
49                      (insert s)
50                      (goto-char (point-min))
51                      (while (re-search-forward "[ \t\n\r]+" nil t)
52                        (replace-match " "))
53                      (setq s (buffer-substring (point-min) (point-max)))))
54                (set-buffer orig-buffer)
55                (kill-buffer temp-buffer))))))
56   s)
57
58 (defun zenirc-yow ()
59   (zenirc-yow-format-string (yow)))
60
61 (zenirc-trigger-register "yow" 'zenirc-yow "\\byow\\b")
62
63 (provide 'zenirc-yow)
64
65 ;;; zenirc-yow.el ends here