aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorRichard M. Stallman1994-03-24 07:51:27 +0000
committerRichard M. Stallman1994-03-24 07:51:27 +0000
commit56783585a4cd608322ebcb65bd9603d91d7777ab (patch)
tree91f4d1039782ac2d39dec5dcd101a2d20e2607c9 /lisp/shell.el
parent21d9bf27d7954017df88ad1dc04dc85ba277a2bd (diff)
downloademacs-56783585a4cd608322ebcb65bd9603d91d7777ab.tar.gz
emacs-56783585a4cd608322ebcb65bd9603d91d7777ab.zip
(shell-strip-ctrl-m): New command.
(shell-mode): Doc fix. (shell-dynamic-complete-as-command): Use comint-dynamic-simple-complete.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r--lisp/shell.el61
1 files changed, 24 insertions, 37 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index 369e0ac14d0..644c43c560b 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -93,6 +93,7 @@
93;;; m-c-b shell-backward-command Backward a shell command 93;;; m-c-b shell-backward-command Backward a shell command
94;;; dirs Resync the buffer's dir stack 94;;; dirs Resync the buffer's dir stack
95;;; dirtrack-toggle Turn dir tracking on/off 95;;; dirtrack-toggle Turn dir tracking on/off
96;;; shell-strip-ctrl-m Remove trailing ^Ms from output
96;;; 97;;;
97;;; The shell mode hook is shell-mode-hook 98;;; The shell mode hook is shell-mode-hook
98;;; comint-prompt-regexp is initialised to shell-prompt-pattern, for backwards 99;;; comint-prompt-regexp is initialised to shell-prompt-pattern, for backwards
@@ -286,7 +287,8 @@ Return after the end of the process' output sends the text from the
286Return before end of process output copies the current line (except 287Return before end of process output copies the current line (except
287 for the prompt) to the end of the buffer and sends it. 288 for the prompt) to the end of the buffer and sends it.
288M-x send-invisible reads a line of text without echoing it, and sends it to 289M-x send-invisible reads a line of text without echoing it, and sends it to
289 the shell. This is useful for entering passwords. 290 the shell. This is useful for entering passwords. Or, add the function
291 `comint-watch-for-password-prompt' to `comint-output-filter-functions'.
290 292
291If you accidentally suspend your process, use \\[comint-continue-subjob] 293If you accidentally suspend your process, use \\[comint-continue-subjob]
292to continue it. 294to continue it.
@@ -681,9 +683,7 @@ Returns t if successful."
681(defun shell-dynamic-complete-as-command () 683(defun shell-dynamic-complete-as-command ()
682 "Dynamically complete at point as a command. 684 "Dynamically complete at point as a command.
683See `shell-dynamic-complete-filename'. Returns t if successful." 685See `shell-dynamic-complete-filename'. Returns t if successful."
684 (let* ((completion-ignore-case nil) 686 (let* ((filename (or (comint-match-partial-filename) ""))
685 (success t)
686 (filename (or (comint-match-partial-filename) ""))
687 (pathnondir (file-name-nondirectory filename)) 687 (pathnondir (file-name-nondirectory filename))
688 (paths (cdr (reverse exec-path))) 688 (paths (cdr (reverse exec-path)))
689 (cwd (file-name-as-directory (expand-file-name default-directory))) 689 (cwd (file-name-as-directory (expand-file-name default-directory)))
@@ -711,39 +711,12 @@ See `shell-dynamic-complete-filename'. Returns t if successful."
711 (setq comps-in-path (cdr comps-in-path))) 711 (setq comps-in-path (cdr comps-in-path)))
712 (setq paths (cdr paths))) 712 (setq paths (cdr paths)))
713 ;; OK, we've got a list of completions. 713 ;; OK, we've got a list of completions.
714 (cond ((null completions) 714 (let ((success (let ((comint-completion-addsuffix nil))
715 (message "No completions of %s" filename) 715 (comint-dynamic-simple-complete pathnondir completions))))
716 (setq success nil)) 716 (if (and (memq success '(sole shortest)) comint-completion-addsuffix
717 ((= 1 (length completions)) ; Gotcha! 717 (not (file-directory-p (comint-match-partial-filename))))
718 (let ((completion (car completions))) 718 (insert " "))
719 (if (string-equal completion pathnondir) 719 success)))
720 (message "Sole completion")
721 (insert (substring (directory-file-name completion)
722 (length pathnondir)))
723 (message "Completed"))
724 (if comint-completion-addsuffix
725 (insert (if (file-directory-p completion) "/" " ")))))
726 (t ; There's no unique completion.
727 (let ((completion
728 (try-completion pathnondir (mapcar (function (lambda (x)
729 (list x)))
730 completions))))
731 ;; Insert the longest substring.
732 (insert (substring (directory-file-name completion)
733 (length pathnondir)))
734 (cond ((and comint-completion-recexact comint-completion-addsuffix
735 (string-equal pathnondir completion)
736 (member completion completions))
737 ;; It's not unique, but user wants shortest match.
738 (insert (if (file-directory-p completion) "/" " "))
739 (message "Completed shortest"))
740 ((or comint-completion-autolist
741 (string-equal pathnondir completion))
742 ;; It's not unique, list possible completions.
743 (comint-dynamic-list-completions completions))
744 (t
745 (message "Partially completed"))))))
746 success))
747 720
748 721
749(defun shell-match-partial-variable () 722(defun shell-match-partial-variable ()
@@ -833,6 +806,20 @@ Returns t if successful."
833 (message "Directory item: %d" index) 806 (message "Directory item: %d" index)
834 t)))))) 807 t))))))
835 808
809(defun shell-strip-ctrl-m (&optional string)
810 "Strip trailing `^M' characters from the current output group.
811
812This function could be in the list `comint-output-filter-functions' or bound to
813a key."
814 (interactive)
815 (let ((pmark (process-mark (get-buffer-process (current-buffer))))
816 (ctrl-m (concat (char-to-string 13) "$")))
817 (save-excursion
818 (goto-char
819 (if (interactive-p) comint-last-input-end comint-last-output-start))
820 (while (re-search-forward ctrl-m pmark t)
821 (replace-match "" t t)))))
822
836(provide 'shell) 823(provide 'shell)
837 824
838;;; shell.el ends here 825;;; shell.el ends here