unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70555: [PATCH] comint.el: Add applicable modes to 'interactive' forms
@ 2024-04-24 18:47 Augusto Stoffel
  0 siblings, 0 replies; only message in thread
From: Augusto Stoffel @ 2024-04-24 18:47 UTC (permalink / raw)
  To: 70555

[-- Attachment #1: Type: text/plain, Size: 30 bytes --]

Tags: patch

See attachment.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-comint.el-Add-interactive-modes-to-all-commands.patch --]
[-- Type: text/patch, Size: 20149 bytes --]

From 30a8a7172218257e94f13eaac65d1170c8238782 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Wed, 24 Apr 2024 18:13:36 +0200
Subject: [PATCH] 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.
---
 lisp/comint.el | 104 +++++++++++++++++++++++++------------------------
 1 file changed, 53 insertions(+), 51 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e856038b0f7..3804932e01c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1122,7 +1122,7 @@ comint-dynamic-list-input-ring-window-conf
 
 (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 @@ comint-dynamic-list-input-ring-select
 
 (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 @@ comint-search-arg
 
 (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 @@ comint-previous-input-string
 
 (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 @@ comint-previous-input
 
 (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 @@ comint-previous-matching-input
 \(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 @@ comint-next-matching-input
 \(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 @@ comint-previous-matching-input-from-input
 \(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 @@ 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)))
 
 
@@ -1380,7 +1380,7 @@ comint-replace-by-expanded-history
 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 @@ comint-replace-by-expanded-history-before-point
 (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
@@ -1532,13 +1532,13 @@ comint-history-isearch
 
 (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 @@ comint-send-input
 	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 @@ comint-adjust-point
 (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 @@ comint-truncate-buffer
 (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 @@ 'shell-strip-ctrl-m
 
 (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 @@ comint-get-old-input-default
 (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 @@ comint-bol
 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 @@ comint-send-invisible
 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 @@ comint-delete-output
 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 @@ comint-write-output
 	      "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 @@ comint-write-output
 (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 @@ comint-show-output
 
 (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 @@ comint-interrupt-subjob
 
 (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 @@ comint-stop-subjob
 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 @@ 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)))))
@@ -2749,7 +2750,7 @@ comint-kill-input
 (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 @@ comint-delchar-or-maybe-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))
 
@@ -2769,7 +2770,7 @@ comint-backward-matching-input
 
 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 @@ comint-forward-matching-input
 
 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 @@ comint-next-prompt
 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 @@ comint-previous-prompt
 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 @@ comint-insert-previous-argument
 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 @@ comint-kill-whole-line
 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 @@ comint-kill-region
 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 @@ comint-dynamic-complete-filename
 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 @@ comint-replace-by-expanded-filename
 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 @@ comint-replace-by-expanded-filename
 
 (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 @@ comint-get-next-from-history
   "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 @@ comint-accumulate
 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 @@ comint-goto-process-mark
   "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 @@ comint-bol-or-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 @@ comint-redirect-setup
 
 (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 @@ comint-redirect-send-command
 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 @@ 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)
@@ -4047,6 +4048,7 @@ comint-fontify-input-mode
 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
-- 
2.44.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-24 18:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24 18:47 bug#70555: [PATCH] comint.el: Add applicable modes to 'interactive' forms Augusto Stoffel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).