;;; comint.el --- general command interpreter in a window stuff
;; Copyright (C) 1988, 1990, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Olin Shivers <shivers@cs.cmu.edu>
;; Simon Marshall <simon@gnu.org>
;; Autoload is necessary for Custom to recognize old alias.
;;;###autoload
(define-obsolete-variable-alias 'comint-use-prompt-regexp-instead-of-fields
- 'comint-use-prompt-regexp "22.1")
+ 'comint-use-prompt-regexp "22.1")
(defcustom comint-mode-hook nil
"Hook run upon entry to `comint-mode'.
(define-key map "\e\C-l" 'comint-show-output)
(define-key map "\C-m" 'comint-send-input)
(define-key map "\C-d" 'comint-delchar-or-maybe-eof)
+ ;; The following two are standardly aliased to C-d,
+ ;; but they should never do EOF, just delete.
+ (define-key map [delete] 'delete-char)
+ (define-key map [kp-delete] 'delete-char)
(define-key map "\C-c " 'comint-accumulate)
(define-key map "\C-c\C-x" 'comint-get-next-from-history)
(define-key map "\C-c\C-a" 'comint-bol-or-process-mark)
;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg00827.html
;;
;; This makes it really work to keep point at the bottom.
-;;; (make-local-variable 'scroll-conservatively)
-;;; (setq scroll-conservatively 10000)
+ ;; (make-local-variable 'scroll-conservatively)
+ ;; (setq scroll-conservatively 10000)
(add-hook 'pre-command-hook 'comint-preinput-scroll-to-bottom t t)
(make-local-variable 'comint-ptyp)
(make-local-variable 'comint-process-echoes)
"Make a Comint process NAME in BUFFER, running PROGRAM.
If BUFFER is nil, it defaults to NAME surrounded by `*'s.
PROGRAM should be either a string denoting an executable program to create
-via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP
-connection to be opened via `open-network-stream'. If there is already a
-running process in that buffer, it is not restarted. Optional fourth arg
+via `start-file-process', or a cons pair of the form (HOST . SERVICE) denoting
+a TCP connection to be opened via `open-network-stream'. If there is already
+a running process in that buffer, it is not restarted. Optional fourth arg
STARTFILE is the name of a file to send the contents of to the process.
If PROGRAM is a string, any more args are arguments to PROGRAM."
- (or (fboundp 'start-process)
+ (or (fboundp 'start-file-process)
(error "Multi-processing is not supported for this system"))
(setq buffer (get-buffer-create (or buffer (concat "*" name "*"))))
;; If no process, or nuked process, crank up a new one and put buffer in
"Make a Comint process NAME in a buffer, running PROGRAM.
The name of the buffer is made by surrounding NAME with `*'s.
PROGRAM should be either a string denoting an executable program to create
-via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP
-connection to be opened via `open-network-stream'. If there is already a
-running process in that buffer, it is not restarted. Optional third arg
+via `start-file-process', or a cons pair of the form (HOST . SERVICE) denoting
+a TCP connection to be opened via `open-network-stream'. If there is already
+a running process in that buffer, it is not restarted. Optional third arg
STARTFILE is the name of a file to send the contents of the process to.
If PROGRAM is a string, any more args are arguments to PROGRAM."
(setq startfile (buffer-substring (point) (point-max)))
(delete-region (point) (point-max))
(comint-send-string proc startfile)))
- (run-hooks 'comint-exec-hook)
- buffer)))
+ (run-hooks 'comint-exec-hook)
+ buffer)))
;; This auxiliary function cranks up the process for comint-exec in
;; the appropriate environment.
;; If the command has slashes, make sure we
;; first look relative to the current directory.
(cons default-directory exec-path) exec-path)))
- (setq proc (apply 'start-process name buffer command switches)))
+ (setq proc (apply 'start-file-process name buffer command switches)))
+ ;; Some file name handler cannot start a process, fe ange-ftp.
+ (unless (processp proc) (error "No process started"))
(let ((coding-systems (process-coding-system proc)))
(setq decoding (car coding-systems)
encoding (cdr coding-systems)))
- ;; If start-process decided to use some coding system for decoding
- ;; data sent from the process and the coding system doesn't
- ;; specify EOL conversion, we had better convert CRLF to LF.
- (if (vectorp (coding-system-eol-type decoding))
- (setq decoding (coding-system-change-eol-conversion decoding 'dos)
- changed t))
- ;; Even if start-process left the coding system for encoding data
+ ;; Even if start-file-process left the coding system for encoding data
;; sent from the process undecided, we had better use the same one
;; as what we use for decoding. But, we should suppress EOL
;; conversion.
If there is no previous input at point, run the command specified
by the global keymap (usually `mouse-yank-at-point')."
(interactive "e")
+ (mouse-set-point event)
(let ((pos (posn-point (event-end event)))
field input)
(with-selected-window (posn-window (event-end event))
(defun comint-dynamic-list-input-ring-select ()
"Choose the input history entry that point is in or next to."
(interactive)
- (let (beg end completion (buffer completion-reference-buffer)
- (base-size completion-base-size))
+ (let ((buffer completion-reference-buffer)
+ (base-size completion-base-size)
+ beg end completion)
(if (and (not (eobp)) (get-text-property (point) 'mouse-face))
(setq end (point) beg (1+ (point))))
(if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
(last-command last-command)
(regexp (read-from-minibuffer prompt nil nil nil
'minibuffer-history-search-history)))
+ ;; If the user didn't enter anything, nothing is added to m-h-s-h.
+ ;; Use the previous search regexp, if there is one.
(list (if (string-equal regexp "")
- (setcar minibuffer-history-search-history
- (nth 1 minibuffer-history-search-history))
+ (or (car minibuffer-history-search-history)
+ regexp)
regexp)
(prefix-numeric-value current-prefix-arg))))
;; Note that the input string does not include its terminal newline.
(let ((proc (get-buffer-process (current-buffer))))
(if (not proc) (error "Current buffer has no process")
- (widen)
- (let* ((pmark (process-mark proc))
- (intxt (if (>= (point) (marker-position pmark))
- (progn (if comint-eol-on-send (end-of-line))
- (buffer-substring pmark (point)))
- (let ((copy (funcall comint-get-old-input)))
- (goto-char pmark)
- (insert copy)
- copy)))
- (input (if (not (eq comint-input-autoexpand 'input))
- ;; Just whatever's already there
- intxt
- ;; Expand and leave it visible in buffer
- (comint-replace-by-expanded-history t pmark)
- (buffer-substring pmark (point))))
- (history (if (not (eq comint-input-autoexpand 'history))
- input
- ;; This is messy 'cos ultimately the original
- ;; functions used do insertion, rather than return
- ;; strings. We have to expand, then insert back.
- (comint-replace-by-expanded-history t pmark)
- (let ((copy (buffer-substring pmark (point)))
- (start (point)))
- (insert input)
- (delete-region pmark start)
- copy))))
-
- (unless no-newline
- (insert ?\n))
-
- (comint-add-to-input-history history)
-
- (run-hook-with-args 'comint-input-filter-functions
- (if no-newline input
- (concat input "\n")))
-
- (let ((beg (marker-position pmark))
- (end (if no-newline (point) (1- (point))))
- (inhibit-modification-hooks t))
- (when (> end beg)
- (add-text-properties beg end
- '(front-sticky t
- font-lock-face comint-highlight-input))
- (unless comint-use-prompt-regexp
- ;; Give old user input a field property of `input', to
- ;; distinguish it from both process output and unsent
- ;; input. The terminating newline is put into a special
- ;; `boundary' field to make cursor movement between input
- ;; and output fields smoother.
- (add-text-properties
- beg end
- '(mouse-face highlight
- help-echo "mouse-2: insert after prompt as new input"
- field input))))
- (unless (or no-newline comint-use-prompt-regexp)
- ;; Cover the terminating newline
- (add-text-properties end (1+ end)
- '(rear-nonsticky t
- field boundary
- inhibit-line-move-field-capture t))))
-
- (comint-snapshot-last-prompt)
-
- (setq comint-save-input-ring-index comint-input-ring-index)
- (setq comint-input-ring-index nil)
- ;; Update the markers before we send the input
- ;; in case we get output amidst sending the input.
- (set-marker comint-last-input-start pmark)
- (set-marker comint-last-input-end (point))
- (set-marker (process-mark proc) (point))
- ;; clear the "accumulation" marker
- (set-marker comint-accum-marker nil)
- (let ((comint-input-sender-no-newline no-newline))
- (funcall comint-input-sender proc input))
-
- ;; Optionally delete echoed input (after checking it).
- (when (and comint-process-echoes (not artificial))
- (let ((echo-len (- comint-last-input-end
- comint-last-input-start)))
- ;; Wait for all input to be echoed:
- (while (and (accept-process-output proc)
- (> (+ comint-last-input-end echo-len)
- (point-max))
- (zerop
- (compare-buffer-substrings
- nil comint-last-input-start
- (- (point-max) echo-len)
- ;; Above difference is equivalent to
- ;; (+ comint-last-input-start
- ;; (- (point-max) comint-last-input-end))
- nil comint-last-input-end (point-max)))))
- (if (and
- (<= (+ comint-last-input-end echo-len)
- (point-max))
- (zerop
- (compare-buffer-substrings
- nil comint-last-input-start comint-last-input-end
- nil comint-last-input-end
- (+ comint-last-input-end echo-len))))
- ;; Certain parts of the text to be deleted may have
- ;; been mistaken for prompts. We have to prevent
- ;; problems when `comint-prompt-read-only' is non-nil.
- (let ((inhibit-read-only t))
- (delete-region comint-last-input-end
- (+ comint-last-input-end echo-len))
- (when comint-prompt-read-only
- (save-excursion
- (goto-char comint-last-input-end)
- (comint-update-fence)))))))
-
- ;; This used to call comint-output-filter-functions,
- ;; but that scrolled the buffer in undesirable ways.
- (run-hook-with-args 'comint-output-filter-functions "")))))
+ (widen)
+ (let* ((pmark (process-mark proc))
+ (intxt (if (>= (point) (marker-position pmark))
+ (progn (if comint-eol-on-send (end-of-line))
+ (buffer-substring pmark (point)))
+ (let ((copy (funcall comint-get-old-input)))
+ (goto-char pmark)
+ (insert copy)
+ copy)))
+ (input (if (not (eq comint-input-autoexpand 'input))
+ ;; Just whatever's already there
+ intxt
+ ;; Expand and leave it visible in buffer
+ (comint-replace-by-expanded-history t pmark)
+ (buffer-substring pmark (point))))
+ (history (if (not (eq comint-input-autoexpand 'history))
+ input
+ ;; This is messy 'cos ultimately the original
+ ;; functions used do insertion, rather than return
+ ;; strings. We have to expand, then insert back.
+ (comint-replace-by-expanded-history t pmark)
+ (let ((copy (buffer-substring pmark (point)))
+ (start (point)))
+ (insert input)
+ (delete-region pmark start)
+ copy))))
+
+ (unless no-newline
+ (insert ?\n))
+
+ (comint-add-to-input-history history)
+
+ (run-hook-with-args 'comint-input-filter-functions
+ (if no-newline input
+ (concat input "\n")))
+
+ (let ((beg (marker-position pmark))
+ (end (if no-newline (point) (1- (point))))
+ (inhibit-modification-hooks t))
+ (when (> end beg)
+ (add-text-properties beg end
+ '(front-sticky t
+ font-lock-face comint-highlight-input))
+ (unless comint-use-prompt-regexp
+ ;; Give old user input a field property of `input', to
+ ;; distinguish it from both process output and unsent
+ ;; input. The terminating newline is put into a special
+ ;; `boundary' field to make cursor movement between input
+ ;; and output fields smoother.
+ (add-text-properties
+ beg end
+ '(mouse-face highlight
+ help-echo "mouse-2: insert after prompt as new input"
+ field input))))
+ (unless (or no-newline comint-use-prompt-regexp)
+ ;; Cover the terminating newline
+ (add-text-properties end (1+ end)
+ '(rear-nonsticky t
+ field boundary
+ inhibit-line-move-field-capture t))))
+
+ (comint-snapshot-last-prompt)
+
+ (setq comint-save-input-ring-index comint-input-ring-index)
+ (setq comint-input-ring-index nil)
+ ;; Update the markers before we send the input
+ ;; in case we get output amidst sending the input.
+ (set-marker comint-last-input-start pmark)
+ (set-marker comint-last-input-end (point))
+ (set-marker (process-mark proc) (point))
+ ;; clear the "accumulation" marker
+ (set-marker comint-accum-marker nil)
+ (let ((comint-input-sender-no-newline no-newline))
+ (funcall comint-input-sender proc input))
+
+ ;; Optionally delete echoed input (after checking it).
+ (when (and comint-process-echoes (not artificial))
+ (let ((echo-len (- comint-last-input-end
+ comint-last-input-start)))
+ ;; Wait for all input to be echoed:
+ (while (and (accept-process-output proc)
+ (> (+ comint-last-input-end echo-len)
+ (point-max))
+ (zerop
+ (compare-buffer-substrings
+ nil comint-last-input-start
+ (- (point-max) echo-len)
+ ;; Above difference is equivalent to
+ ;; (+ comint-last-input-start
+ ;; (- (point-max) comint-last-input-end))
+ nil comint-last-input-end (point-max)))))
+ (if (and
+ (<= (+ comint-last-input-end echo-len)
+ (point-max))
+ (zerop
+ (compare-buffer-substrings
+ nil comint-last-input-start comint-last-input-end
+ nil comint-last-input-end
+ (+ comint-last-input-end echo-len))))
+ ;; Certain parts of the text to be deleted may have
+ ;; been mistaken for prompts. We have to prevent
+ ;; problems when `comint-prompt-read-only' is non-nil.
+ (let ((inhibit-read-only t))
+ (delete-region comint-last-input-end
+ (+ comint-last-input-end echo-len))
+ (when comint-prompt-read-only
+ (save-excursion
+ (goto-char comint-last-input-end)
+ (comint-update-fence)))))))
+
+ ;; This used to call comint-output-filter-functions,
+ ;; but that scrolled the buffer in undesirable ways.
+ (run-hook-with-args 'comint-output-filter-functions "")))))
(defvar comint-preoutput-filter-functions nil
"List of functions to call before inserting Comint output into the buffer.
Make single carriage returns delete to the beginning of the line.
Make backspaces delete the previous character."
(save-excursion
- ;; First do a quick check to see if there are any applicable
- ;; characters, so we can avoid calling save-match-data and
- ;; save-restriction if not.
+ ;; We used to check the existence of \b and \r at first to avoid
+ ;; calling save-match-data and save-restriction. But, such a
+ ;; check is not necessary now because we don't use regexp search
+ ;; nor save-restriction. Note that the buffer is already widen,
+ ;; and calling narrow-to-region and widen are not that heavy.
(goto-char start)
- (when (< (skip-chars-forward "^\b\r" end) (- end start))
- (save-match-data
- (save-restriction
- (widen)
- (let ((inhibit-field-text-motion t)
- (inhibit-read-only t))
- ;; CR LF -> LF
- ;; Note that this won't work properly when the CR and LF
- ;; are in different output chunks, but this is probably an
- ;; exceedingly rare case (because they are generally
- ;; written as a unit), and to delay interpretation of a
- ;; trailing CR in a chunk would result in odd interactive
- ;; behavior (and this case is probably far more common).
- (while (re-search-forward "\r$" end t)
- (delete-char -1))
- ;; bare CR -> delete preceding line
- (goto-char start)
- (while (search-forward "\r" end t)
- (delete-region (point) (line-beginning-position)))
- ;; BS -> delete preceding character
- (goto-char start)
- (while (search-forward "\b" end t)
- (delete-char -2))))))))
+ (let* ((inhibit-field-text-motion t)
+ (inhibit-read-only t)
+ (lbeg (line-beginning-position))
+ delete-end ch)
+ ;; If the preceding text is marked as "must-overwrite", record
+ ;; it in delete-end.
+ (when (and (> start (point-min))
+ (get-text-property (1- start) 'comint-must-overwrite))
+ (setq delete-end (point-marker))
+ (remove-text-properties lbeg start '(comint-must-overwrite nil)))
+ (narrow-to-region lbeg end)
+ ;; Handle BS, LF, and CR specially.
+ (while (and (skip-chars-forward "^\b\n\r") (not (eobp)))
+ (setq ch (following-char))
+ (cond ((= ch ?\b) ; CH = BS
+ (delete-char 1)
+ (if (> (point) lbeg)
+ (delete-char -1)))
+ ((= ch ?\n)
+ (when delete-end ; CH = LF
+ (if (< delete-end (point))
+ (delete-region lbeg delete-end))
+ (set-marker delete-end nil)
+ (setq delete-end nil))
+ (forward-char 1)
+ (setq lbeg (point)))
+ (t ; CH = CR
+ (delete-char 1)
+ (if delete-end
+ (when (< delete-end (point))
+ (delete-region lbeg delete-end)
+ (move-marker delete-end (point)))
+ (setq delete-end (point-marker))))))
+ (when delete-end
+ (if (< delete-end (point))
+ ;; As there's a text after the last CR, make the current
+ ;; line contain only that text.
+ (delete-region lbeg delete-end)
+ ;; Remember that the process output ends by CR, and thus we
+ ;; must overwrite the contents of the current line next
+ ;; time.
+ (put-text-property lbeg delete-end 'comint-must-overwrite t))
+ (set-marker delete-end nil))
+ (widen))))
;; The purpose of using this filter for comint processes
;; is to keep comint-last-input-end from moving forward
(if (eq scroll 'this)
(goto-char (point-max))
(walk-windows
- (function (lambda (window)
- (if (and (eq (window-buffer window) current)
- (or (eq scroll t) (eq scroll 'all)))
- (progn
- (select-window window)
- (goto-char (point-max))
- (select-window selected)))))
+ (lambda (window)
+ (if (and (eq (window-buffer window) current)
+ (or (eq scroll t) (eq scroll 'all)))
+ (progn
+ (select-window window)
+ (goto-char (point-max))
+ (select-window selected))))
nil t))))))
(defun comint-postoutput-scroll-to-bottom (string)
(unwind-protect
(if process
(walk-windows
- (function (lambda (window)
- (if (eq (window-buffer window) current)
- (progn
- (select-window window)
- (if (and (< (point) (process-mark process))
- (or (eq scroll t) (eq scroll 'all)
- ;; Maybe user wants point to jump to end.
- (and (eq scroll 'this) (eq selected window))
- (and (eq scroll 'others) (not (eq selected window)))
- ;; If point was at the end, keep it at end.
- (and (marker-position comint-last-output-start)
- (>= (point) comint-last-output-start))))
- (goto-char (process-mark process)))
- ;; Optionally scroll so that the text
- ;; ends at the bottom of the window.
- (if (and comint-scroll-show-maximum-output
- (= (point) (point-max)))
- (save-excursion
- (goto-char (point-max))
- (recenter (- -1 scroll-margin))))
- (select-window selected)))))
+ (lambda (window)
+ (when (eq (window-buffer window) current)
+ (select-window window)
+ (if (and (< (point) (process-mark process))
+ (or (eq scroll t) (eq scroll 'all)
+ ;; Maybe user wants point to jump to end.
+ (and (eq scroll 'this) (eq selected window))
+ (and (eq scroll 'others) (not (eq selected window)))
+ ;; If point was at the end, keep it at end.
+ (and (marker-position comint-last-output-start)
+ (>= (point) comint-last-output-start))))
+ (goto-char (process-mark process)))
+ ;; Optionally scroll so that the text
+ ;; ends at the bottom of the window.
+ (if (and comint-scroll-show-maximum-output
+ (= (point) (point-max)))
+ (save-excursion
+ (goto-char (point-max))
+ (recenter (- -1 scroll-margin))))
+ (select-window selected)))
nil t))
(set-buffer current))))
;; Output message and put back prompt
(comint-output-filter proc replacement)))
(define-obsolete-function-alias 'comint-kill-output
- 'comint-delete-output "21.1")
+ 'comint-delete-output "21.1")
(defun comint-write-output (filename &optional append mustbenew)
"Write output from interpreter since last input to FILENAME.
(interactive)
(comint-skip-input)
(interrupt-process nil comint-ptyp)
-;; (process-send-string nil "\n")
-)
+ ;; (process-send-string nil "\n")
+ )
(defun comint-kill-subjob ()
"Send kill signal to the current subjob.
(error nil))
(not (file-directory-p stringfile))))
(defdir (if sfile-p (file-name-directory stringfile)
- (car def)))
+ (car def)))
(deffile (if sfile-p (file-name-nondirectory stringfile)
- (cdr def)))
+ (cdr def)))
(ans (read-file-name (if deffile (format "%s(default %s) "
prompt deffile)
- prompt)
+ prompt)
defdir
(concat defdir deffile)
mustmatch-p)))
filename
(let ((regexp
(format "[%s]"
- (mapconcat 'char-to-string comint-file-name-quote-list ""))))
+ (mapconcat 'char-to-string comint-file-name-quote-list ""))))
(save-match-data
(let ((i 0))
(while (string-match regexp filename i)
(defun comint-dynamic-complete-as-filename ()
"Dynamically complete at point as a filename.
See `comint-dynamic-complete-filename'. Returns t if successful."
- (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin)))
+ (let* ((completion-ignore-case read-file-name-completion-ignore-case)
(completion-ignored-extensions comint-completion-fignore)
;; If we bind this, it breaks remote directory tracking in rlogin.el.
;; I think it was originally bound to solve file completion problems,
(directory (if filedir (comint-directory filedir) default-directory))
(completion (file-name-completion filenondir directory)))
(cond ((null completion)
- (message "No completions of %s" filename)
+ (if minibuffer-p
+ (minibuffer-message (format " [No completions of %s]" filename))
+ (message "No completions of %s" filename))
(setq success nil))
((eq completion t) ; Means already completed "file".
(insert filesuffix)
See also `comint-dynamic-complete-filename'."
(let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin)))
+ (minibuffer-p (window-minibuffer-p (selected-window)))
(suffix (cond ((not comint-completion-addsuffix) "")
((not (consp comint-completion-addsuffix)) " ")
(t (cdr comint-completion-addsuffix))))
(completions (all-completions stub candidates)))
(cond ((null completions)
- (message "No completions of %s" stub)
+ (if minibuffer-p
+ (minibuffer-message (format " [No completions of %s]" stub))
+ (message "No completions of %s" stub))
nil)
((= 1 (length completions)) ; Gotcha!
(let ((completion (car completions)))
(if (string-equal completion stub)
- (message "Sole completion")
+ (unless minibuffer-p
+ (message "Sole completion"))
(insert (substring completion (length stub)))
- (message "Completed"))
+ (unless minibuffer-p
+ (message "Completed")))
(insert suffix)
'sole))
(t ; There's no unique completion.
(member completion completions))
;; It's not unique, but user wants shortest match.
(insert suffix)
- (message "Completed shortest")
+ (unless minibuffer-p
+ (message "Completed shortest"))
'shortest)
((or comint-completion-autolist
(string-equal stub completion))
;; It's not unique, list possible completions.
- (comint-dynamic-list-completions completions)
+ (comint-dynamic-list-completions completions stub)
'listed)
(t
- (message "Partially completed")
+ (unless minibuffer-p
+ (message "Partially completed"))
'partial)))))))
(defun comint-dynamic-list-filename-completions ()
"List in help buffer possible completions of the filename at point."
(interactive)
- (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin)))
+ (let* ((completion-ignore-case read-file-name-completion-ignore-case)
;; If we bind this, it breaks remote directory tracking in rlogin.el.
;; I think it was originally bound to solve file completion problems,
;; but subsequent changes may have made this unnecessary. sm.
(directory (if filedir (comint-directory filedir) default-directory))
(completions (file-name-all-completions filenondir directory)))
(if (not completions)
- (message "No completions of %s" filename)
+ (if (window-minibuffer-p (selected-window))
+ (minibuffer-message (format " [No completions of %s]" filename))
+ (message "No completions of %s" filename))
(comint-dynamic-list-completions
- (mapcar 'comint-quote-filename completions)))))
+ (mapcar 'comint-quote-filename completions)
+ filenondir))))
;; This is bound locally in a *Completions* buffer to the list of
(defvar comint-dynamic-list-completions-config nil)
-(defun comint-dynamic-list-completions (completions)
+(defun comint-dynamic-list-completions (completions &optional common-substring)
"List in help buffer sorted COMPLETIONS.
+The meaning of COMMON-SUBSTRING is the same as in `display-completion-list'.
Typing SPC flushes the help buffer."
(let ((window (get-buffer-window "*Completions*" 0)))
(setq completions (sort completions 'string-lessp))
(setq comint-dynamic-list-completions-config
(current-window-configuration))
(with-output-to-temp-buffer "*Completions*"
- (display-completion-list completions))
- (message "Type space to flush; repeat completion command to scroll"))
+ (display-completion-list completions common-substring))
+ (if (window-minibuffer-p (selected-window))
+ (minibuffer-message " [Type space to flush; repeat completion command to scroll]")
+ (message "Type space to flush; repeat completion command to scroll")))
;; Read the next key, to process SPC.
(let (key first)
This function does not need to be invoked by the end user."
(let ((output-buffer-list
(if (listp comint-redirect-output-buffer)
- comint-redirect-output-buffer
+ comint-redirect-output-buffer
(list comint-redirect-output-buffer)))
(filtered-input-string input-string))
(or (re-search-backward comint-prompt-regexp nil t)
(error "No prompt found or `comint-prompt-regexp' not set properly"))))
- ;;;;;;;;;;;;;;;;;;;;;
;; Set up for redirection
- ;;;;;;;;;;;;;;;;;;;;;
(comint-redirect-setup
- ;; Output Buffer
output-buffer
- ;; Comint Buffer
- (current-buffer)
- ;; Finished Regexp
- comint-prompt-regexp
- ;; Echo input
- echo)
-
- ;;;;;;;;;;;;;;;;;;;;;
+ (current-buffer) ; Comint Buffer
+ comint-prompt-regexp ; Finished Regexp
+ echo) ; Echo input
+
;; Set the filter
- ;;;;;;;;;;;;;;;;;;;;;
- ;; Save the old filter
- (setq comint-redirect-original-filter-function
+ (setq comint-redirect-original-filter-function ; Save the old filter
(process-filter proc))
(set-process-filter proc 'comint-redirect-filter)
- ;;;;;;;;;;;;;;;;;;;;;
;; Send the command
- ;;;;;;;;;;;;;;;;;;;;;
- (process-send-string
- (current-buffer)
- (concat command "\n"))
+ (process-send-string (current-buffer) (concat command "\n"))
- ;;;;;;;;;;;;;;;;;;;;;
;; Show the output
- ;;;;;;;;;;;;;;;;;;;;;
(or no-display
(display-buffer
(get-buffer-create
results)))
results)))
-(mapc (lambda (x)
- (add-to-list 'debug-ignored-errors x))
- '("^Not at command line$"
- "^Empty input ring$"
- "^No history$"
- "^Not found$" ; Too common?
- "^Current buffer has no process$"))
+(dolist (x '("^Not at command line$"
+ "^Empty input ring$"
+ "^No history$"
+ "^Not found$" ; Too common?
+ "^Current buffer has no process$"))
+ (add-to-list 'debug-ignored-errors x))
\f
;; Converting process modes to use comint mode