diff lisp/prim/sound.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents 9b50b4588a93
children b980b6286996
line wrap: on
line diff
--- a/lisp/prim/sound.el	Mon Aug 13 09:29:37 2007 +0200
+++ b/lisp/prim/sound.el	Mon Aug 13 09:30:11 2007 +0200
@@ -21,6 +21,94 @@
 ;; Boston, MA 02111-1307, USA.
 
 ;;; Synched up with: Not in FSF.
+(defgroup sound nil
+  "Configure XEmacs sounds and properties"
+  :group 'environment)
+ 
+(defcustom sound-default-alist
+      '((default		:sound bass)
+	(undefined-key	:sound drum)
+	(undefined-click	:sound drum)
+	;; beginning-of-buffer or end-of-buffer errors.
+	(buffer-bound	:sound drum)
+	;; buffer-read-only error
+	(read-only	        :sound drum)
+	;; non-interactive function or lambda called
+	(command-error	:sound bass)
+	(y-or-n-p		:sound quiet)
+	(yes-or-no-p		:sound quiet)
+	(auto-save-error	:sound whip :volume 100)
+	(no-completion	:sound whip)
+	(isearch-failed	:sound quiet)
+	(isearch-quit	:sound bass)
+	;; QUIT: sound generated by ^G and it's variants.
+	(quit		:sound quiet :volume 75)
+	;; READY: time-consuming task has completed...  compile,
+	;; cvs-update, etc.
+	(ready		:sound cuckoo)
+	;; WARP: XEmacs has changed the selected-window or frame
+	;; asynchronously...  Especially when it's done by an
+	;; asynchronous process filter.  Perhaps by a debugger breakpoint
+	;; has been hit?
+	(warp		:sound yeep :volume 75)
+	;; ALARM: used for reminders...
+	(alarm		:sound cuckoo :volume 100)
+	)
+      "The alist of sounds and associated error symbols.
+
+ Used to set sound-alist in load-default-sounds."
+      :group 'sound
+      :type '(repeat
+	      (group (symbol :tag "Name")
+		     (checklist :inline t
+				:greedy t
+				(group :inline t
+				       (const :format "" :value :sound)
+				       (symbol :tag "Sound"))
+				(group :inline t
+				       (const :format "" :value :volume)
+				       (integer :tag "Volume"))
+				(group :inline t
+				       (const :format "" :value :pitch)
+				       (integer :tag "Pitch"))
+				(group :inline t
+				       (const :format "" :value :duration)
+				       (integer :tag "Duration"))))))
+
+(defcustom sound-load-alist 
+  '((load-sound-file "sounds/drum-beep.au"	'drum)
+    (load-sound-file "sounds/quiet-beep.au"	'quiet)
+    (load-sound-file "sounds/bass-snap.au"	'bass 80)
+    (load-sound-file "sounds/whip.au"		'whip 70)
+    (load-sound-file "sounds/cuckoo.au"		'cuckoo)
+    (load-sound-file "sounds/yeep.au"		'yeep)
+    (load-sound-file "sounds/hype.au"		'hype 100)
+    )
+  "A list of calls to load-sound-file to be processed by load-default-sounds. 
+
+  Reference load-sound-file for more information."
+  
+  :group 'sound
+  :type '(repeat  (sexp :tag "Sound")
+		  ))
+
+(defcustom default-sound-directory data-directory
+  "Default directory to load a sound file from."
+  :group 'sound
+  :type 'directory
+  )
+
+(defcustom sound-ext ""
+  "Filename extensions to complet sound file name with. If more than one 
+   extension is used, they should be separated by \":\". "
+  :group 'sound
+  :type 'string)
+
+(defcustom default-sound-directory-list ( list default-sound-directory )
+  "List of directories which to search for sound files"
+  :group 'sound
+  :type '(repeat directory )
+  )
 
 ;;;###autoload
 (or sound-alist
@@ -48,7 +136,8 @@
 	  (set-buffer (setq buf (get-buffer-create " *sound-tmp*")))
 	  (buffer-disable-undo (current-buffer))
 	  (erase-buffer)
-	  (insert-file-contents filename)
+	  (insert-file-contents 
+	   (locate-file filename  default-sound-directory-list  sound-ext ))
 	  (setq data (buffer-string))
 	  (erase-buffer))
       (and buf (kill-buffer buf)))
@@ -74,46 +163,11 @@
   ;; #### - this should do NOTHING if the sounds can't be played.  
   (message "Loading sounds...")
   (setq sound-alist nil)
-  (let ((default-directory data-directory))
-    (load-sound-file "sounds/drum-beep.au"	'drum)
-    (load-sound-file "sounds/quiet-beep.au"	'quiet)
-    (load-sound-file "sounds/bass-snap.au"	'bass 80)
-    (load-sound-file "sounds/whip.au"		'whip 70)
-    (load-sound-file "sounds/cuckoo.au"		'cuckoo)
-    (load-sound-file "sounds/yeep.au"		'yeep)
-    (load-sound-file "sounds/hype.au"		'hype 100)
-    )
+  ;; this is where the calls to load-sound-file get done
+  (mapc 'eval sound-load-alist)
   (setq sound-alist
-	(append
-	 '((default		:sound bass)
-	   (undefined-key	:sound drum)
-	   (undefined-click	:sound drum)
-	   ;; beginning-of-buffer or end-of-buffer errors.
-	   (buffer-bound	:sound drum)
-	   ;; buffer-read-only error
-	   (read-only	        :sound drum)
-	   ;; non-interactive function or lambda called
-	   (command-error	:sound bass)
-	   (y-or-n-p		:sound quiet)
-	   (yes-or-no-p		:sound quiet)
-	   (auto-save-error	:sound whip :volume 100)
-	   (no-completion	:sound whip)
-	   (isearch-failed	:sound quiet)
-	   (isearch-quit	:sound bass)
-	   ;; QUIT: sound generated by ^G and it's variants.
-	   (quit		:sound quiet :volume 75)
-	   ;; READY: time-consuming task has completed...  compile,
-	   ;; cvs-update, etc.
-	   (ready		:sound cuckoo)
-	   ;; WARP: XEmacs has changed the selected-window or frame
-	   ;; asynchronously...  Especially when it's done by an
-	   ;; asynchronous process filter.  Perhaps by a debugger breakpoint
-	   ;; has been hit?
-	   (warp		:sound yeep :volume 75)
-	   ;; ALARM: used for reminders...
-	   (alarm		:sound cuckoo :volume 100)
-	   )
-	 sound-alist))
+	(append sound-default-alist
+		sound-alist))
   (message "Loading sounds...done")
   ;; (beep nil 'quiet)
   )