24

Is there a way to disable the beep in Emacs when trying to move the cursor beyond the beginning or end of a document? I normally wouldn't mind, but the momentum scrolling on my trackpad makes it so that it beeps a dozen times whenever I scroll to the top or bottom of a document.

I'd rather not disable the bell for other things, if that's possible.

asmeurer
  • 86,894
  • 26
  • 169
  • 240
  • 1
    [disable-carbon-emacs-scroll-beep][1] ? [1]: http://stackoverflow.com/questions/324457/disable-carbon-emacs-scroll-beep – ChrisSM Jul 27 '12 at 00:41

2 Answers2

34

Put

(setq ring-bell-function 'ignore)

in your .emacs. This will disable the bell entirely, which might not be what you want.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • 3
    This disables the bell entirely, which isn't quite what the question was asking, but happens to be exactly what I was looking for. Thanks! – Keegan Quinn Oct 15 '14 at 16:48
22

This works pretty well for me to disable the bell just when scrolling to limits (add the following to your .emacs or other init file) :

(defun my-bell-function ()
  (unless (memq this-command
        '(isearch-abort abort-recursive-edit exit-minibuffer
              keyboard-quit mwheel-scroll down up next-line previous-line
              backward-char forward-char))
    (ding)))
(setq ring-bell-function 'my-bell-function)

Source

Community
  • 1
  • 1
Keith Flower
  • 4,032
  • 25
  • 16
  • Nice. I actually am perfectly fine with also disabling it for those other things too. I just added my custom scrolling functions from http://stackoverflow.com/questions/11532149/emacs-make-custom-scrolling-function-follow-mouse-but-not-change-keyboard-focus to that list and it seems to work. – asmeurer Jul 27 '12 at 00:11