tinlyx February 2016

How to use unix login user names in Emacs lisp/config?

I was wondering if it is possible to use the current login user name in Emacs config files (in elisp)?

For example, some times the username and default database for a PostgreSQL database are the same as the current login Unix/Linux user name in many multi-user environment. When configuring a Emacs SQL mode and supplying user and database to connect to, something as the following can be used in the Emacs config.

(setq sql-postgres-login-params
      '((user :default "postgres")
        (database :default "postgres")
        (server :default "localhost")
        (port :default 5432)))

How can I replace the username and database from "postgres" to the value of $(whoami) in Linux/Unix?

Answers


coredump February 2016

That would be user-login-name. Just in case you don't know, be sure to no write it inside a quoted list. You can use a backquote:

`((user :default ,user-login-name))

Post Status

Asked in February 2016
Viewed 3,689 times
Voted 13
Answered 1 times

Search




Leave an answer