unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: dgiglio@iol.it (daniele.g)
To: help-gnu-emacs@gnu.org
Subject: Re: enviromental variables into dot.emacs
Date: Mon, 15 Aug 2011 10:47:28 +0200	[thread overview]
Message-ID: <871uwnqcwv.fsf@father.nostromo.wy> (raw)
In-Reply-To: 87k4afvitv.fsf@googlemail.com

Michael Markert <markert.michael@googlemail.com> 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 "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.

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	other threads:[~2011-08-15  8:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-14 15:50 enviromental variables into dot.emacs daniele.g
2011-08-14 16:07 ` Tassilo Horn
2011-08-14 20:12   ` daniele.g
2011-08-14 20:28     ` Michael Markert
2011-08-15  8:47       ` daniele.g [this message]
2011-08-14 21:46     ` Jay Belanger
2011-08-14 23:35       ` daniele.g
2011-08-15  0:01         ` Jay Belanger
2011-08-14 16:07 ` Michael Markert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871uwnqcwv.fsf@father.nostromo.wy \
    --to=dgiglio@iol.it \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).