8

I'm using emacs on both Mac OS X and Ubuntu. My .emacs is mostly the same for both platforms, with a couple of lines concerning local fonts and other OS-related stuff. As I usually do additions to my .emacs files, I would like to sync them in a quasi-automatic manner. My question is---is there a way in Lisp to add a conditional procedure to detect the running OS? Something like (pseudo-code):

If OS X: 
  run this and that command;
If Linux:
  run that other command;
Fi

Thanks in advance.

2 Answers 2

12

Following bmeric's advice, this solution worked for me:

(cond
   ((string-equal system-type "gnu/linux")
        ;; window size
        (add-to-list 'default-frame-alist '(left . 0))
        (add-to-list 'default-frame-alist '(top . 0))
        (add-to-list 'default-frame-alist '(height . 32))
        (add-to-list 'default-frame-alist '(width . 70))
        )
   ((string-equal system-type "darwin")
    ;; window size
        (add-to-list 'default-frame-alist '(left . 0))
        (add-to-list 'default-frame-alist '(top . 0))
        (add-to-list 'default-frame-alist '(height . 63))
        (add-to-list 'default-frame-alist '(width . 100))
    )
)
9

You can use system-type variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.