[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: System operating detection
From: |
Pascal J. Bourguignon |
Subject: |
Re: System operating detection |
Date: |
Wed, 08 Dec 2010 15:24:12 -0000 |
User-agent: |
Gnus/5.101 (Gnus v5.10.10) Emacs/23.2 (gnu/linux) |
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/