From: Lars Ingebrigtsen Date: Tue, 22 Mar 2022 18:15:33 +0000 (+0100) Subject: Add a shell-filter-ring-bell function X-Git-Tag: emacs-29.0.90~1931^2~986 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d0e457325d242466107e0c14f910eef0f1ae3599;p=emacs.git Add a shell-filter-ring-bell function * lisp/shell.el (shell-mode): Mention it. (shell-filter-ring-bell): New function (bug#21652). --- diff --git a/lisp/shell.el b/lisp/shell.el index 565ededa1ef..008fcc4c4e8 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -570,7 +570,14 @@ the initialization of the input ring history, and history expansion. Variables `comint-output-filter-functions', a hook, and `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output' control whether input and output cause the window to scroll to the end of the -buffer." +buffer. + +By default, shell mode does nothing special when it receives a +\"bell\" character (C-g or ^G). If you + (add-hook 'comint-output-filter-functions 'shell-filter-ring-bell nil t) +from `shell-mode-hook', Emacs will call the `ding' function +whenever it receives the bell character in output from a +command." :interactive nil (setq comint-prompt-regexp shell-prompt-pattern) (shell-completion-vars) @@ -681,6 +688,13 @@ This function can be put on `comint-preoutput-filter-functions'." (replace-regexp-in-string "[\C-a\C-b]" "" string t t) string)) +(defun shell-filter-ring-bell (string) + "Call `ding' if STRING contains a \"^G\" character. +This function can be put on `comint-output-filter-functions'." + (when (string-search "\a" string) + (ding)) + string) + (defun shell-write-history-on-exit (process event) "Called when the shell process is stopped.