all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#61069: 30.0.50; comint-copy-old-input should include continuation lines
@ 2023-01-26  1:43 Bob Rogers
  2023-01-26  7:04 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Bob Rogers @ 2023-01-26  1:43 UTC (permalink / raw)
  To: 61069

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 817 bytes --]

   In a shell-mode buffer with lots of "make" output, there will often
appear commands with continuation lines.  To use them as new input
(e.g. while debugging some bit of makefile logic) requires either
marking and copying multiple lines, or multiple invocations of
comint-copy-old-input (C-RET in shell-mode) to get the complete command.
The attached patch against f0971f94fe42224b4d85bb8b6188d5d805689ddf in
master includes those continuation lines, which seems like a desirable
bit of dwimmery.  However, I may have misunderstood the purpose of the
line-end-position vs. field-end thing.  Also, this assumes shell syntax,
so it may be more appropriate to leave comint-get-old-input-default
alone and give shell-mode its own shell-get-old-input-default function.

					-- Bob Rogers
					   http://www.rgrjr.com/


[-- Attachment #2: Type: text/x-patch, Size: 1683 bytes --]

diff --git a/lisp/comint.el b/lisp/comint.el
index c5589324a14..89c35149022 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2377,7 +2377,7 @@ comint-get-old-input-default
   "Default for `comint-get-old-input'.
 If `comint-use-prompt-regexp' is nil, then either
 return the current input field, if point is on an input field, or the
-current line, if point is on an output field.
+current line, with continuation lines, if point is on an output field.
 If `comint-use-prompt-regexp' is non-nil, then return
 the current line with any initial string matching the regexp
 `comint-prompt-regexp' removed."
@@ -2388,11 +2388,18 @@ comint-get-old-input-default
                                     (setq bof (field-beginning)) 'field))))
 	(field-string-no-properties bof)
       (comint-bol)
-      (buffer-substring-no-properties (point)
-                                      (if (or comint-use-prompt-regexp
-                                              (eq field-prop 'output))
-					  (line-end-position)
-					(field-end))))))
+      (let ((start (point)))
+        (cond ((or comint-use-prompt-regexp
+                   (eq field-prop 'output))
+               (goto-char (line-end-position))
+               ;; Include continuation lines as long as the current
+               ;; line ends with a backslash.
+               (while (and (not (eobp))
+                           (= (char-before) ?\\))
+                 (goto-char (line-end-position 2))))
+              (t
+	       (goto-char (field-end))))
+        (buffer-substring-no-properties start (point))))))
 
 (defun comint-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited.

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-04-01  0:15 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26  1:43 bug#61069: 30.0.50; comint-copy-old-input should include continuation lines Bob Rogers
2023-01-26  7:04 ` Eli Zaretskii
2023-01-26  7:33   ` Bob Rogers
2023-01-26  8:12     ` Eli Zaretskii
2023-01-26  8:38       ` Bob Rogers
2023-01-26  9:32         ` Eli Zaretskii
2023-01-28  3:45           ` Bob Rogers
2023-01-30  8:25             ` Robert Pluim
2023-01-30 21:05               ` Bob Rogers
2023-01-31  2:38                 ` Bob Rogers
2023-01-31  9:10                   ` Robert Pluim
2023-01-31 19:45                     ` Bob Rogers
2023-03-30 19:51                       ` Bob Rogers
2023-03-31  8:07                         ` Robert Pluim
2023-03-31 10:51                           ` Eli Zaretskii
2023-03-31 13:01                             ` Robert Pluim
2023-03-31 13:23                               ` Robert Pluim
2023-04-01  0:15                                 ` Bob Rogers

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.