help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enviromental variables into dot.emacs


From: Michael Markert
Subject: Re: enviromental variables into dot.emacs
Date: Sun, 14 Aug 2011 22:28:28 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

On 14 Aug 2011, daniele g. wrote:

> There was a misunderstanding. I don't want to set an enviromental
> variable, I want to _read_ it. For example, I want set up my email
> address for Gnus from $USER and $HOSTNAME values. I know I can use
> getenv to read them, but I don't know how to use them in my dot-emacs.
>
> My aim is to unify my conf files making them picking as many values as
> possible from the same place.

Do you think of this?
#+begin_src emacs-lisp
(cond
((and (string= (getenv "USER") "johndoe")
      (string= (getenv "HOSTNAME") "bar"))
 (setq user-mail-address "johndow@bar.com")
 (require 'john))
((and (string= (getenv "USER") "janedoe")
      (string= (getenv "HOSTNAME") "bar"))
 (setq user-mail-address "johndow@bar.com")
 (require 'jane))
(t
 (setq user-mail-address (concat (getenv "USER") "@" (getenv "HOSTNAME")))))
#+end_src emacs-lisp

But note that $HOSTNAME is often not set. You can use `system-name'
here.

Michael

Attachment: pgprHXhGGvhq_.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]