Previous: , Up: Display   [Contents][Index]


52.12 Beeping

You can make SXEmacs ring a bell, play a sound, or blink the screen to attract the user’s attention. Be conservative about how often you do this; frequent bells can become irritating. Also be careful not to use beeping alone when signaling an error is appropriate. (See Errors.)

Function: ding &optional dont-terminate sound device

This function beeps, or flashes the screen (see visible-bell below). It also terminates any keyboard macro currently executing unless dont-terminate is non-nil.

If sound is specified, it should be a symbol specifying which sound to make. This sound will be played if visible-bell is nil. This only works if sound support was compiled into the executable and you are running on the console of a Sun SparcStation, SGI, HP9000s700, or Linux PC. Otherwise you just get a beep.

The optional third argument specifies what device to make the sound on, and defaults to the selected device.

Function: beep &optional dont-terminate sound device

This is a synonym for ding.

User Option: visible-bell

This variable determines whether SXEmacs should flash the screen to represent a bell. Non-nil means yes, nil means no. On TTY devices, this is effective only if the Termcap entry for the terminal type has the visible bell flag (‘vb’) set.

Variable: sound-alist

This variable holds an alist associating names with sounds. When beep or ding is called with one of the name symbols, the associated sound will be generated instead of the standard beep.

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 (deprecated), 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).

stream

A media stream object containing the sound.

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

Note: SXEmacs must be built with sound support for your system. Not all systems support sound. See Media.

Note: The pitch, duration, and volume options are available everywhere, but many X servers ignore the ‘pitch’ option.

The following beep-types are used by SXEmacs itself:

auto-save-error

when an auto-save does not succeed

command-error

when the SXEmacs command loop catches an error

undefined-key

when you type a key that is undefined

undefined-click

when you use an undefined mouse-click combination

no-completion

during completing-read

y-or-n-p

when you type something other than ’y’ or ’n’

yes-or-no-p

when you type something other than ’yes’ or ’no’

default

used when nothing else is appropriate.

Other lisp packages may use other beep types, but these are the ones that the C kernel of SXEmacs uses.

User Option: bell-volume

This variable specifies the default volume for sounds, from 0 to 100.

Command: load-default-sounds

This function loads and installs some sound files as beep-types.

Command: load-sound-file filename sound-name &optional volume

This function reads in an audio file and adds it to sound-alist. The sound file must be in the Sun/NeXT U-LAW format. sound-name should be a symbol, specifying the name of the sound. If volume is specified, the sound will be played at that volume; otherwise, the value of bell-volume will be used.

For more information about sounds or audio in general, see See Media.


Previous: , Up: Display   [Contents][Index]