* Nice Emacs Lisp
@ 2009-03-18 15:09 Sébastien Vauban
2009-03-18 17:45 ` tyler
2009-03-18 21:31 ` Mike Mattie
0 siblings, 2 replies; 9+ messages in thread
From: Sébastien Vauban @ 2009-03-18 15:09 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-18 15:09 Nice Emacs Lisp Sébastien Vauban
@ 2009-03-18 17:45 ` tyler
2009-03-18 21:31 ` Mike Mattie
1 sibling, 0 replies; 9+ messages in thread
From: tyler @ 2009-03-18 17:45 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-18 15:09 Nice Emacs Lisp Sébastien Vauban
2009-03-18 17:45 ` tyler
@ 2009-03-18 21:31 ` Mike Mattie
2009-03-18 22:13 ` Peter Dyballa
1 sibling, 1 reply; 9+ messages in thread
From: Mike Mattie @ 2009-03-18 21:31 UTC (permalink / raw)
To: S??bastien Vauban; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2700 bytes --]
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
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-18 21:31 ` Mike Mattie
@ 2009-03-18 22:13 ` Peter Dyballa
2009-03-18 22:42 ` Mike Mattie
0 siblings, 1 reply; 9+ messages in thread
From: Peter Dyballa @ 2009-03-18 22:13 UTC (permalink / raw)
To: Mike Mattie; +Cc: emacs help
Am 18.03.2009 um 22:31 schrieb Mike Mattie:
> (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")))
It's also possible to set the variable custom-file to something like
(setq custom-file (format "~/.emacs-Abrichtung-%d.el" system-type))
Then all customisation would go into this file. And this file would
be loaded after the user-init-file (which is a variable containing
the file name, including directory, of the user's initialisation file).
--
Greetings
Pete
For some reason, this fortune reminds everyone of Marvin Zelkowitz.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-18 22:13 ` Peter Dyballa
@ 2009-03-18 22:42 ` Mike Mattie
2009-03-18 23:34 ` Peter Dyballa
0 siblings, 1 reply; 9+ messages in thread
From: Mike Mattie @ 2009-03-18 22:42 UTC (permalink / raw)
To: Peter Dyballa; +Cc: emacs help
[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]
On Wed, Mar 18, 2009 at 11:13:02PM +0100, Peter Dyballa wrote:
>
> Am 18.03.2009 um 22:31 schrieb Mike Mattie:
>
>> (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")))
>
> It's also possible to set the variable custom-file to something like
>
> (setq custom-file (format "~/.emacs-Abrichtung-%d.el" system-type))
>
> Then all customisation would go into this file. And this file would be
> loaded after the user-init-file (which is a variable containing the file
> name, including directory, of the user's initialisation file).
elegant, but isn't the custom-file scribbled on by customize ?
From my memory it is really a data file, though it is elisp.
> --
> Greetings
>
> Pete
>
> For some reason, this fortune reminds everyone of Marvin Zelkowitz.
>
>
--
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-18 22:42 ` Mike Mattie
@ 2009-03-18 23:34 ` Peter Dyballa
2009-03-19 15:33 ` Drew Adams
[not found] ` <mailman.3579.1237478655.31690.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Peter Dyballa @ 2009-03-18 23:34 UTC (permalink / raw)
To: Mike Mattie; +Cc: emacs help
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
Am 18.03.2009 um 23:42 schrieb Mike Mattie:
> elegant, but isn't the custom-file scribbled on by customize ?
> From my memory it is really a data file, though it is elisp.
Mostly. Of course I moved the two custom-set-variables and custom-set-
faces sections from my old ~/.emacs file into the customisations file
first before I activated the code. Since then the *customize* buffers
read from and write into my customisations file. (And from time to
time I copy manually a line from one file to this or that other file.
Doing the same in *customize* would cost too much time.)
--
Greetings
Pete
I love deadlines. I love the whooshing noise they make as they go by.
– Douglas Adams
[-- Attachment #2: Signierter Teil der Nachricht --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Nice Emacs Lisp
2009-03-18 23:34 ` Peter Dyballa
@ 2009-03-19 15:33 ` Drew Adams
[not found] ` <mailman.3579.1237478655.31690.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2009-03-19 15:33 UTC (permalink / raw)
To: 'Peter Dyballa', 'Mike Mattie'; +Cc: 'emacs help'
> > elegant, but isn't the custom-file scribbled on by customize ?
> > From my memory it is really a data file, though it is elisp.
>
>
> Mostly. Of course I moved the two custom-set-variables and
> custom-set-faces sections from my old ~/.emacs file into the
> customisations file first before I activated the code. Since
> then the *customize* buffers read from and write into my
> customisations file. (And from time to time I copy manually
> a line from one file to this or that other file.
> Doing the same in *customize* would cost too much time.)
FWIW - I like (and recommend) using `custom-file' and keeping Customize stuff
out of the `init-file'. I load `custom-file' as the very last thing in my init
file. (YMMV.)
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.3579.1237478655.31690.help-gnu-emacs@gnu.org>]
* Re: Nice Emacs Lisp
[not found] ` <mailman.3579.1237478655.31690.help-gnu-emacs@gnu.org>
@ 2009-03-20 9:11 ` rustom
2009-03-20 13:31 ` Mike Mattie
0 siblings, 1 reply; 9+ messages in thread
From: rustom @ 2009-03-20 9:11 UTC (permalink / raw)
To: help-gnu-emacs
On Mar 19, 8:33 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
>
> FWIW - I like (and recommend) using `custom-file' and keeping Customize stuff
> out of the `init-file'. I load `custom-file' as the very last thing in my init
> file. (YMMV.)
The customization business is major irritation for me.
Of course I use a separated custom-file so that it does not throw crud
into my init.
It would be so nice-n-simple if we could set an option -- something
like use-.emacs-dir (as against single-file-.emacs. Using this option
would make each customization group go into a separate file
in .emacs.d. Then that file could have a custom-set-variable along
with anything else related to that mode/group.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Nice Emacs Lisp
2009-03-20 9:11 ` rustom
@ 2009-03-20 13:31 ` Mike Mattie
0 siblings, 0 replies; 9+ messages in thread
From: Mike Mattie @ 2009-03-20 13:31 UTC (permalink / raw)
To: rustom; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]
On Fri, Mar 20, 2009 at 02:11:00AM -0700, rustom wrote:
> On Mar 19, 8:33?pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> >
> > FWIW - I like (and recommend) using `custom-file' and keeping Customize stuff
> > out of the `init-file'. I load `custom-file' as the very last thing in my init
> > file. (YMMV.)
>
> The customization business is major irritation for me.
>
> Of course I use a separated custom-file so that it does not throw crud
> into my init.
>
> It would be so nice-n-simple if we could set an option -- something
> like use-.emacs-dir (as against single-file-.emacs. Using this option
> would make each customization group go into a separate file
> in .emacs.d. Then that file could have a custom-set-variable along
> with anything else related to that mode/group.
It turns out to be suprisingly easy just to throw customization overboard.
Not everyone's cup of tea, but it certianly helps quite a bit.
--
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-03-20 13:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 15:09 Nice Emacs Lisp Sébastien Vauban
2009-03-18 17:45 ` tyler
2009-03-18 21:31 ` Mike Mattie
2009-03-18 22:13 ` Peter Dyballa
2009-03-18 22:42 ` Mike Mattie
2009-03-18 23:34 ` Peter Dyballa
2009-03-19 15:33 ` Drew Adams
[not found] ` <mailman.3579.1237478655.31690.help-gnu-emacs@gnu.org>
2009-03-20 9:11 ` rustom
2009-03-20 13:31 ` Mike Mattie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).