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 13:05:42 -0800 Message-ID: <25560.12582.576156.155902@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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="SIP4buY2UI" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12016"; 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 Mon Jan 30 22:06:24 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 1pMbM8-0002rx-3W for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Jan 2023 22:06:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMbLq-0006xe-EE; Mon, 30 Jan 2023 16:06: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 1pMbLm-0006wg-KH for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 16:06:02 -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 1pMbLm-0006VY-CT for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 16:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMbLm-0006t5-7V for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 16:06: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: Mon, 30 Jan 2023 21:06: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.167511275426461 (code B ref 61069); Mon, 30 Jan 2023 21:06:02 +0000 Original-Received: (at 61069) by debbugs.gnu.org; 30 Jan 2023 21:05:54 +0000 Original-Received: from localhost ([127.0.0.1]:50715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMbLd-0006sj-GX for submit@debbugs.gnu.org; Mon, 30 Jan 2023 16:05:53 -0500 Original-Received: from mail-oa1-f52.google.com ([209.85.160.52]:36552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMbLb-0006sW-Tm for 61069@debbugs.gnu.org; Mon, 30 Jan 2023 16:05:52 -0500 Original-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-16346330067so16858881fac.3 for <61069@debbugs.gnu.org>; Mon, 30 Jan 2023 13:05:51 -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=MN9z04Vjqr1+y3RKxjlN3Yigm5kZ8YOlsBBlniOqJe8=; b=CONy028KEeJbtu7uYbr2g6fwFXApCPTBGOcT/90V3O3eF93ioT4MBEKCeSfERkd0XO eco0D46LrVylg0cNDoBMAGTe8LTye8C2z8FIirfLB5Cj7PfPAYkZgZIBuEt35i7xwzwg nF+v4RESNOCNxsDoxiLO5H7yMjq1MKqGk90G1/9vzooNOpCGxV2ymaEsy1IkQeRs9Dwz /bjGHm1mh7Gm2sdhnfNowWvGb5uZZnKdxczcuchNgIy2DSxZ4Bucny2LZDFihVKzY35B 8dCZ5m07EYvButKZMNuJl4G/D3NPvtOYK1D3Zu9qQ4qgxvo4wB4Gecxf+9gK/mJY9/IM uIbA== 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=MN9z04Vjqr1+y3RKxjlN3Yigm5kZ8YOlsBBlniOqJe8=; b=AKsO9uALcRTJmpIzLbpn055fiCflkmHxkQXDAQb799VmOmln2vIf90fb+E/46wm1pA 3mM1YGN0jXJgVvOo/5brBy/A9FEYAhmtJklTjzjC4lHyvWcNGZYaZ2gH5PBmOI23vuZK w59dQBYRhlP+GoVMwjs19oWuPK8I1P/W3umHfrwWkVCqyEAruN8SAA5sYIsPSk0MoHMG wKSHOdSQlZL5j31LSn6ZTyCR7VDHcDA5uPyFDlWrB2olRMPxReoVsrgzDaEil6YOmQet 4At5FmGmT/npJzcdKEtPQaKPRGi/886XeAbDLi6qAupXuodfBVo31IzSczQDdrPC/DNr j4XQ== X-Gm-Message-State: AFqh2ko/51jN3Z1IxtRJR07MNssKEEvJjhb6YgTMXJuvVoKTQXiUY/z+ GbTzi3kWNu1+FpyDe9aRrGUp8g== X-Google-Smtp-Source: AMrXdXtxIpwhAI+oe1wNuffLtA+03Q3qWGhQv/pmpj5hd2002ztPoWoeo/R99ezY2NzpivBKGwQJ+w== X-Received: by 2002:a05:6870:b419:b0:15f:dbec:7cbe with SMTP id x25-20020a056870b41900b0015fdbec7cbemr19394808oap.27.1675112745907; Mon, 30 Jan 2023 13:05:45 -0800 (PST) Original-Received: from orion.rgrjr.com ([2600:1700:7c2c:e000::24]) by smtp.gmail.com with ESMTPSA id x30-20020a056870b41e00b0015f84d752ebsm5745589oap.39.2023.01.30.13.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 13:05:45 -0800 (PST) In-Reply-To: <87bkmgzaxc.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:254481 Archived-At: --SIP4buY2UI Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit From: Robert Pluim Date: Mon, 30 Jan 2023 09:25:19 +0100 >>>>> On Fri, 27 Jan 2023 19:45:33 -0800, Bob Rogers said: Bob> Then the following should fit the bill. Given that this solution Bob> introduces a defcustom, I imagine it should also have a NEWS item as Bob> well . . . Yes. And a :version on the new defcustom itself. Right. Bob> -- Bob Bob> * lisp/shell.el (shell-get-old-input-include-continuation-lines): New Bob> defcustom (default nil). Bob> (shell-get-old-input): Like comint-get-old-input-default but include Bob> all continuation lines if the above is true. Bob> (shell-mode): Install shell-get-old-input. (bug#61069) Two spaces after '.' Good; I prefer that as well. (I see I chose a poor example as a commit log message prototype.) Bob> +(defcustom shell-get-old-input-include-continuation-lines nil Bob> + "If non-nil, shell-get-old-input-default includes \"\\\" lines." Bob> + :type 'boolean Bob> + :group 'shell) Bob> + "Whether `shell-get-old-input-default' includes \"\\\" lines." Nice; I was wondering how to make that more concise. Bob> +(defun shell-get-old-input () Bob> + . . . Bob> + (let (field-prop bof) Bob> + (if (and (not comint-use-prompt-regexp) Bob> + ;; Make sure we're in an input rather than output field. Bob> + (not (setq field-prop (get-char-property Bob> + (setq bof (field-beginning)) 'field)))) Bob> + (field-string-no-properties bof) Emacs uses spaces only in elisp. We even have a .dir-locals.el enforcing that. Robert -- I hadn't noticed that, actually -- either the .dir-locals.el or the policy. FWIW, I think both of these tabs are from cutting-and-pasting from comint.el. -- Bob --SIP4buY2UI Content-Type: text/x-patch; name="shell-get-old-input-continuation-lines-2.patch" Content-Description: Content-Disposition: inline; filename="shell-get-old-input-continuation-lines-2.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) 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) --SIP4buY2UI--