unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Markert <markert.michael@googlemail.com>
To: dgiglio@iol.it (daniele.g)
Cc: help-gnu-emacs@gnu.org
Subject: Re: enviromental variables into dot.emacs
Date: Sun, 14 Aug 2011 22:28:28 +0200	[thread overview]
Message-ID: <87k4afvitv.fsf@googlemail.com> (raw)
In-Reply-To: <87fwl3pxbe.fsf@father.nostromo.wy> (daniele g.'s message of "Sun, 14 Aug 2011 22:12:05 +0200")

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

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 #2: Type: application/pgp-signature, Size: 835 bytes --]

  reply	other threads:[~2011-08-14 20:28 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 [this message]
2011-08-15  8:47       ` daniele.g
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=87k4afvitv.fsf@googlemail.com \
    --to=markert.michael@googlemail.com \
    --cc=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).