annotate lisp/gnus/earcon.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
1 ;;; earcon.el --- Sound effects for messages
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
2 ;; Copyright (C) 1996 Free Software Foundation
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
3
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
4 ;; Author: Steven L. Baur <steve@miranova.com>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
5 ;; Keywords: news fun sound
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
6
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
8
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
12 ;; any later version.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
13
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
18
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 ;;; Commentary:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 ;; This file provides access to sound effects in Gnus.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27 ;;; Code:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 (if (null (boundp 'running-xemacs))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32 (require 'gnus)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 (require 'gnus-sound)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34 (eval-when-compile (require 'cl))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 (defvar earcon-auto-play nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37 "When True, automatially play sounds as well as buttonize them.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
38
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 (defvar earcon-prefix "**"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
40 "The start of an earcon")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
41
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 (defvar earcon-suffix "**"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
43 "The end of an earcon")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
44
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 (defvar earcon-regexp-alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
46 '(("boring" 1 "Boring.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 ("evil[ \t]+laugh" 1 "Evil_Laugh.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
48 ("gag\\|puke" 1 "Puke.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 ("snicker" 1 "Snicker.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50 ("meow" 1 "catmeow.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 ("sob\\|boohoo" 1 "cry.wav")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 ("drum[ \t]*roll" 1 "drumroll.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 ("blast" 1 "explosion.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54 ("flush" 1 "flush.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 ("kiss" 1 "kiss.wav")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 ("tee[ \t]*hee" 1 "laugh.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
57 ("shoot" 1 "shotgun.wav")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
58 ("yawn" 1 "snore.wav")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
59 ("cackle" 1 "witch.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 ("yell\\|roar" 1 "yell2.au")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61 ("whoop-de-doo" 1 "whistle.au"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62 "A list of regexps to map earcons to real sounds.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
63
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
64 (defvar earcon-button-marker-list nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
65 (make-variable-buffer-local 'earcon-button-marker-list)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
66
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
67
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
68
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
69 ;;; FIXME!! clone of code from gnus-vis.el FIXME!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
70 (defun earcon-article-push-button (event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
71 "Check text under the mouse pointer for a callback function.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
72 If the text under the mouse pointer has a `earcon-callback' property,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
73 call it with the value of the `earcon-data' text property."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
74 (interactive "e")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
75 (set-buffer (window-buffer (posn-window (event-start event))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
76 (let* ((pos (posn-point (event-start event)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
77 (data (get-text-property pos 'earcon-data))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
78 (fun (get-text-property pos 'earcon-callback)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
79 (if fun (funcall fun data))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
80
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
81 (defun earcon-article-press-button ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82 "Check text at point for a callback function.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
83 If the text at point has a `earcon-callback' property,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
84 call it with the value of the `earcon-data' text property."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
85 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
86 (let* ((data (get-text-property (point) 'earcon-data))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
87 (fun (get-text-property (point) 'earcon-callback)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
88 (if fun (funcall fun data))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
89
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
90 (defun earcon-article-prev-button (n)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
91 "Move point to N buttons backward.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
92 If N is negative, move forward instead."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
93 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
94 (earcon-article-next-button (- n)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
95
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
96 (defun earcon-article-next-button (n)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
97 "Move point to N buttons forward.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
98 If N is negative, move backward instead."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
99 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
100 (let ((function (if (< n 0) 'previous-single-property-change
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
101 'next-single-property-change))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
102 (inhibit-point-motion-hooks t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
103 (backward (< n 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
104 (limit (if (< n 0) (point-min) (point-max))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
105 (setq n (abs n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
106 (while (and (not (= limit (point)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
107 (> n 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
108 ;; Skip past the current button.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
109 (when (get-text-property (point) 'earcon-callback)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
110 (goto-char (funcall function (point) 'earcon-callback nil limit)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
111 ;; Go to the next (or previous) button.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
112 (gnus-goto-char (funcall function (point) 'earcon-callback nil limit))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
113 ;; Put point at the start of the button.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
114 (when (and backward (not (get-text-property (point) 'earcon-callback)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
115 (goto-char (funcall function (point) 'earcon-callback nil limit)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
116 ;; Skip past intangible buttons.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
117 (when (get-text-property (point) 'intangible)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
118 (incf n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
119 (decf n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
120 (unless (zerop n)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
121 (gnus-message 5 "No more buttons"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
122 n))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
123
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
124 (defun earcon-article-add-button (from to fun &optional data)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
125 "Create a button between FROM and TO with callback FUN and data DATA."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
126 (and (boundp gnus-article-button-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
127 gnus-article-button-face
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
128 (gnus-overlay-put (gnus-make-overlay from to)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
129 'face gnus-article-button-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
130 (gnus-add-text-properties
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
131 from to
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
132 (nconc (and gnus-article-mouse-face
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
133 (list gnus-mouse-face-prop gnus-article-mouse-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
134 (list 'gnus-callback fun)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
135 (and data (list 'gnus-data data)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
136
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
137 (defun earcon-button-entry ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
138 ;; Return the first entry in `gnus-button-alist' matching this place.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
139 (let ((alist earcon-regexp-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
140 (case-fold-search t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
141 (entry nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
142 (while alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
143 (setq entry (pop alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
144 (if (looking-at (car entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
145 (setq alist nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
146 (setq entry nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
147 entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
148
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
149
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
150 (defun earcon-button-push (marker)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
151 ;; Push button starting at MARKER.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
152 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
153 (set-buffer gnus-article-buffer)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
154 (goto-char marker)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
155 (let* ((entry (earcon-button-entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
156 (inhibit-point-motion-hooks t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
157 (fun 'gnus-sound-play)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
158 (args (list (nth 2 entry))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
159 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
160 ((fboundp fun)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
161 (apply fun args))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
162 ((and (boundp fun)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
163 (fboundp (symbol-value fun)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
164 (apply (symbol-value fun) args))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
165 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
166 (gnus-message 1 "You must define `%S' to use this button"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
167 (cons fun args)))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
168
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
169 ;;; FIXME!! clone of code from gnus-vis.el FIXME!!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
170
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
171 ;;;###interactive
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
172 (defun earcon-region (beg end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
173 "Play Sounds in the region between point and mark."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
174 (interactive "r")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
175 (earcon-buffer (current-buffer) beg end))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
176
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
177 ;;;###interactive
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
178 (defun earcon-buffer (&optional buffer st nd)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
179 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
180 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
181 ;; clear old markers.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
182 (if (boundp 'earcon-button-marker-list)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
183 (while earcon-button-marker-list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
184 (set-marker (pop earcon-button-marker-list) nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
185 (setq earcon-button-marker-list nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
186 (and buffer (set-buffer buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
187 (let ((buffer-read-only nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
188 (inhibit-point-motion-hooks t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
189 (case-fold-search t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
190 (alist earcon-regexp-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
191 beg entry regexp)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
192 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
193 (setq beg (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
194 (while (setq entry (pop alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
195 (setq regexp (concat (regexp-quote earcon-prefix)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
196 ".*\\("
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
197 (car entry)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
198 "\\).*"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
199 (regexp-quote earcon-suffix)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
200 (goto-char beg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
201 (while (re-search-forward regexp nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
202 (let* ((start (and entry (match-beginning 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
203 (end (and entry (match-end 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
204 (from (match-beginning 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
205 (earcon-article-add-button
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
206 start end 'earcon-button-push
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
207 (car (push (set-marker (make-marker) from)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
208 earcon-button-marker-list)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
209 (gnus-sound-play (caddr entry))))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
210
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
211 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
212 (defun gnus-earcon-display ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
213 "Play sounds in message buffers."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
214 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
215 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
216 (set-buffer gnus-article-buffer)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
217 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
218 ;; Skip headers
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
219 (unless (search-forward "\n\n" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
220 (goto-char (point-max)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
221 (sit-for 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
222 (earcon-buffer (current-buffer) (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
223
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
224 ;;;***
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
225
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
226 (provide 'earcon)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
227
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
228 (run-hooks 'earcon-load-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
229
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
230 ;;; earcon.el ends here