diff options
| author | Simon Marshall | 1995-02-25 16:10:01 +0000 |
|---|---|---|
| committer | Simon Marshall | 1995-02-25 16:10:01 +0000 |
| commit | 8079b5901c7cd5885b085bce67b5a151d7c146bf (patch) | |
| tree | 86e2b93e2674f02a4589cdd36a16b1425ae8c968 | |
| parent | 81fb2771d991555e1ddfb454e19d5ad478220a9d (diff) | |
| download | emacs-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.el | 23 |
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 | ||
| 157 | Detecting executability of files may slow command completion considerably.") | 157 | Detecting 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. | ||
| 161 | Shell 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. |
| 252 | Return 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. |
| 254 | Return 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 | |||
| 260 | If you want to make multiple shell buffers, rename the `*shell*' buffer | 264 | If you want to make multiple shell buffers, rename the `*shell*' buffer |
| 261 | using \\[rename-buffer] or \\[rename-uniquely] and start a new shell. | 265 | using \\[rename-buffer] or \\[rename-uniquely] and start a new shell. |
| 262 | 266 | ||
| 267 | If you want to make shell buffers limited in length, add the function | ||
| 268 | `shell-truncate-buffer' to `comint-output-filter-functions'. | ||
| 269 | |||
| 263 | If you accidentally suspend your process, use \\[comint-continue-subjob] | 270 | If you accidentally suspend your process, use \\[comint-continue-subjob] |
| 264 | to continue it. | 271 | to 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. |
| 629 | See `shell-command-regexp'." | 644 | See `shell-command-regexp'." |