From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/7023 Path: main.gmane.org!not-for-mail From: Steven L Baur Newsgroups: gmane.emacs.gnus.general Subject: earcon.el/gnus-sond.el for Gnus 5.2.29 Date: 27 Jun 1996 22:31:26 -0700 Sender: steve@miranova.com Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 (generated by tm-edit 7.69) Content-Type: multipart/mixed; boundary="Multipart_Thu_Jun_27_22:31:25_1996-1" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035147394 5598 80.91.224.250 (20 Oct 2002 20:56:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 20:56:34 +0000 (UTC) Return-Path: ding-request@ifi.uio.no Original-Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.7.5/8.6.9) with SMTP id XAA19701 for ; Thu, 27 Jun 1996 23:27:56 -0700 Original-Received: from deanna.miranova.com (steve@deanna.miranova.com [206.190.83.1]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Fri, 28 Jun 1996 07:32:14 +0200 Original-Received: (from steve@localhost) by deanna.miranova.com (8.7.5/8.6.9) id WAA19586; Thu, 27 Jun 1996 22:31:29 -0700 Original-To: ding@ifi.uio.no X-Url: http://www.miranova.com/%7Esteve/ Mail-Copies-To: never X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5" f8*@r4ipO6Jl!:Ccqp:9I OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+ Original-Lines: 416 X-Mailer: Gnus v5.2.29/XEmacs 20.0 Xref: main.gmane.org gmane.emacs.gnus.general:7023 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:7023 --Multipart_Thu_Jun_27_22:31:25_1996-1 Content-Type: text/plain; charset=US-ASCII **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 ... :-) --Multipart_Thu_Jun_27_22:31:25_1996-1 Content-Type: application/octet-stream; type=emacs-lisp Content-Disposition: attachment; filename="gnus-sound.el" Content-Transfer-Encoding: 7bit ;;; gnus-sound.el --- Sound effects for Gnus ;; Copyright (C) 1996 Free Software Foundation ;; Author: Steven L. Baur ;; 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 --Multipart_Thu_Jun_27_22:31:25_1996-1 Content-Type: application/octet-stream; type=emacs-lisp Content-Disposition: attachment; filename="earcon.el" Content-Transfer-Encoding: 7bit ;;; earcon.el --- Sound effects for messages ;; Copyright (C) 1996 Free Software Foundation ;; Author: Steven L. Baur ;; 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 --Multipart_Thu_Jun_27_22:31:25_1996-1 Content-Type: text/plain; charset=US-ASCII -- 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. --Multipart_Thu_Jun_27_22:31:25_1996-1--