From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bob Rogers Newsgroups: gmane.emacs.bugs Subject: bug#61069: 30.0.50; comint-copy-old-input should include continuation lines Date: Mon, 30 Jan 2023 18:38:46 -0800 Message-ID: <25560.32566.881643.236038@orion.rgrjr.com> References: <25553.55974.767552.842578@orion.rgrjr.com> <834jsdg4jh.fsf@gnu.org> <25554.11478.609268.317183@orion.rgrjr.com> <83o7qlemta.fsf@gnu.org> <25554.15392.580428.54160@orion.rgrjr.com> <83fsbxej3v.fsf@gnu.org> <25556.39517.23330.591366@orion.rgrjr.com> <87bkmgzaxc.fsf@gmail.com> <25560.12582.576156.155902@orion.rgrjr.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="hJT56gf7Ic" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35668"; mail-complaints-to="usenet@ciao.gmane.io" To: Robert Pluim , Eli Zaretskii , 61069@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 31 03:39:22 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMgYK-000988-QH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Jan 2023 03:39:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMgY6-0000tz-3R; Mon, 30 Jan 2023 21:39:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMgY4-0000tc-9V for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 21:39:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMgY2-0000SV-9G for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 21:39:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMgY2-0007GG-5A for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 21:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Bob Rogers Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 31 Jan 2023 02:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61069 X-GNU-PR-Package: emacs Original-Received: via spool by 61069-submit@debbugs.gnu.org id=B61069.167513273627898 (code B ref 61069); Tue, 31 Jan 2023 02:39:02 +0000 Original-Received: (at 61069) by debbugs.gnu.org; 31 Jan 2023 02:38:56 +0000 Original-Received: from localhost ([127.0.0.1]:51043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMgXv-0007Fu-ND for submit@debbugs.gnu.org; Mon, 30 Jan 2023 21:38:56 -0500 Original-Received: from mail-oa1-f52.google.com ([209.85.160.52]:35441) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMgXu-0007Fi-EM for 61069@debbugs.gnu.org; Mon, 30 Jan 2023 21:38:54 -0500 Original-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-15085b8a2f7so17738534fac.2 for <61069@debbugs.gnu.org>; Mon, 30 Jan 2023 18:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rgrjr-com.20210112.gappssmtp.com; s=20210112; h=references:in-reply-to:subject:to:date:message-id :content-transfer-encoding:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=HQM0tbn93sgHXnOIjOtoOokws7kxBMPLBDAb4ukCUw0=; b=r3yn8/NLgFOHr+G3Bdn3B9lzydsnEMCwFg7NweV1rJq/C1UXb/9KG3yCxq4R9YRkuT sZdHCTvz/0XdU5W9t1+bMPiQchngERVBc8t8B2uHk6okwJxd5zkhwgrQU6qt3G9KxCWr SWOCEYGR2pmr+d9iI6FpKCO64fc+F5K+gI3ULxDj0czDlvDxuwEDp+IUjJIGh2sUUu2Y KWPPl9t73gCcpnrzqVMLZV55fW9KZgJlffrHMiai2KnwWnaeu75jF1ZCeCng+pDjZbMh 4US3gFe4cEicTfdA8Mo+Kg2gnN/py3kA757PZ4zxwpkFx529XGx7ao+RJ8kVDGjMkpCO RKhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:subject:to:date:message-id :content-transfer-encoding:mime-version:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HQM0tbn93sgHXnOIjOtoOokws7kxBMPLBDAb4ukCUw0=; b=KzOhGam7yX0FczCj5tsiJLzBSiZLPY/cl0lIKfedVqi6G47IC2rxXH6WmAPxnKOQYF jbNGO5Xp4Y+3LR0ncxaijGG/JVxpHvUwKkusH9R77y4Z7FPnquTlvcbouMaIdG61E35J IjIEyZEWL3KwF7jH1mgqYJGauRRn8b9ROedmwUfKxY05LcFR9Yn88naJk8OfnQfcW+SX vt6xxJX4GG1CKDC/f/S277D9iveveSC4s10457oCuyOQTZg33dT87+tEA+iWlH/HR0A/ 2Y3pv7MvU8K4sv4X5soh8btG3DoA28YgJt/PSux0r0yQuFJH2nAX2FlFcnUQYFEmDfIE QIcw== X-Gm-Message-State: AFqh2kpM0U048Vjrwnyd/XJu0KwLvyWq6MVXbZJdRsM5izcmaj/XHfae uj1964o8lt9L67HBRHKHYzMtdQ== X-Google-Smtp-Source: AMrXdXvFlL+s5PF1N2726Biu8/hyvzYDlW6a4RWVnBkWTxqqaux1iGAdxV4G4LfkGzCEVpBY491A+Q== X-Received: by 2002:a05:6871:71f:b0:15f:de61:1390 with SMTP id f31-20020a056871071f00b0015fde611390mr21532790oap.16.1675132728782; Mon, 30 Jan 2023 18:38:48 -0800 (PST) Original-Received: from orion.rgrjr.com ([2600:1700:7c2c:e000::24]) by smtp.gmail.com with ESMTPSA id l11-20020a4ab2cb000000b004a3527e8279sm5663339ooo.0.2023.01.30.18.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 18:38:48 -0800 (PST) In-Reply-To: <25560.12582.576156.155902@orion.rgrjr.com> X-Mailer: VM 8.2.0b under 30.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254499 Archived-At: --hJT56gf7Ic Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit From: Bob Rogers Date: Mon, 30 Jan 2023 13:05:42 -0800 Oops; try this instead (forgot the NEWS item). -- Bob --hJT56gf7Ic Content-Type: text/x-patch; name="shell-get-old-input-continuation-lines-3.patch" Content-Description: Content-Disposition: inline; filename="shell-get-old-input-continuation-lines-3.patch" Content-Transfer-Encoding: 7bit * lisp/shell.el (shell-get-old-input-include-continuation-lines): New defcustom (default nil). (shell-get-old-input): Like comint-get-old-input-default but include all continuation lines if the above is true. (shell-mode): Install shell-get-old-input. (bug#61069) * etc/NEWS: Advertise the new defcustom. diff --git a/etc/NEWS b/etc/NEWS index 5b8ab06086c..46f0e8bffca 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -163,6 +163,13 @@ this to your configuration: After manually editing 'eshell-aliases-file', you can use this command to load the edited aliases. +** Shell Mode + ++++ +*** New variable 'shell-get-old-input-include-continuation-lines'. +Users can set this variable to tell shell-get-old-input (C-RET) to +include multiple shell "\" continuation lines from command output. + ** Prog Mode +++ diff --git a/lisp/shell.el b/lisp/shell.el index 5cf108bfa3b..31fb98c0176 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -366,6 +366,12 @@ shell-has-auto-cd :group 'shell-directories :version "28.1") +(defcustom shell-get-old-input-include-continuation-lines nil + "Whether shell-get-old-input-default includes \"\\\" lines." + :type 'boolean + :group 'shell + :version "30.1") + (defcustom shell-kill-buffer-on-exit nil "Kill a shell buffer after the shell process terminates." :type 'boolean @@ -506,6 +512,38 @@ shell--parse-pcomplete-arguments (push (mapconcat #'identity (nreverse arg) "") args))) (cons (nreverse args) (nreverse begins))))) +(defun shell-get-old-input () + "Default for `comint-get-old-input' in shell-mode. +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. +If `comint-use-prompt-regexp' is non-nil, then return +the current line with any initial string matching the regexp +`comint-prompt-regexp' removed. In either case, if +shell-get-old-input-include-continuation-lines is non-nil and the +current line ends with a backslash, the next line is also included and +examined for a backslash, ending with a final line without a backslash." + (let (field-prop bof) + (if (and (not comint-use-prompt-regexp) + ;; Make sure we're in an input rather than output field. + (not (setq field-prop (get-char-property + (setq bof (field-beginning)) 'field)))) + (field-string-no-properties bof) + (comint-bol) + (let ((start (point))) + (cond ((or comint-use-prompt-regexp + (eq field-prop 'output)) + (goto-char (line-end-position)) + (when shell-get-old-input-include-continuation-lines + ;; 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)))))) + ;;;###autoload (defun split-string-shell-command (string) "Split STRING (a shell command) into a list of strings. @@ -642,6 +680,7 @@ shell-mode (setq-local font-lock-defaults '(shell-font-lock-keywords t)) (setq-local shell-dirstack nil) (setq-local shell-last-dir nil) + (setq-local comint-get-old-input #'shell-get-old-input) ;; People expect Shell mode to keep the last line of output at ;; window bottom. (setq-local scroll-conservatively 101) --hJT56gf7Ic--