unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48417: [PATCH] lisp/progmodes/sql.el: prepend newline in sqli buffer
@ 2021-05-14 13:19 Ingo Lohmar
  2021-05-16 14:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Ingo Lohmar @ 2021-05-14 13:19 UTC (permalink / raw)
  To: 48417


(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






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

* bug#48417: [PATCH] lisp/progmodes/sql.el: prepend newline in sqli buffer
  2021-05-14 13:19 bug#48417: [PATCH] lisp/progmodes/sql.el: prepend newline in sqli buffer Ingo Lohmar
@ 2021-05-16 14:32 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-16 14:32 UTC (permalink / raw)
  To: Ingo Lohmar; +Cc: 48417

Ingo Lohmar <ingo.lohmar@posteo.net> writes:

> (sql-remove-continuation-prompt, sql-send-string): Move newline
> insertion.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-05-16 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 13:19 bug#48417: [PATCH] lisp/progmodes/sql.el: prepend newline in sqli buffer Ingo Lohmar
2021-05-16 14:32 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).