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: Tue, 31 Jan 2023 11:45:42 -0800 Message-ID: <25561.28646.107695.153190@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> <25560.32566.881643.236038@orion.rgrjr.com> <87v8knvzld.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Un7K/jlQaP" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40046"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61069@debbugs.gnu.org, Eli Zaretskii To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 31 20:46:36 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 1pMwaR-000AFm-KC for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Jan 2023 20:46:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMwa2-0006EI-Q1; Tue, 31 Jan 2023 14:46:10 -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 1pMwZw-0006Cl-Cn for bug-gnu-emacs@gnu.org; Tue, 31 Jan 2023 14:46:06 -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 1pMwZu-0004wf-7J for bug-gnu-emacs@gnu.org; Tue, 31 Jan 2023 14:46:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMwZu-00019u-3T for bug-gnu-emacs@gnu.org; Tue, 31 Jan 2023 14:46: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 19:46: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.16751943534434 (code B ref 61069); Tue, 31 Jan 2023 19:46:02 +0000 Original-Received: (at 61069) by debbugs.gnu.org; 31 Jan 2023 19:45:53 +0000 Original-Received: from localhost ([127.0.0.1]:55086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMwZl-00019R-1A for submit@debbugs.gnu.org; Tue, 31 Jan 2023 14:45:53 -0500 Original-Received: from mail-oo1-f54.google.com ([209.85.161.54]:38451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMwZi-00018w-Fe for 61069@debbugs.gnu.org; Tue, 31 Jan 2023 14:45:51 -0500 Original-Received: by mail-oo1-f54.google.com with SMTP id t24-20020a4a8258000000b005170b789faaso1230160oog.5 for <61069@debbugs.gnu.org>; Tue, 31 Jan 2023 11:45:50 -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:cc:to:date:message-id :content-transfer-encoding:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=YrIuEoTtHmca7CWKiUBaONT8NyoNL8uNyC74VBLefRQ=; b=pL2FXD082cUTvr4w6VfCBK+3xXc6R3R42YJKkaCc+D0PdhCROJPH6w4JiwR9qsnMeK LE46ksQlLRuEBjCoDt9DKvVjRciPkmnobUQOiht+GDhqPYlCCvzYr7WnL4WPOkG5Yur1 NS8izI9QLssSZk0zB/iUcsBjbsASlHfPg3O2vsg6LEY1bOSw0OpiscaKC+O9YMl3fo5i ymFk3n/3SCGuDzKXOY6Mdc0Xp6wd2tTWBwdoCtAZsI56oMJLVNrtDxK3sht6FiQT5lUm vDEXVFCBpUDLhWnPu+NsvHBamJQyV8Y9irgP+Ld4BGRUmj6dtcntytl1mZrEWwJh8U0V OhMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:subject:cc:to:date:message-id :content-transfer-encoding:mime-version:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YrIuEoTtHmca7CWKiUBaONT8NyoNL8uNyC74VBLefRQ=; b=pAfLU9qtE9+tjibeX66u7loFtOVDyzyWnEujst5EXr0CGn8PpEI0nna3AsOvvZmrVp YAQMQwTWYuSkSLbtVtvyLcohO72Ju4vU5El95pkD/1nEewDKuUMB8YoRRHUQosnKZ7kN I3QIZwtEGi2R621EqOAitK4MvCtF7AcIZICEp/8Fe2HlHdLKuBZBP5eM/+PUZrzBdFIw cxuD71azS6HwMlxAIutLOT3I2mMfTdJQZ3HtCZCfcVU7nND5mj/t6iZ2+d9G5PxNUVpg 3nOrLoiR+hgoJ1CwHposJWinPGRgXoBEuLkr13CutyFGqlAqvK8iT2fag18vRYu3pyGm 4v2w== X-Gm-Message-State: AO0yUKVQsLlIYTPBICfy2bnnUr8IreB7Z4lEWXHAkV1Ls+oW70ASrfLp IjO5nBWBcFCFSuMj93YP1sgoNg== X-Google-Smtp-Source: AK7set/8mOsy8xhX7hTLki5DVexpftxKliOPvIFlYzR1pBK7d+w2IhAjcvbWT4QEbKctKTz8bVBARQ== X-Received: by 2002:a05:6820:3c1:b0:517:8369:23e4 with SMTP id s1-20020a05682003c100b00517836923e4mr21865ooj.0.1675194344657; Tue, 31 Jan 2023 11:45:44 -0800 (PST) Original-Received: from orion.rgrjr.com ([2600:1700:7c2c:e000::24]) by smtp.gmail.com with ESMTPSA id o22-20020a4ae596000000b004f269f9b8f3sm6466825oov.25.2023.01.31.11.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 11:45:43 -0800 (PST) In-Reply-To: <87v8knvzld.fsf@gmail.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:254543 Archived-At: --Un7K/jlQaP Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit From: Robert Pluim Date: Tue, 31 Jan 2023 10:10:38 +0100 >>>>> On Mon, 30 Jan 2023 18:38:46 -0800, Bob Rogers said: Bob> From: Bob Rogers Bob> Date: Mon, 30 Jan 2023 13:05:42 -0800 Bob> Oops; try this instead (forgot the NEWS item). Bob> -- Bob 3 nits below . . . Robert -- All good nits. -- Bob --Un7K/jlQaP Content-Type: text/x-patch; name="shell-get-old-input-continuation-lines-4.patch" Content-Description: Content-Disposition: inline; filename="shell-get-old-input-continuation-lines-4.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..28cec94bea0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -163,6 +163,14 @@ 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 user option to tell shell-get-old-input (C-RET) to +include multiple shell "\" continuation lines from command output. +Default is nil. + ** Prog Mode +++ diff --git a/lisp/shell.el b/lisp/shell.el index 5cf108bfa3b..7e0cdce86ed 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) --Un7K/jlQaP--