X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fearcon.el;h=2086f86c4176b08fd6939c0c560f19849c4a76e6;hb=74a489ff1213794152d6e13f7a11e16c89f62602;hp=cd894829106f0d0e347fa94adf07f31a605ba89f;hpb=c8a3ee0ce77ae60b50c02e626af979b263307692;p=gnus diff --git a/lisp/earcon.el b/lisp/earcon.el index cd8948291..2086f86c4 100644 --- a/lisp/earcon.el +++ b/lisp/earcon.el @@ -1,15 +1,16 @@ ;;; earcon.el --- Sound effects for messages -;; Copyright (C) 1996 Free Software Foundation + +;; Copyright (C) 1996, 2000, 2001, 2002, 2003, 2004, +;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; 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 +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -17,41 +18,42 @@ ;; 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. +;; along with GNU Emacs. If not, see . ;;; 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) -(require 'gnus-sound) (eval-when-compile (require 'cl)) +(require 'gnus) +(require 'gnus-audio) +(require 'gnus-art) -(defvar earcon-auto-play nil - "When True, automatially play sounds as well as buttonize them.") +(defgroup earcon nil + "Turn ** sounds ** into noise." + :group 'gnus-visual) -(defvar earcon-prefix "**" - "The start of an earcon") +(defcustom earcon-prefix "**" + "*String denoting the start of an earcon." + :type 'string + :group 'earcon) -(defvar earcon-suffix "**" - "The end of an earcon") +(defcustom earcon-suffix "**" + "String denoting the end of an earcon." + :type 'string + :group 'earcon) -(defvar earcon-regexp-alist +(defcustom 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") + ("meow" 1 "catmeow.wav") ("sob\\|boohoo" 1 "cry.wav") ("drum[ \t]*roll" 1 "drumroll.au") ("blast" 1 "explosion.au") - ("flush" 1 "flush.au") + ("flush\\|plonk!*" 1 "flush.au") ("kiss" 1 "kiss.wav") ("tee[ \t]*hee" 1 "laugh.au") ("shoot" 1 "shotgun.wav") @@ -59,13 +61,14 @@ ("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.") - + "*A list of regexps to map earcons to real sounds." + :type '(repeat (list regexp + (integer :tag "Match") + (string :tag "Sound"))) + :group 'earcon) (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. @@ -74,7 +77,7 @@ 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)) + (data (get-text-property pos 'earcon-data)) (fun (get-text-property pos 'earcon-callback))) (if fun (funcall fun data)))) @@ -127,7 +130,7 @@ If N is negative, move backward instead." gnus-article-button-face (gnus-overlay-put (gnus-make-overlay from to) 'face gnus-article-button-face)) - (gnus-add-text-properties + (gnus-add-text-properties from to (nconc (and gnus-article-mouse-face (list gnus-mouse-face-prop gnus-article-mouse-face)) @@ -146,15 +149,13 @@ If N is negative, move backward instead." (setq entry nil))) entry)) - (defun earcon-button-push (marker) ;; Push button starting at MARKER. - (save-excursion - (set-buffer gnus-article-buffer) + (with-current-buffer gnus-article-buffer (goto-char marker) (let* ((entry (earcon-button-entry)) (inhibit-point-motion-hooks t) - (fun 'gnus-sound-play) + (fun 'gnus-audio-play) (args (list (nth 2 entry)))) (cond ((fboundp fun) @@ -193,10 +194,10 @@ If N is negative, move backward instead." (setq beg (point)) (while (setq entry (pop alist)) (setq regexp (concat (regexp-quote earcon-prefix) - ".*\\(" - (car entry) - "\\).*" - (regexp-quote earcon-suffix))) + ".*\\(" + (car entry) + "\\).*" + (regexp-quote earcon-suffix))) (goto-char beg) (while (re-search-forward regexp nil t) (let* ((start (and entry (match-beginning 1))) @@ -206,14 +207,13 @@ If N is negative, move backward instead." start end 'earcon-button-push (car (push (set-marker (make-marker) from) earcon-button-marker-list))) - (gnus-sound-play (caddr entry)))))))) + (gnus-audio-play (caddr entry)))))))) ;;;###autoload (defun gnus-earcon-display () "Play sounds in message buffers." (interactive) - (save-excursion - (set-buffer gnus-article-buffer) + (with-current-buffer gnus-article-buffer (goto-char (point-min)) ;; Skip headers (unless (search-forward "\n\n" nil t)