From: Augusto Stoffel Date: Wed, 24 Apr 2024 16:13:36 +0000 (+0200) Subject: comint.el: Add applicable modes to 'interactive' forms X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9b991680af64572c284e706e49a18d274139b643;p=emacs.git comint.el: Add applicable modes to 'interactive' forms * lisp/comint.el (comint-dynamic-list-input-ring-select) (comint-dynamic-list-input-ring, comint-restore-input) (comint-previous-input, comint-next-input) (comint-previous-matching-input, comint-next-matching-input) (comint-previous-matching-input-from-input) (comint-next-matching-input-from-input) (comint-replace-by-expanded-history, comint-magic-space) (comint-history-isearch-backward) (comint-history-isearch-backward-regexp, comint-send-input) (comint-truncate-buffer, comint-strip-ctrl-m) (comint-show-maximum-output, comint-copy-old-input, comint-bol) (comint-send-invisible, comint-delete-output, comint-write-output) (comint-append-output-to-file, comint-show-output) (comint-clear-buffer, comint-interrupt-subjob, comint-kill-subjob) (comint-quit-subjob, comint-stop-subjob, comint-continue-subjob) (comint-kill-input, comint-delchar-or-maybe-eof, comint-send-eof) (comint-backward-matching-input, comint-forward-matching-input) (comint-next-prompt, comint-previous-prompt) (comint-insert-previous-argument, comint-kill-whole-line) (comint-kill-region, comint-dynamic-complete-filename) (comint-replace-by-expanded-filename) (comint-dynamic-list-filename-completions) (comint-get-next-from-history, comint-accumulate) (comint-goto-process-mark, comint-bol-or-process-mark) (comint-set-process-mark, comint-redirect-cleanup) (comint-redirect-send-command) (comint-redirect-send-command-to-process, comint-fontify-input-mode): Add mode to interactive form. (Bug#70555) (cherry picked from commit e8feb04cc68f24d60d12390cef28064727d75669) --- diff --git a/lisp/comint.el b/lisp/comint.el index 720d9d55ec6..90f974c5def 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1122,7 +1122,7 @@ See also `comint-read-input-ring'." (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)) @@ -1139,7 +1139,7 @@ See also `comint-read-input-ring'." (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") @@ -1203,7 +1203,7 @@ See also `comint-read-input-ring'." (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) @@ -1232,7 +1232,7 @@ Moves relative to `comint-input-ring-index'." (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 @@ -1246,7 +1246,7 @@ Moves relative to `comint-input-ring-index'." (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) @@ -1295,7 +1295,7 @@ Moves relative to START, or `comint-input-ring-index'." \(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? @@ -1325,7 +1325,7 @@ If N is negative, find the next or Nth next match." \(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) @@ -1333,7 +1333,7 @@ If N is negative, find the previous or Nth previous match." \(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)) @@ -1355,7 +1355,7 @@ If N is negative, search forwards for the -Nth following match." \(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))) @@ -1380,7 +1380,7 @@ than the logical beginning of line. 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)))) @@ -1510,7 +1510,7 @@ actual side-effect." (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)) @@ -1532,13 +1532,13 @@ If nil, Isearch operates on the whole comint buffer." (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)) @@ -1927,7 +1927,7 @@ If the Comint is Lucid Common Lisp, 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 @@ -2376,7 +2376,7 @@ SELECTED is the window that was originally selected." (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)) @@ -2387,7 +2387,7 @@ This function could be on `comint-output-filter-functions' or bound to a key." (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 @@ -2409,7 +2409,7 @@ This function could be on `comint-output-filter-functions' or bound to a key." (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))) @@ -2437,7 +2437,7 @@ the current line with any initial string matching the regexp (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) @@ -2503,7 +2503,7 @@ If prefix argument is given (\\[universal-argument]) the prompt is not skipped. 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) @@ -2530,7 +2530,7 @@ Then send it to the process running in the current buffer. 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)) @@ -2612,7 +2612,7 @@ If KILL (interactively, the prefix), save the killed text in the 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)) @@ -2650,7 +2650,8 @@ otherwise." "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) @@ -2662,13 +2663,13 @@ otherwise." (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 @@ -2682,13 +2683,13 @@ Sets mark to the value of point when this command is run." (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") @@ -2696,13 +2697,13 @@ Sets mark to the value of point when this command is run." (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)) @@ -2713,14 +2714,14 @@ WARNING: if there is no current subjob, you can end up suspending 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 () @@ -2741,7 +2742,7 @@ called this function are inserted into the buffer." (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))))) @@ -2749,7 +2750,7 @@ called this function are inserted into the buffer." (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) @@ -2757,7 +2758,7 @@ Sends an EOF only if point is at the end of the buffer and there is no input." (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)) @@ -2769,7 +2770,7 @@ by lines that match `comint-prompt-regexp'. 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)) @@ -2801,7 +2802,7 @@ by lines that match `comint-prompt-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))) @@ -2810,7 +2811,7 @@ If N is negative, find the previous or Nth previous match." 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)) @@ -2847,7 +2848,7 @@ text matching `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. @@ -2875,7 +2876,7 @@ from progressively earlier commands (using the value of INDEX specified 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) @@ -2949,7 +2950,7 @@ with negative arguments.) 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)))) @@ -2968,7 +2969,7 @@ prompts should stay at the beginning of a line. If this is not 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)) @@ -3363,7 +3364,7 @@ Completion is dependent on the value of `comint-completion-addsuffix', 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...")) @@ -3438,7 +3439,7 @@ variables (e.g. $HOME), `~'s, `..', and `.', and making the 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) @@ -3446,7 +3447,7 @@ filename absolute. For expansion see `expand-file-name' and (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) @@ -3534,7 +3535,7 @@ the completions." "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)) @@ -3548,7 +3549,7 @@ to be sent along with this line. Use \\[comint-send-input] 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) @@ -3573,7 +3574,7 @@ when you send it." "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)) @@ -3591,14 +3592,14 @@ from input that has not yet been sent. Ordinarily, the process mark 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)) @@ -3755,7 +3756,7 @@ and does not normally need to be invoked by the end user or programmer." (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 @@ -3864,7 +3865,7 @@ This function does not need to be invoked by the end user." 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 @@ -3878,7 +3879,7 @@ If NO-DISPLAY is non-nil, do not show the output buffer." 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) @@ -4047,6 +4048,7 @@ This function signals an error if `comint-use-prompt-regexp' is 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