emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d0e457325d: Add a shell-filter-ring-bell function


From: Lars Ingebrigtsen
Subject: master d0e457325d: Add a shell-filter-ring-bell function
Date: Tue, 22 Mar 2022 14:16:17 -0400 (EDT)

branch: master
commit d0e457325d242466107e0c14f910eef0f1ae3599
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a shell-filter-ring-bell function
    
    * lisp/shell.el (shell-mode): Mention it.
    (shell-filter-ring-bell): New function (bug#21652).
---
 lisp/shell.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lisp/shell.el b/lisp/shell.el
index 565ededa1e..008fcc4c4e 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.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]