(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.
;; 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
(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)