Mercurial > emacs
comparison lisp/shell.el @ 10831:94811e4b2a06
Added shell-truncate-buffer function to restrict buffer size to
at most shell-buffer-maximum-size lines in length.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Sat, 25 Feb 1995 16:10:01 +0000 |
parents | 1d1db37a4bb7 |
children | 32d4c4ca1ff8 |
comparison
equal
deleted
inserted
replaced
10830:a774e92de39c | 10831:94811e4b2a06 |
---|---|
154 "*If non-nil, use executable files only for completion candidates. | 154 "*If non-nil, use executable files only for completion candidates. |
155 This mirrors the optional behavior of tcsh. | 155 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 |
162 (defvar shell-pushd-regexp "pushd" | 166 (defvar shell-pushd-regexp "pushd" |
163 "*Regexp to match subshell commands equivalent to pushd.") | 167 "*Regexp to match subshell commands equivalent to pushd.") |
247 ;;; =========================================================================== | 251 ;;; =========================================================================== |
248 ;;; | 252 ;;; |
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'. |
259 | 263 |
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. |
266 | |
267 If you want to make shell buffers limited in length, add the function | |
268 `shell-truncate-buffer' to `comint-output-filter-functions'. | |
262 | 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 |
266 `cd', `pushd' and `popd' commands given to the shell are watched by Emacs to | 273 `cd', `pushd' and `popd' commands given to the shell are watched by Emacs to |
622 (setcar ds dir)) | 629 (setcar ds dir)) |
623 (setq msg (concat msg (directory-file-name dir) " ")) | 630 (setq msg (concat msg (directory-file-name dir) " ")) |
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'." |
630 (interactive "p") | 645 (interactive "p") |
631 (let ((limit (save-excursion (end-of-line nil) (point)))) | 646 (let ((limit (save-excursion (end-of-line nil) (point)))) |