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: daniele.g
Subject: Re: enviromental variables into dot.emacs
Date: Mon, 15 Aug 2011 10:47:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Michael Markert <address@hidden> writes:

> 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?

Oh yesss!

> #+Begin_src emacs-lisp
> (cond
> ((and (string= (getenv "USER") "johndoe")
>       (string= (getenv "HOSTNAME") "bar"))
>  (setq user-mail-address "address@hidden")
>  (require 'john))
> ((and (string= (getenv "USER") "janedoe")
>       (string= (getenv "HOSTNAME") "bar"))
>  (setq user-mail-address "address@hidden")
>  (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.

Indeed, the hostname can be recall using the program hostname. This is
the further step, using shell commands within the file. :-)
-- 
                  - Grazie al cielo, ha lavoro.  Chi?
                  - L'astronomo!!




reply via email to

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