(defun comint-dynamic-list-input-ring-select ()
"Choose the input history entry that point is in or next to."
- (interactive)
+ (interactive nil completion-list-mode)
(let ((buffer completion-reference-buffer)
beg end completion)
(if (and (not (eobp)) (get-text-property (point) 'mouse-face))
(defun comint-dynamic-list-input-ring ()
"Display a list of recent inputs entered into the current buffer."
- (interactive)
+ (interactive nil comint-mode)
(if (or (not (ring-p comint-input-ring))
(ring-empty-p comint-input-ring))
(message "No history")
(defun comint-restore-input ()
"Restore unfinished input."
- (interactive)
+ (interactive nil comint)
(when comint-input-ring-index
(comint-delete-input)
(when (> (length comint-stored-incomplete-input) 0)
(defun comint-previous-input (arg)
"Cycle backwards through input history, saving input."
- (interactive "*p")
+ (interactive "*p" comint-mode)
(if (and comint-input-ring-index
(or ;; leaving the "end" of the ring
(and (< arg 0) ; going down
(defun comint-next-input (arg)
"Cycle forwards through input history."
- (interactive "*p")
+ (interactive "*p" comint-mode)
(comint-previous-input (- arg)))
(defun comint-previous-matching-input-string (regexp arg)
\(Previous history elements are earlier commands.)
With prefix argument N, search for Nth previous match.
If N is negative, find the next or Nth next match."
- (interactive (comint-regexp-arg "Previous input matching (regexp): "))
+ (interactive (comint-regexp-arg "Previous input matching (regexp): ") comint-mode)
(setq n (comint-search-arg n))
(let ((pos (comint-previous-matching-input-string-position regexp n)))
;; Has a match been found?
\(Later history elements are more recent commands.)
With prefix argument N, search for Nth following match.
If N is negative, find the previous or Nth previous match."
- (interactive (comint-regexp-arg "Next input matching (regexp): "))
+ (interactive (comint-regexp-arg "Next input matching (regexp): ") comint-mode)
(comint-previous-matching-input regexp (- n)))
(defun comint-previous-matching-input-from-input (n)
\(Previous history elements are earlier commands.)
With prefix argument N, search for Nth previous match.
If N is negative, search forwards for the -Nth following match."
- (interactive "p")
+ (interactive "p" comint-mode)
(let ((opoint (point)))
(unless (memq last-command '(comint-previous-matching-input-from-input
comint-next-matching-input-from-input))
\(Following history elements are more recent commands.)
With prefix argument N, search for Nth following match.
If N is negative, search backwards for the -Nth previous match."
- (interactive "p")
+ (interactive "p" comint-mode)
(comint-previous-matching-input-from-input (- n)))
See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'.
Returns t if successful."
- (interactive)
+ (interactive nil comint-mode)
(let ((f (comint-c-a-p-replace-by-expanded-history silent start)))
(if f (funcall f))))
(defun comint-magic-space (arg)
"Expand input history references before point and insert ARG spaces.
A useful command to bind to SPC. See `comint-replace-by-expanded-history'."
- (interactive "p")
+ (interactive "p" comint-mode)
(comint-replace-by-expanded-history)
(self-insert-command arg))
\f
(defun comint-history-isearch-backward ()
"Search for a string backward in input history using Isearch."
- (interactive)
+ (interactive nil comint-mode)
(setq comint-history-isearch t)
(isearch-backward nil t))
(defun comint-history-isearch-backward-regexp ()
"Search for a regular expression backward in input history using Isearch."
- (interactive)
+ (interactive nil comint-mode)
(setq comint-history-isearch t)
(isearch-backward-regexp nil t))
which matches (1) all whitespace (2) :a, :c, etc.
Similarly for Soar, Scheme, etc."
- (interactive)
+ (interactive nil comint-mode)
;; If we're currently completing, stop. We're definitely done
;; completing, and by sending the input, we might cause side effects
;; that will confuse the code running in the completion
(defun comint-truncate-buffer (&optional _string)
"Truncate the buffer to `comint-buffer-maximum-size'.
This function could be on `comint-output-filter-functions' or bound to a key."
- (interactive)
+ (interactive nil comint-mode)
(save-excursion
(goto-char (process-mark (get-buffer-process (current-buffer))))
(forward-line (- comint-buffer-maximum-size))
(defun comint-strip-ctrl-m (&optional _string interactive)
"Strip trailing `^M' characters from the current output group.
This function could be on `comint-output-filter-functions' or bound to a key."
- (interactive (list nil t))
+ (interactive (list nil t) comint-mode)
(let ((process (get-buffer-process (current-buffer))))
(if (not process)
;; This function may be used in
(defun comint-show-maximum-output ()
"Put the end of the buffer at the bottom of the window."
- (interactive)
+ (interactive nil comint-mode)
(goto-char (point-max))
(recenter (- -1 scroll-margin)))
(defun comint-copy-old-input ()
"Insert after prompt old input at point as new input to be edited.
Calls `comint-get-old-input' to get old input."
- (interactive)
+ (interactive nil comint-mode)
(let ((input (funcall comint-get-old-input))
(process (get-buffer-process (current-buffer))))
(if (not process)
If `comint-use-prompt-regexp' is non-nil, then the prompt skip is done
by skipping text matching the regular expression `comint-prompt-regexp',
a buffer local variable."
- (interactive "P")
+ (interactive "P" comint-mode)
(if arg
;; Unlike `beginning-of-line', forward-line ignores field boundaries
(forward-line 0)
The string is sent using `comint-input-sender'.
Security bug: your string can still be temporarily recovered with
\\[view-lossage]; `clear-this-command-keys' can fix that."
- (interactive "P") ; Defeat snooping via C-x ESC ESC
+ (interactive "P" comint-mode) ; Defeat snooping via C-x ESC ESC
(let ((proc (get-buffer-process (current-buffer)))
(prefix
(if (eq (window-buffer) (current-buffer))
kill ring.
This command does not delete the prompt."
- (interactive "P")
+ (interactive "P" comint-mode)
(let ((proc (get-buffer-process (current-buffer)))
(replacement nil)
(inhibit-read-only t))
"Append output to file: "
"Write output to file: "))
current-prefix-arg
- (not current-prefix-arg)))
+ (not current-prefix-arg))
+ comint-mode)
(save-excursion
(goto-char (process-mark (get-buffer-process (current-buffer))))
(forward-line 0)
(defun comint-append-output-to-file (filename)
"Append output from interpreter since last input to FILENAME.
Any prompt at the end of the output is not written."
- (interactive "fAppend output to file: ")
+ (interactive "fAppend output to file: " comint-mode)
(comint-write-output filename t))
(defun comint-show-output ()
"Display start of this batch of interpreter output at top of window.
Sets mark to the value of point when this command is run."
- (interactive)
+ (interactive nil comint-mode)
(push-mark)
(let ((pos (or (marker-position comint-last-input-end) (point-max))))
(cond (comint-use-prompt-regexp
(defun comint-clear-buffer ()
"Clear the comint buffer."
- (interactive)
+ (interactive nil comint-mode)
(let ((comint-buffer-maximum-size 0))
(comint-truncate-buffer)))
(defun comint-interrupt-subjob ()
"Interrupt the current subjob."
- (interactive)
+ (interactive nil comint-mode)
(comint-skip-input)
(interrupt-process nil comint-ptyp)
;; (process-send-string nil "\n")
(defun comint-kill-subjob ()
"Send kill signal to the current subjob."
- (interactive)
+ (interactive nil comint-mode)
(comint-skip-input)
(kill-process nil comint-ptyp))
(defun comint-quit-subjob ()
"Send quit signal to the current subjob."
- (interactive)
+ (interactive nil comint-mode)
(comint-skip-input)
(quit-process nil comint-ptyp))
the top-level process running in the buffer. If you accidentally do
this, use \\[comint-continue-subjob] to resume the process. (This
is not a problem with most shells, since they ignore this signal.)"
- (interactive)
+ (interactive nil comint-mode)
(comint-skip-input)
(stop-process nil comint-ptyp))
(defun comint-continue-subjob ()
"Send CONT signal to process buffer's process group.
Useful if you accidentally suspend the top-level process."
- (interactive)
+ (interactive nil comint-mode)
(continue-process nil comint-ptyp))
(defun comint-skip-input ()
(defun comint-kill-input ()
"Kill all text from last stuff output by interpreter to point."
- (interactive)
+ (interactive nil comint-mode)
(let ((pmark (process-mark (get-buffer-process (current-buffer)))))
(if (> (point) (marker-position pmark))
(kill-region pmark (point)))))
(defun comint-delchar-or-maybe-eof (arg)
"Delete ARG characters forward or send an EOF to subprocess.
Sends an EOF only if point is at the end of the buffer and there is no input."
- (interactive "p")
+ (interactive "p" comint-mode)
(let ((proc (get-buffer-process (current-buffer))))
(if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
(comint-send-eof)
(defun comint-send-eof ()
"Send an EOF to the current buffer's process."
- (interactive)
+ (interactive nil comint-mode)
(comint-send-input t t)
(process-send-eof))
With prefix argument N, search for Nth previous match.
If N is negative, find the next or Nth next match."
- (interactive (comint-regexp-arg "Backward input matching (regexp): "))
+ (interactive (comint-regexp-arg "Backward input matching (regexp): ") comint-mode)
(if comint-use-prompt-regexp
;; Use comint-prompt-regexp
(let* ((re (concat comint-prompt-regexp ".*" regexp))
With prefix argument N, search for Nth following match.
If N is negative, find the previous or Nth previous match."
- (interactive (comint-regexp-arg "Forward input matching (regexp): "))
+ (interactive (comint-regexp-arg "Forward input matching (regexp): ") comint-mode)
(comint-backward-matching-input regexp (- n)))
If `comint-use-prompt-regexp' is nil, then this means the beginning of
the Nth next `input' field, otherwise, it means the Nth occurrence of
text matching `comint-prompt-regexp'."
- (interactive "^p")
+ (interactive "^p" comint-mode)
(if comint-use-prompt-regexp
;; Use comint-prompt-regexp
(let ((paragraph-start comint-prompt-regexp))
If `comint-use-prompt-regexp' is nil, then this means the beginning of
the Nth previous `input' field, otherwise, it means the Nth occurrence of
text matching `comint-prompt-regexp'."
- (interactive "^p")
+ (interactive "^p" comint-mode)
(comint-next-prompt (- n)))
;; State used by `comint-insert-previous-argument' when cycling.
with the first command). Values of INDEX < 0 count from the end, so
INDEX = -1 is the last argument. This command is like \"M-.\" in
Bash and zsh."
- (interactive "P")
+ (interactive "P" comint-mode)
(unless (null index)
(setq index (prefix-numeric-value index)))
(cond ((eq last-command this-command)
If COUNT is zero, kill current line but exclude the trailing newline.
The read-only status of newlines is updated with `comint-update-fence',
if necessary."
- (interactive "p")
+ (interactive "p" comint-mode)
(let ((inhibit-read-only t) (inhibit-field-text-motion t))
(kill-whole-line count)
(when (>= count 0) (comint-update-fence))))
the case, this command just calls `kill-region' with all
read-only properties intact. The read-only status of newlines is
updated using `comint-update-fence', if necessary."
- (interactive "r")
+ (interactive "r" comint-mode)
(save-excursion
(let* ((true-beg (min beg end))
(true-end (max beg end))
completions listing is dependent on the value of `comint-completion-autolist'.
Returns t if successful."
- (interactive)
+ (interactive nil comint-mode)
(when (comint--match-partial-filename)
(unless (window-minibuffer-p)
(message "Completing file name..."))
filename absolute. For expansion see `expand-file-name' and
`substitute-in-file-name'. For completion see
`comint-dynamic-complete-filename'."
- (interactive)
+ (interactive nil comint-mode)
(let ((filename (comint-match-partial-filename)))
(when filename
(replace-match (expand-file-name filename) t t)
(defun comint-dynamic-list-filename-completions ()
"Display a list of possible completions for the filename at point."
- (interactive)
+ (interactive nil comint-mode)
(let* ((data (comint--complete-file-name-data))
(minibuffer-completion-table (nth 2 data))
(minibuffer-completion-predicate nil)
"After fetching a line from input history, this fetches the following line.
In other words, this recalls the input line after the line you recalled last.
You can use this to repeat a sequence of input lines."
- (interactive)
+ (interactive nil comint-mode)
(if comint-save-input-ring-index
(progn
(setq comint-input-ring-index (1+ comint-save-input-ring-index))
to send all the accumulated input, at once.
The entire accumulated text becomes one item in the input history
when you send it."
- (interactive)
+ (interactive nil comint-mode)
(when-let* ((proc (get-buffer-process (current-buffer)))
(pmark (process-mark proc))
((or (marker-position comint-accum-marker)
"Move point to the process mark.
The process mark separates output, and input already sent,
from input that has not yet been sent."
- (interactive)
+ (interactive nil comint-mode)
(let ((proc (or (get-buffer-process (current-buffer))
(user-error "Current buffer has no process"))))
(goto-char (process-mark proc))
is at the beginning of the current input line; but if you have
used \\[comint-accumulate] to send multiple lines at once,
the process mark is at the beginning of the accumulated input."
- (interactive)
+ (interactive nil comint-mode)
(if (not (eq last-command 'comint-bol-or-process-mark))
(comint-bol nil)
(comint-goto-process-mark)))
(defun comint-set-process-mark ()
"Set the process mark at point."
- (interactive)
+ (interactive nil comint-mode)
(let ((proc (or (get-buffer-process (current-buffer))
(user-error "Current buffer has no process"))))
(set-marker (process-mark proc) (point))
(defun comint-redirect-cleanup ()
"End a Comint redirection. See `comint-redirect-send-command'."
- (interactive)
+ (interactive nil comint-mode)
;; Release the last redirected string
(setq comint-redirect-previous-input-string nil)
;; Restore the process filter
With prefix arg ECHO, echo output in process buffer.
If NO-DISPLAY is non-nil, do not show the output buffer."
- (interactive "sCommand: \nBOutput Buffer: \nP")
+ (interactive "sCommand: \nBOutput Buffer: \nP" comint-mode)
(let ((process (get-buffer-process (current-buffer))))
(if process
(comint-redirect-send-command-to-process
With prefix arg, echo output in process buffer.
If NO-DISPLAY is non-nil, do not show the output buffer."
- (interactive "sCommand: \nBOutput Buffer: \nbProcess Buffer: \nP")
+ (interactive "sCommand: \nBOutput Buffer: \nbProcess Buffer: \nP" comint-mode)
(let* (;; The process buffer
(process-buffer (if (processp process)
(process-buffer process)
non-nil. Input fontification isn't compatible with this
setting."
:lighter nil
+ :interactive (comint-mode)
(if comint-fontify-input-mode
(let ((success nil))
(unwind-protect