help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System operating detection


From: Richard Riley
Subject: Re: System operating detection
Date: Wed, 11 Aug 2010 11:22:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Andrea Crotti <address@hidden> writes:

> Is there a way to make this ugly thing:
>
>
>
>
> --8<---------------cut here---------------start------------->8---
>   (defconst sysop
>     (cond
>      ((string-match "linux" system-configuration) "linux")
>      ((string-match "apple" system-configuration) "mac")
>      ((string-match "win" system-configuration) "win")
>      (t "other")))
>   
>   (defconst linux (string= "linux" sysop))
>   (defconst mac (string= "mac" sysop))
>   (defconst win (string= "win" sysop))
>   (defconst other (string= "other" sysop))
> --8<---------------cut here---------------end--------------->8---
>
>
>
> looking better?
> I would like to have all the constants defined (to nil or t) but
> avoiding this ugly repetition.
> One (small) problem is that without the "cond" also "darwin" matches
> "win", so I get a wrong constant...


I think you need to show your usage patterns for the variables you have
defined for a better answer. How are you using the results?

That said, maybe just define sysop and then load-library a filename stub
concat'ed with the sysop along the lines of

(load-library (concat "os-specific-" sysop))

is a better approach? And then os-specific-win etc all contain their OS
specific details.






reply via email to

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