pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
slightly OT - Using psql from Emacs with sql.el
5+ messages / 2 participants
[nested] [flat]

* slightly OT - Using psql from Emacs with sql.el
@ 2011-05-05 22:01 Seb <spluque@gmail.com>
  2011-05-05 22:47 ` Re: slightly OT - Using psql from Emacs with sql.el Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Seb @ 2011-05-05 22:01 UTC (permalink / raw)
  To: pgsql-sql

Hi,

When working with psql via sql.el, multiple prompts accumulate in a
single line when sending multi-line input to the SQLi buffer.  For
example, sending the following:

SELECT a,
    b,
    c,
FROM some_table;

with 'C-c C-r' results in these lines in the SQLi buffer:

database_name=# database_name-# database_name-# database_name-# 

before showing the output of the query.

This doesn't happen when working with psql directly from a shell.

Has someone dealt with this problem or can suggest some ideas to avoid
this?

Thanks,

-- 
Seb




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

* Re: slightly OT - Using psql from Emacs with sql.el
  2011-05-05 22:01 slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
@ 2011-05-05 22:47 ` Rob Sargent <robjsargent@gmail.com>
  2011-05-05 22:55   ` Re: slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
  2011-05-07 22:33   ` Re: slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Rob Sargent @ 2011-05-05 22:47 UTC (permalink / raw)
  To: pgsql-sql



On 05/05/2011 04:01 PM, Seb wrote:
> Hi,
>
> When working with psql via sql.el, multiple prompts accumulate in a
> single line when sending multi-line input to the SQLi buffer.  For
> example, sending the following:
>
> SELECT a,
>      b,
>      c,
> FROM some_table;
>
> with 'C-c C-r' results in these lines in the SQLi buffer:
>
> database_name=# database_name-# database_name-# database_name-#
>
> before showing the output of the query.
>
> This doesn't happen when working with psql directly from a shell.
>
> Has someone dealt with this problem or can suggest some ideas to avoid
> this?
>
> Thanks,
>
Doesn't appear to.  I use sql-mode alot/daily.  The multiple prompts 
never bothers me, though the output not starting at the left kind of does.



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

* Re: slightly OT - Using psql from Emacs with sql.el
  2011-05-05 22:01 slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
  2011-05-05 22:47 ` Re: slightly OT - Using psql from Emacs with sql.el Rob Sargent <robjsargent@gmail.com>
@ 2011-05-05 22:55   ` Seb <spluque@gmail.com>
  2011-05-05 23:15     ` Re: slightly OT - Using psql from Emacs with sql.el Rob Sargent <robjsargent@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Seb @ 2011-05-05 22:55 UTC (permalink / raw)
  To: pgsql-sql

On Thu, 05 May 2011 16:47:09 -0600,
Rob Sargent <robjsargent@gmail.com> wrote:

[...]

> Doesn't appear to.  I use sql-mode alot/daily.  The multiple prompts
> never bothers me, though the output not starting at the left kind of
> does.

I've adapted someone's suggestion at the Emacs Wiki for that:

(defun sl/sql-add-newline-before-output (output)
  "Add newline to beginning of OUTPUT for `comint-preoutput-filter-functions'"
  (concat "\n" output))

(add-hook 'sql-interactive-mode-hook
	  (lambda ()
	    (add-hook 'comint-preoutput-filter-functions
		      'sl/sql-add-newline-before-output)))

... but this breaks navigation (e.g. 'C-c C-p')


-- 
Seb




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

* Re: slightly OT - Using psql from Emacs with sql.el
  2011-05-05 22:01 slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
  2011-05-05 22:47 ` Re: slightly OT - Using psql from Emacs with sql.el Rob Sargent <robjsargent@gmail.com>
  2011-05-05 22:55   ` Re: slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
@ 2011-05-05 23:15     ` Rob Sargent <robjsargent@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Rob Sargent @ 2011-05-05 23:15 UTC (permalink / raw)
  To: pgsql-sql



On 05/05/2011 04:55 PM, Seb wrote:
> On Thu, 05 May 2011 16:47:09 -0600,
> Rob Sargent<robjsargent@gmail.com>  wrote:
>
> [...]
>
>> Doesn't appear to.  I use sql-mode alot/daily.  The multiple prompts
>> never bothers me, though the output not starting at the left kind of
>> does.
>
> I've adapted someone's suggestion at the Emacs Wiki for that:
>
> (defun sl/sql-add-newline-before-output (output)
>    "Add newline to beginning of OUTPUT for `comint-preoutput-filter-functions'"
>    (concat "\n" output))
>
> (add-hook 'sql-interactive-mode-hook
> 	  (lambda ()
> 	    (add-hook 'comint-preoutput-filter-functions
> 		      'sl/sql-add-newline-before-output)))
>
> ... but this breaks navigation (e.g. 'C-c C-p')
>
>
Oooo, can't have that.  Though my usage (sql-send-paragraph) does not 
get registered in the command history, I still like have a proper record 
of what I have typed into the *SQL* buffer.  If I want a history of what 
I sent from my working buffer (of sql statements) I wipe/yank into 
*SQL*.  Then the entire block returns on M-p.



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

* Re: slightly OT - Using psql from Emacs with sql.el
  2011-05-05 22:01 slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
  2011-05-05 22:47 ` Re: slightly OT - Using psql from Emacs with sql.el Rob Sargent <robjsargent@gmail.com>
@ 2011-05-07 22:33   ` Seb <spluque@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Seb @ 2011-05-07 22:33 UTC (permalink / raw)
  To: pgsql-sql

On Thu, 05 May 2011 16:47:09 -0600,
Rob Sargent <robjsargent@gmail.com> wrote:

[...]

> Doesn't appear to.  I use sql-mode alot/daily.  The multiple prompts
> never bothers me, though the output not starting at the left kind of
> does.

Then you might like this:

http://www.emacswiki.org/emacs/SqlMode#toc3

bottom section

-- 
Seb




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


end of thread, other threads:[~2011-05-07 22:33 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 22:01 slightly OT - Using psql from Emacs with sql.el Seb <spluque@gmail.com>
2011-05-05 22:47 ` Rob Sargent <robjsargent@gmail.com>
2011-05-05 22:55   ` Seb <spluque@gmail.com>
2011-05-05 23:15     ` Rob Sargent <robjsargent@gmail.com>
2011-05-07 22:33   ` Seb <spluque@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox