]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a shell-filter-ring-bell function
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 22 Mar 2022 18:15:33 +0000 (19:15 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 22 Mar 2022 18:16:09 +0000 (19:16 +0100)
* lisp/shell.el (shell-mode): Mention it.
(shell-filter-ring-bell): New function (bug#21652).

lisp/shell.el

index 565ededa1efa8f8aa5ddae1c9258c7de33c27c98..008fcc4c4e89f83f050144e5576141cb78b85db9 100644 (file)
@@ -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.