Forum OpenACS Q&A: Re: psql and emacs

Collapse
18: Re: psql and emacs (response to 12)
Posted by Andrei Popov on
From my .emacs:
(setq sql-user "apopov")
(setq sql-database "apopov")
(setq sql-server "vm")
(setq sql-postgres-options '("-Uapopov" "-P" "pager=off"))
But it won't help w/port.
Collapse
19: Re: psql and emacs (response to 18)
Posted by Bart Teeuwisse on
Another option is to apply the following patch to emacs/21.2/lisp/progmodes/sql.el so that Emacs will always ask for a username regardless of environment variables. It has served me well.

1674c1674
<    (sql-get-login 'database 'server)
---
<blockquote>    (sql-get-login 'user 'database 'server)
</blockquote>
1683a1684,1685
<blockquote>      (if (not (string= "" sql-user))
      (setq params (append (list "-U" sql-user) params)))
</blockquote>

Don't forget to byte compile sql.el afterwards or Emacs will continue to use the old sql.elc without the patch.

/Bart

Collapse
20: Re: psql and emacs (response to 19)
Posted by Mark Aufflick on
To save people wasting the time i just wasted, if you're using emacs 21.3 you can do just about the same thing as Bart describes with the following points:

* I applied the patch by hand, but I think the lines in the 21.2 patch above is off by 1 - but get to line 1683 and it's around there somewhere
* it only worked for me if the sql-get-login used this specific order:

(sql-get-login 'database 'user 'server)

If I put the 'user anywhere else it ignored it :/

Also, sql-get-login will automatically ask for password when it asks for user - if you are not using passwords just leave it blank and hit enter.

PS: Bart you'll be pleased to know that I got to this thread from the first page of a google search - it's cool because I'm working at a non-oacs client, and I didn't even notice that I was on openacs.org until I saw /Bart :)

I'll be signing off /Mark soon, thus completing all our conversions into Lars-borgs :P