all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: System operating detection
Date: Wed, 11 Aug 2010 16:27:11 +0200	[thread overview]
Message-ID: <87k4nx9qdc.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.1.1281531533.2853.help-gnu-emacs@gnu.org

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>>
>> Use case:
>>
>> ,----
>> | (case system-type
>> |   (gnu/linux "Linux")
>> |   (window-nt "windows")
>> |   (darwin    "mac")
>> |   (t         "other")
>> `----
>>
>>
>>
>>>
>>>
>
> Ah great I didn't know this, so now is
> --8<---------------cut here---------------start------------->8---
>   (defconst linux nil)
>   (defconst mac nil)
>   (defconst win nil)
>   (defconst other nil)
>   
>   (case system-type
>     (gnu/linux (setq linux t))
>     (window-nt (setq mac t))
>     (darwin    (setq win t))
>     (t         (setq other t)))
> --8<---------------cut here---------------end--------------->8---
>
> But maybe could be even better, what if I create the symbol only if
> really needed?
>
> Then I could do
> --8<---------------cut here---------------start------------->8---
> (if (boundp linux)...
> --8<---------------cut here---------------end--------------->8---
> which probably becomes even longer.
> Isn't there a way to automatically define functions or variables?

What if you write simply:

    (when (eq system-type 'gnu/linux) 
       ...)
?

or, if you have several cases:

   (case system-type
     ((gnu/linux)  (do-something-on-linux))
     ((mac)        (do-something-on-mac))
     (otherwise    (do-something-standard)))

?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


  parent reply	other threads:[~2010-08-11 14:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11  9:06 System operating detection Andrea Crotti
2010-08-11  9:22 ` Richard Riley
2010-08-11 10:19   ` Andrea Crotti
2010-08-11 11:58 ` Thierry Volpiatto
2010-08-11 12:58   ` Andrea Crotti
     [not found]   ` <mailman.1.1281531533.2853.help-gnu-emacs@gnu.org>
2010-08-11 14:27     ` Pascal J. Bourguignon [this message]
2010-08-16 21:53 ` Oleksandr Gavenko
     [not found] <mailman.3.1281517588.2982.help-gnu-emacs@gnu.org>
2010-08-11 11:13 ` TheFlyingDutchman

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

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

  git send-email \
    --in-reply-to=87k4nx9qdc.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.