Next: , Previous: , Up: Customization   [Contents][Index]


27.7 Changing the Bell Sound

You can now change how the audible bell sounds using the variable sound-alist.

sound-alist’s value is an list associating symbols with, among other things, strings of audio-data. When ding is called with one of the symbols, the associated sound data is played instead of the standard beep. This only works if you are logged in on the console of a machine with audio hardware. To listen to a sound of the provided type, call the function play-sound with the argument sound. You can also set the volume of the sound with the optional argument volume.

Each element of sound-alist is a list describing a sound. The first element of the list is the name of the sound being defined. Subsequent elements of the list are alternating keyword/value pairs:

sound

A string of raw sound data, or the name of another sound to play. The symbol t here means use the default X beep.

volume

An integer from 0-100, defaulting to bell-volume.

pitch

If using the default X beep, the pitch (Hz) to generate.

duration

If using the default X beep, the duration (milliseconds).

For compatibility, elements of ‘sound-alist’ may also be of the form:

( sound-name . <sound> )
( sound-name <volume> <sound> )

You should probably add things to this list by calling the function load-sound-file.

Note that you can only play audio data if running on the console screen of a machine with audio hardware which emacs understands, which at this time means a Sun SparcStation, SGI, or HP9000s700.

Also note that the pitch, duration, and volume options are available everywhere, but most X servers ignore the ‘pitch’ option.

The variable bell-volume should be an integer from 0 to 100, with 100 being loudest, which controls how loud the sounds emacs makes should be. Elements of the sound-alist may override this value. This variable applies to the standard X bell sound as well as sound files.

If the symbol t is in place of a sound-string, Emacs uses the default X beep. This allows you to define beep-types of different volumes even when not running on the console.

You can add things to this list by calling the function load-sound-file, which reads in an audio-file and adds its data to the sound-alist. You can specify the sound with the sound-name argument and the file into which the sounds are loaded with the filename argument. The optional volume argument sets the volume.

load-sound-file (filename sound-name &optional volume)

To load and install some sound files as beep-types, use the function load-default-sounds (note that this only works if you are on display 0 of a machine with audio hardware).

The following beep-types are used by Emacs itself. Other Lisp packages may use other beep types, but these are the ones that the C kernel of Emacs uses.

auto-save-error

An auto-save does not succeed

command-error

The Emacs command loop catches an error

undefined-key

You type a key that is undefined

undefined-click

You use an undefined mouse-click combination

no-completion

Completion was not possible

y-or-n-p

You type something other than the required y or n

yes-or-no-p

You type something other than yes or no


Next: , Previous: , Up: Customization   [Contents][Index]