[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nice Emacs Lisp
From: |
Mike Mattie |
Subject: |
Re: Nice Emacs Lisp |
Date: |
Wed, 18 Mar 2009 14:31:16 -0700 |
User-agent: |
Mutt/1.5.16 (2007-06-09) |
I use this in Grail:
;;----------------------------------------------------------------------
;; Host specific adaptation
;;
;; each host system has a site file that normalizes the platform
;; and extends the library search space for extra libraries it
;; manages.
;;
;; these files and platform specific customization are loaded by
;; platform here.
;;----------------------------------------------------------------------
(load-user-elisp
(cond
((string-equal "gnu/linux" system-type) "linux.el")
((string-equal "darwin" system-type) "darwin.el")
((string-equal "windows" system-type) "windows.el")))
note that load-user-elisp is a function of my own. You can substitute
that with (load) and a full path to the files.
I think the file approach is the cleanest, as it clearly separates
the logic of adapting to the platform from the platform code
itself which can become quite long, and more prone to simple
parentheses nesting errors when placed inside a form.
On Wed, Mar 18, 2009 at 04:09:01PM +0100, S??bastien Vauban wrote:
> Hello,
>
> 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:
>
> --8<---------------cut here---------------start------------->8---
> (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)))
> --8<---------------cut here---------------end--------------->8---
>
> and I write (for example):
>
> --8<---------------cut here---------------start------------->8---
> (setq bcc-cache-directory
> (concat
> (Windows "~/.emacs.d/byte-cache-ms-windows")
> (GNULinux "~/.emacs.d/byte-cache-linux")))
> --8<---------------cut here---------------end--------------->8---
>
> But do you know some better way to write the above (the concat function is not
> that clear there...), while avoiding such a construction:
>
> --8<---------------cut here---------------start------------->8---
> (Windows
> (setq bcc-cache-directory "~/.emacs.d/byte-cache-ms-windows"))
> (GNULinux
> (setq bcc-cache-directory "~/.emacs.d/byte-cache-linux"))
> --8<---------------cut here---------------end--------------->8---
>
> as I hate duplicating things (error-prone when changing one and not the
> other).
>
> Best regards,
> Seb
>
> --
> S??bastien??Vauban
--
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu
pgpDuovG2LTyb.pgp
Description: PGP signature
- Nice Emacs Lisp, Sébastien Vauban, 2009/03/18
- Re: Nice Emacs Lisp, tyler, 2009/03/18
- Re: Nice Emacs Lisp,
Mike Mattie <=
- Re: Nice Emacs Lisp, Peter Dyballa, 2009/03/18
- Re: Nice Emacs Lisp, Mike Mattie, 2009/03/18
- Re: Nice Emacs Lisp, Peter Dyballa, 2009/03/18
- RE: Nice Emacs Lisp, Drew Adams, 2009/03/19
- Message not available
- Re: Nice Emacs Lisp, rustom, 2009/03/20
- Re: Nice Emacs Lisp, Mike Mattie, 2009/03/20