Gnus development mailing list
 help / color / mirror / Atom feed
* earcon.el/gnus-sond.el for Gnus 5.2.29
@ 1996-06-28  5:31 Steven L Baur
  1996-06-28 20:13 ` Greg Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Steven L Baur @ 1996-06-28  5:31 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

**drumroll** please ...

Continuing in the fine tradition of Gnus leadership in multimedia News
and Mail, here is earcon.el & gnus-sound.el.  :-)

To use, put
(require 'earcons)
(add-hook 'gnus-article-display-hook 'gnus-earcon-display)
in your .gnus.

The sound files are available here
	ftp://ftp.miranova.com/pub/people/Steve.Baur/Gnus-Sounds.tar.gz

Install the sounds in gnus-5.2.29/etc/sounds

You have a choice between buttonizing earcons a la URL buttons, or
having them played when a message is displayed (controlled through the
earcon-auto-play variable).  To play a buttonized earcon, select them
the same way you select URLs.  The sound playing function is portable
to GNU Emacs, but you will need a .wav player to play all of the
sounds currently being used.  Perhaps Mark Boyns can fix this.  You
can customize the sound playing programs by modifying the appropriate
variables in gnus-sound.el.  If you don't have a showaudio script, use

#! /bin/sh
/bin/cat $* > /dev/audio


There are currently some dependencies on Gnus utility functions that
will need to be modularized out of Gnus to make this code usable with
W3, VM, etc.

Earcons are recognized in three pieces a prefix, a label, and a
suffix.  The prefix and suffix are currently set to `**'.  The label
determines which sound gets selected.

This is a plug-in to Gnus, so if it makes you **gag**, you can just
**flush** it away ...  :-)

