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

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

Re: Nice Emacs Lisp


From: tyler
Subject: Re: Nice Emacs Lisp
Date: Wed, 18 Mar 2009 14:45:07 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Sébastien Vauban <zthjwsqqafhv@spammotel.com>
writes:

> I'd like to mix Linux and Windows settings in my .emacs file, so that
> I can use GNU Emacs on both platforms with the same init file.
>
> Currently, I've defined:
>
> (defmacro GNULinux (&rest body)
>   (list 'if (string-match "linux" (prin1-to-string system-type)) (cons 'progn 
> body)))
>
> (defmacro Windows (&rest body)
>   (list 'if (string-match "windows" (prin1-to-string system-type)) (cons 
> 'progn body)))
>
> and I write (for example):
>
>     (setq bcc-cache-directory
>           (concat
>            (Windows "~/.emacs.d/byte-cache-ms-windows")
>            (GNULinux "~/.emacs.d/byte-cache-linux")))
>
> But do you know some better way to write the above (the concat function is not
> that clear there...)


I'm not very familiar with macros, but maybe using a single macro
instead of two makes things clearer:

(defmacro gnu-win (gnu win)
  `(if (string-match "gnu/linux" (prin1-to-string system-type))
      (,@gnu)
    (,@win)))

(setq bcc-cache-directory
           (gnu-win 
            "~/.emacs.d/byte-cache-linux"
            "~/.emacs.d/byte-cache-ms-windows"))


Cheers,

Tyler

-- 
Philosophy of science is about as useful to scientists as ornithology is
to birds.                              --Richard Feynman





reply via email to

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