Emacs and PostgreSQL database names

Date:

Emacs brings REPL-driven development to SQL using sql-mode, so you can have a SQL buffer running and send commands to it.

Today however sql-mode didn’t show a prompt when connecting to my local dev database. It turns out that sql-mode has a regexp looking for the prompt, which expects the database name to be all alphanumerics for some reason. It seems to be fixed but is not in the version I get from Arch Linux.

EmacsWiki provides the following fix which works:

(add-hook 'sql-interactive-mode-hook
            (lambda ()
              (setq sql-prompt-regexp "^[_[:alpha:]]*[=][#>] ")
              (setq sql-prompt-cont-regexp "^[_[:alpha:]]*[-][#>] ")))