From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ingo Lohmar Newsgroups: gmane.emacs.bugs Subject: bug#48417: [PATCH] lisp/progmodes/sql.el: prepend newline in sqli buffer Date: Fri, 14 May 2021 13:19:22 +0000 Message-ID: <87tun5wizp.fsf@kenko.localhost.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25809"; mail-complaints-to="usenet@ciao.gmane.io" To: 48417@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 14 15:20:11 2021 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 1lhXje-0006W7-9i for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 May 2021 15:20:10 +0200 Original-Received: from localhost ([::1]:34262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhXjd-0000Zx-CM for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 May 2021 09:20:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhXjW-0000Zp-Fh for bug-gnu-emacs@gnu.org; Fri, 14 May 2021 09:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhXjW-0001e2-6t for bug-gnu-emacs@gnu.org; Fri, 14 May 2021 09:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lhXjW-000664-18 for bug-gnu-emacs@gnu.org; Fri, 14 May 2021 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ingo Lohmar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 May 2021 13:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48417 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162099837223393 (code B ref -1); Fri, 14 May 2021 13:20:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 May 2021 13:19:32 +0000 Original-Received: from localhost ([127.0.0.1]:45267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhXj2-00065F-18 for submit@debbugs.gnu.org; Fri, 14 May 2021 09:19:32 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhXiz-000657-K4 for submit@debbugs.gnu.org; Fri, 14 May 2021 09:19:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhXiz-0000Xr-Ei for bug-gnu-emacs@gnu.org; Fri, 14 May 2021 09:19:29 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:46907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhXix-0001Eh-1K for bug-gnu-emacs@gnu.org; Fri, 14 May 2021 09:19:29 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 8799C240026 for ; Fri, 14 May 2021 15:19:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1620998363; bh=ZY0nJecGMVbjoo+0XyLgpMpwxIlWH8Yvg6A4K/xBf70=; h=From:To:Subject:Date:From; b=SOG5lvf5o16L5FzVpOsXO/mLJNwnV09fNbiYIzrK5SJkQrL16mM3UGNvWgoMrGRhM OWMm8c7zfn5F1MFRROZxMFGfTciV6WjS3FbDhU7lc9XzjoDk7FedUxbJpf/nEq+abF +XY+tMrcalFB0LtoMDyFw+Jm0rlbvsw55FzYEv0Qfj82IdFs4e0XP+UqgFa0ScDD90 RyCz8YP0DYYp7rS6wBWxfkTZhYTIIiiuNpvvO5Da9W+3boQoACM4Br/dMO4/WYibiw YiIKDHTUTzJ0A0TqeYOf7aPjOKO4ynFzyx2bs4AK9vZNThJbn6LnxNwQsbtLgfqgA6 SdtAAvliQ3BgA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FhTdR0xxfz9rxD for ; Fri, 14 May 2021 15:19:22 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=ingo.lohmar@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:206518 Archived-At: (sql-remove-continuation-prompt, sql-send-string): Move newline insertion. Previously, the preoutput filter `sql-remove-continuation-prompt' inserted a leading newline in the interactive SQL buffer if it decided that is has to remove continuation prompts and that it had found all it was looking for. 1) This filter function was a doubtful place to do that (arguably, its name does not suggest any action like this). 2) The behavior worked inconsistently, eg, when sending a single-line "SELECT" statement, because it only ran when the filter function needed to remove any prompts (for example, not when sending a region without newlines). This can lead to misaligned table headers, which explains why emacswiki and stackoverflow both present several fixes to this behavior. Instead of further complicating the prompt removal logic, only insert the newline before sending to the inferior process, which all goes through `sql-send-string'. This is robust, and in the worst case there will be an additional leading newline (with respect to the previous behavior). --- lisp/progmodes/sql.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 65a4094d70..83cb77ef78 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -3723,8 +3723,7 @@ sql-interactive-remove-continuation-prompt ;; If we've found all the expected prompts, stop looking (if (= sql-output-newline-count 0) - (setq sql-output-newline-count nil - oline (concat "\n" oline)) + (setq sql-output-newline-count nil) ;; Still more possible prompts, leave them for the next pass (setq sql-preoutput-hold oline @@ -3769,6 +3768,8 @@ sql-send-string (with-current-buffer sql-buffer (when sql-debug-send (message ">>SQL> %S" s)) + (insert "\n") + (comint-set-process-mark) ;; Send the string (trim the trailing whitespace) (sql-input-sender (get-buffer-process (current-buffer)) s) -- 2.30.2