X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fsound.el;h=46e277c2dd32d07e67fcfef7cec74d7eab35f55a;hb=515ed47192a2fc212474dc246a875771890e0cbe;hp=62b2706deafdfe2e2f34c6bad62f9d0d50b43bac;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git.1 diff --git a/lisp/sound.el b/lisp/sound.el index 62b2706..46e277c 100644 --- a/lisp/sound.el +++ b/lisp/sound.el @@ -82,7 +82,7 @@ (const :format "" :value :duration) (integer :tag "Duration")))))) -(defcustom sound-load-alist +(defcustom sound-load-list '((load-sound-file "drum-beep" 'drum) (load-sound-file "quiet-beep" 'quiet) (load-sound-file "bass-snap" 'bass 80) @@ -105,16 +105,20 @@ :type 'directory ) -(defcustom sound-ext (if (or (eq system-type 'cygwin32) - (eq system-type 'windows-nt)) - ".wav:" ".au:") +;; #### This should really be a list. --hniksic +(defcustom sound-extension-list (cond ((or (eq system-type 'cygwin32) + (eq system-type 'windows-nt)) + ".wav:") + ((eq system-type 'linux) + ".wav:.au:") + (t + ".au:")) "Filename extensions to complete 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 ) - +(defcustom default-sound-directory-list (locate-data-directory-list "sounds") "List of directories which to search for sound files" :group 'sound :type '(repeat directory ) @@ -129,6 +133,11 @@ (defun load-sound-file (filename sound-name &optional volume) "Read in an audio-file and add it to the sound-alist. +FILENAME can either be absolute or relative, in which case the file will +be searched in the directories given by `default-sound-directory-list'. +When looking for the file, the extensions given by `sound-extension-list' are +also tried in the given order. + You can only play sound files if you are running on display 0 of the console of a machine with native sound support or running a NetAudio server and XEmacs has the necessary sound support compiled in. @@ -142,9 +151,18 @@ nVolume (0 for default): ") (error "sound-name not a symbol")) (unless (or (null volume) (integerp volume)) (error "volume not an integer or nil")) - (let (buf - data - (file (locate-file filename default-sound-directory-list sound-ext))) + (let ((file (if (file-name-absolute-p filename) + ;; For absolute file names, we don't have on choice on the + ;; location, but sound extensions however can still be tried + (setq file (locate-file filename + (list (file-name-directory filename)) + (split-string sound-extension-list + ":"))) + (setq file (locate-file filename + default-sound-directory-list + (split-string sound-extension-list + ":"))))) + buf data) (unless file (error "Couldn't load sound file %s" filename)) (unwind-protect @@ -161,12 +179,11 @@ nVolume (0 for default): ") ;; some conses in sound-alist might have been dumped with emacs. (if old (setq sound-alist (delq old (copy-sequence sound-alist))))) (setq sound-alist (cons - (purecopy - (nconc (list sound-name) - (if (and volume (not (eq 0 volume))) - (list ':volume volume)) - (list ':sound data))) - sound-alist))) + (nconc (list sound-name) + (if (and volume (not (eq 0 volume))) + (list ':volume volume)) + (list ':sound data)) + sound-alist))) sound-name) ;;;###autoload @@ -180,7 +197,7 @@ server and XEmacs has the necessary sound support compiled in." (message "Loading sounds...") (setq sound-alist nil) ;; this is where the calls to load-sound-file get done - (mapc 'eval sound-load-alist) + (mapc 'eval sound-load-list) (setq sound-alist (append sound-default-alist sound-alist))