[-- Attachment #2: gnus-sound.el --]
[-- Type: application/octet-stream, Size: 4189 bytes --]

;;; gnus-sound.el --- Sound effects for Gnus
;; Copyright (C) 1996 Free Software Foundation

;; Author: Steven L. Baur <steve@miranova.com>
;; Keywords: news

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:
;; This file provides access to sound effects in Gnus.
;; Prerelease:  This file is partially stripped to support earcons.el
;; You can safely ignore most of it until Red Gnus. **Evil Laugh**
;;; Code:

(if (null (boundp 'running-xemacs))
    (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)))

(require 'nnheader)
(eval-when-compile (require 'cl))

(defvar gnus-sound-inline-sound
  (and (fboundp 'device-sound-enabled-p)
       (device-sound-enabled-p))
  "When t, we will not spawn a subprocess to play sounds.")

(defvar gnus-sound-directory (nnheader-find-etc-directory "sounds")
  "The directory containing the Sound Files.")

(defvar gnus-sound-au-player "/usr/bin/showaudio"
  "Executable program for playing sun AU format sound files")
(defvar gnus-sound-wav-player "/usr/local/bin/play"
  "Executable program for playing WAV files")


;;; The following isn't implemented yet.  Wait for Red Gnus.
;(defvar gnus-sound-effects-enabled t
;  "When t, Gnus will use sound effects.")
;(defvar gnus-sound-enable-hooks nil
;  "Functions run when enabling sound effects.")
;(defvar gnus-sound-disable-hooks nil
;  "Functions run when disabling sound effects.")
;(defvar gnus-sound-theme-song nil
;  "Theme song for Gnus.")
;(defvar gnus-sound-enter-group nil
;  "Sound effect played when selecting a group.")
;(defvar gnus-sound-exit-group nil
;  "Sound effect played when exiting a group.")
;(defvar gnus-sound-score-group nil
;  "Sound effect played when scoring a group.")
;(defvar gnus-sound-busy-sound nil
;  "Sound effect played when going into a ... sequence.")


;;;###autoload
;(defun gnus-sound-enable-sound ()
;  "Enable Sound Effects for Gnus."
;  (interactive)
;  (setq gnus-sound-effects-enabled t)
;  (run-hooks gnus-sound-enable-hooks))

;;;###autoload
;(defun gnus-sound-disable-sound ()
;  "Disable Sound Effects for Gnus."
;  (interactive)
;  (setq gnus-sound-effects-enabled nil)
;  (run-hooks gnus-sound-disable-hooks))

;;;###autoload
(defun gnus-sound-play (file)
  "Play a sound through the speaker."
  (interactive)
  (let ((sound-file (if (file-exists-p file)
			file
		      (concat gnus-sound-directory file))))
    (when (file-exists-p sound-file)
      (if gnus-sound-inline-sound
	  (play-sound-file (concat gnus-sound-directory sound-file))
	(cond ((string-match "\\.wav$" sound-file)
	       (call-process gnus-sound-wav-player
			     (concat gnus-sound-directory sound-file)
			     0
			     nil))
	      ((string-match "\\.au$" sound-file)
	       (call-process gnus-sound-au-player
			     (concat gnus-sound-directory sound-file)
			     0
			     nil)))))))


;;; The following isn't implemented yet, wait for Red Gnus
;(defun gnus-sound-startrek-sounds ()
;  "Enable sounds from Star Trek the original series."
;  (interactive)
;  (setq gnus-sound-busy-sound "working.au")
;  (setq gnus-sound-enter-group "bulkhead_door.au")
;  (setq gnus-sound-exit-group "bulkhead_door.au")
;  (setq gnus-sound-score-group "ST_laser.au")
;  (setq gnus-sound-theme-song "startrek.au")
;  (add-hook 'gnus-select-group-hook 'gnus-sound-startrek-select-group)
;  (add-hook 'gnus-exit-group-hook 'gnus-sound-startrek-exit-group))
;;;***

(provide 'gnus-sound)

(run-hooks 'gnus-sound-load-hook)

;;; gnus-sound.el ends here

[-- Attachment #3: earcon.el --]
[-- Type: application/octet-stream, Size: 7316 bytes --]

;;; earcon.el --- Sound effects for messages
;; Copyright (C) 1996 Free Software Foundation

;; Author: Steven L. Baur <steve@miranova.com>
;; Keywords: news fun sound

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:
;; This file provides access to sound effects in Gnus.

;;; Code:

(if (null (boundp 'running-xemacs))
    (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)))

(require 'gnus-sound)
(eval-when-compile (require 'cl))

(defvar earcon-auto-play nil
  "When True, automatially play sounds as well as buttonize them.")

(defvar earcon-prefix "**"
  "The start of an earcon")

(defvar earcon-suffix "**"
  "The end of an earcon")

(defvar earcon-regexp-alist
  '(("boring" 1 "Boring.au")
    ("evil[ \t]+laugh" 1 "Evil_Laugh.au")
    ("gag\\|puke" 1 "Puke.au")
    ("snicker" 1 "Snicker.au")
    ("meow" 1 "catmeow.au")
    ("sob\\|boohoo" 1 "cry.wav")
    ("drum[ \t]*roll" 1 "drumroll.au")
    ("blast" 1 "explosion.au")
    ("flush" 1 "flush.au")
    ("kiss" 1 "kiss.wav")
    ("tee[ \t]*hee" 1 "laugh.au")
    ("shoot" 1 "shotgun.wav")
    ("yawn" 1 "snore.wav")
    ("cackle" 1 "witch.au")
    ("yell\\|roar" 1 "yell2.au")
    ("whoop-de-doo" 1 "whistle.au"))
  "A list of regexps to map earcons to real sounds.")

(defvar earcon-button-marker-list nil)
(make-variable-buffer-local 'earcon-button-marker-list)



;;; FIXME!! clone of code from gnus-vis.el FIXME!!
(defun earcon-article-push-button (event)
  "Check text under the mouse pointer for a callback function.
If the text under the mouse pointer has a `earcon-callback' property,
call it with the value of the `earcon-data' text property."
  (interactive "e")
  (set-buffer (window-buffer (posn-window (event-start event))))
  (let* ((pos (posn-point (event-start event)))
         (data (get-text-property pos 'earcon-data))
	 (fun (get-text-property pos 'earcon-callback)))
    (if fun (funcall fun data))))

(defun earcon-article-press-button ()
  "Check text at point for a callback function.
If the text at point has a `earcon-callback' property,
call it with the value of the `earcon-data' text property."
  (interactive)
  (let* ((data (get-text-property (point) 'earcon-data))
	 (fun (get-text-property (point) 'earcon-callback)))
    (if fun (funcall fun data))))

(defun earcon-article-prev-button (n)
  "Move point to N buttons backward.
If N is negative, move forward instead."
  (interactive "p")
  (earcon-article-next-button (- n)))

(defun earcon-article-next-button (n)
  "Move point to N buttons forward.
If N is negative, move backward instead."
  (interactive "p")
  (let ((function (if (< n 0) 'previous-single-property-change
		    'next-single-property-change))
	(inhibit-point-motion-hooks t)
	(backward (< n 0))
	(limit (if (< n 0) (point-min) (point-max))))
    (setq n (abs n))
    (while (and (not (= limit (point)))
		(> n 0))
      ;; Skip past the current button.
      (when (get-text-property (point) 'earcon-callback)
	(goto-char (funcall function (point) 'earcon-callback nil limit)))
      ;; Go to the next (or previous) button.
      (gnus-goto-char (funcall function (point) 'earcon-callback nil limit))
      ;; Put point at the start of the button.
      (when (and backward (not (get-text-property (point) 'earcon-callback)))
	(goto-char (funcall function (point) 'earcon-callback nil limit)))
      ;; Skip past intangible buttons.
      (when (get-text-property (point) 'intangible)
	(incf n))
      (decf n))
    (unless (zerop n)
      (gnus-message 5 "No more buttons"))
    n))

(defun earcon-article-add-button (from to fun &optional data)
  "Create a button between FROM and TO with callback FUN and data DATA."
  (and (boundp gnus-article-button-face)
       gnus-article-button-face
       (gnus-overlay-put (gnus-make-overlay from to)
			 'face gnus-article-button-face))
  (gnus-add-text-properties 
   from to
   (nconc (and gnus-article-mouse-face
	       (list gnus-mouse-face-prop gnus-article-mouse-face))
	  (list 'gnus-callback fun)
	  (and data (list 'gnus-data data)))))

(defun earcon-button-entry ()
  ;; Return the first entry in `gnus-button-alist' matching this place.
  (let ((alist earcon-regexp-alist)
	(case-fold-search t)
	(entry nil))
    (while alist
      (setq entry (pop alist))
      (if (looking-at (car entry))
	  (setq alist nil)
	(setq entry nil)))
    entry))


(defun earcon-button-push (marker)
  ;; Push button starting at MARKER.
  (save-excursion
    (set-buffer gnus-article-buffer)
    (goto-char marker)
    (let* ((entry (earcon-button-entry))
	   (inhibit-point-motion-hooks t)
	   (fun 'gnus-sound-play)
	   (args (list (nth 2 entry))))
      (cond
       ((fboundp fun)
	(apply fun args))
       ((and (boundp fun)
	     (fboundp (symbol-value fun)))
	(apply (symbol-value fun) args))
       (t
	(gnus-message 1 "You must define `%S' to use this button"
		      (cons fun args)))))))

;;; FIXME!! clone of code from gnus-vis.el FIXME!!

;;;###interactive
(defun earcon-region (beg end)
  "Play Sounds in the region between point and mark."
  (interactive "r")
  (earcon-buffer (current-buffer) beg end))

;;;###interactive
(defun earcon-buffer (&optional buffer st nd)
  (interactive)
  (save-excursion
    ;; clear old markers.
    (if (boundp 'earcon-button-marker-list)
	(while earcon-button-marker-list
	  (set-marker (pop earcon-button-marker-list) nil))
      (setq earcon-button-marker-list nil))
    (and buffer (set-buffer buffer))
    (let ((buffer-read-only nil)
	  (inhibit-point-motion-hooks t)
	  (case-fold-search t)
	  (alist earcon-regexp-alist)
	  beg entry regexp)
      (goto-char (point-min))
      (setq beg (point))
      (while (setq entry (pop alist))
	(setq regexp (concat (regexp-quote earcon-prefix)
			      ".*\\("
			      (car entry)
			      "\\).*"
			      (regexp-quote earcon-suffix)))
	(goto-char beg)
	(while (re-search-forward regexp nil t)
	  (let* ((start (and entry (match-beginning 1)))
		 (end (and entry (match-end 1)))
		 (from (match-beginning 1)))
	    (earcon-article-add-button
	     start end 'earcon-button-push
	     (car (push (set-marker (make-marker) from)
			earcon-button-marker-list)))
	    (gnus-sound-play (caddr entry))))))))

;;;###autoload
(defun gnus-earcon-display ()
  "Play sounds in message buffers."
  (interactive)
  (save-excursion
    (set-buffer gnus-article-buffer)
    (goto-char (point-min))
    ;; Skip headers
    (unless (search-forward "\n\n" nil t)
      (goto-char (point-max)))
    (sit-for 0)
    (earcon-buffer (current-buffer) (point))))

;;;***

(provide 'earcon)

(run-hooks 'earcon-load-hook)

;;; earcon.el ends here

[-- Attachment #4: Type: text/plain, Size: 192 bytes --]


-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be proofread for $250/hour.
Andrea Seastrand: For your vote on the Telecom bill, I will vote for anyone
except you in November.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: earcon.el/gnus-sond.el for Gnus 5.2.29
  1996-06-28  5:31 earcon.el/gnus-sond.el for Gnus 5.2.29 Steven L Baur
@ 1996-06-28 20:13 ` Greg Thompson
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Thompson @ 1996-06-28 20:13 UTC (permalink / raw)


how about making gnus-sound divine the players from the user's
.mailcap if she/he has one?
-- 
		-greg	    loaded up on dynamite. hey brother can you
			    spare a light. i'm going to scrape the sky
				  tonight and shake down all the stars
						      -poster children


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-06-28 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-28  5:31 earcon.el/gnus-sond.el for Gnus 5.2.29 Steven L Baur
1996-06-28 20:13 ` Greg Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).