aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1995-02-25 16:10:01 +0000
committerSimon Marshall1995-02-25 16:10:01 +0000
commit8079b5901c7cd5885b085bce67b5a151d7c146bf (patch)
tree86e2b93e2674f02a4589cdd36a16b1425ae8c968
parent81fb2771d991555e1ddfb454e19d5ad478220a9d (diff)
downloademacs-8079b5901c7cd5885b085bce67b5a151d7c146bf.tar.gz
emacs-8079b5901c7cd5885b085bce67b5a151d7c146bf.zip
Added shell-truncate-buffer function to restrict buffer size to
at most shell-buffer-maximum-size lines in length.
-rw-r--r--lisp/shell.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index cfd92282a87..64b52c4f1ef 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -156,6 +156,10 @@ This mirrors the optional behavior of tcsh.
156 156
157Detecting executability of files may slow command completion considerably.") 157Detecting executability of files may slow command completion considerably.")
158 158
159(defvar shell-buffer-maximum-size 1024
160 "*The maximum size in lines for shell buffers.
161Shell buffers are truncated from the top to be no greater than this number.")
162
159(defvar shell-popd-regexp "popd" 163(defvar shell-popd-regexp "popd"
160 "*Regexp to match subshell commands equivalent to popd.") 164 "*Regexp to match subshell commands equivalent to popd.")
161 165
@@ -249,10 +253,10 @@ Thus, this does not include the shell's current directory.")
249 253
250(defun shell-mode () 254(defun shell-mode ()
251 "Major mode for interacting with an inferior shell. 255 "Major mode for interacting with an inferior shell.
252Return after the end of the process' output sends the text from the 256\\[comint-send-input] after the end of the process' output sends the text from
253 end of process to the end of the current line. 257 the end of process to the end of the current line.
254Return before end of process output copies the current line (except 258\\[comint-send-input] before end of process output copies the current line minus the prompt to
255 for the prompt) to the end of the buffer and sends it. 259 the end of the buffer and sends it (\\[comint-copy-old-input] just copies the current line).
256\\[send-invisible] reads a line of text without echoing it, and sends it to 260\\[send-invisible] reads a line of text without echoing it, and sends it to
257 the shell. This is useful for entering passwords. Or, add the function 261 the shell. This is useful for entering passwords. Or, add the function
258 `comint-watch-for-password-prompt' to `comint-output-filter-functions'. 262 `comint-watch-for-password-prompt' to `comint-output-filter-functions'.
@@ -260,6 +264,9 @@ Return before end of process output copies the current line (except
260If you want to make multiple shell buffers, rename the `*shell*' buffer 264If you want to make multiple shell buffers, rename the `*shell*' buffer
261using \\[rename-buffer] or \\[rename-uniquely] and start a new shell. 265using \\[rename-buffer] or \\[rename-uniquely] and start a new shell.
262 266
267If you want to make shell buffers limited in length, add the function
268`shell-truncate-buffer' to `comint-output-filter-functions'.
269
263If you accidentally suspend your process, use \\[comint-continue-subjob] 270If you accidentally suspend your process, use \\[comint-continue-subjob]
264to continue it. 271to continue it.
265 272
@@ -624,6 +631,14 @@ command again."
624 (setq ds (cdr ds)))) 631 (setq ds (cdr ds))))
625 (message msg))) 632 (message msg)))
626 633
634(defun shell-truncate-buffer (string)
635 "Truncate the buffer to `shell-buffer-maximum-size'."
636 (save-excursion
637 (goto-char (point-max))
638 (forward-line (- shell-buffer-maximum-size))
639 (beginning-of-line)
640 (delete-region (point-min) (point))))
641
627(defun shell-forward-command (&optional arg) 642(defun shell-forward-command (&optional arg)
628 "Move forward across ARG shell command(s). Does not cross lines. 643 "Move forward across ARG shell command(s). Does not cross lines.
629See `shell-command-regexp'." 644See `shell-command-regexp'."