0

I'm using spacemacs and I want to declare different paths for org-mode according to the platform that I'm inside it.

For example, if I'm in Linux, I want the path be ~/orgs but if I was in windows the path should be D:\orgs\.

Is there a variable to check the current platform?

SdSaati
  • 798
  • 9
  • 18
  • 1
    https://stackoverflow.com/questions/1817257/how-to-determine-operating-system-in-elisp – dalanicolai Jul 28 '21 at 22:47
  • Thank you @dalanicolai please post this as an answer, to check it as the correct one. – SdSaati Jul 29 '21 at 14:51
  • 1
    Well, an answer should be complete, not just a link, and I am not sure if I should copy the answer from there. I think the link in the comment works okay already. There is an [Emacs stack-exchange](https://emacs.stackexchange.com/) b.t.w., I guess it would be better to ask these questions there. Or on the Spacemacs gitter, but you have found that already... – dalanicolai Jul 29 '21 at 21:59

2 Answers2

1

Using the command

systeminfo | findstr /B /C:"OS Name" /C:"OS Version" Will return the OS name and version. Put that in variable after running the command and then do some comparison tests.

see this link: https://www.windows-commandline.com/find-windows-os-version-from-command/

Eoin
  • 21
  • 2
0

One of the solutions(Thanks to @dalanicolai and @milochadam in the gitter website of spacemacs for all of the helps) is that You declare your condition inside user-init () for example, I declared two global variables: snippet_path and org_path and they will get different values depends on the platform(Linux/windows):

(defun dotspacemacs/user-init ()
;; ... other stuff

(if (or (equal system-type 'cygwin) (equal system-type 'windows-nt) (equal system-type 'ms-dos))
    ;; if we are in windows
      (progn
        (setq snippet_path "e:/home/snippets")
        (setq org_path "d:/org-mode/todo.org")
      )
    ;; else if (we are in linux)
      (progn
        (setq snippet_path "/home/ghost/spacemacs/snippets")
        (setq org_path "d:/org-mode/todo.org")
      )
  )

;; ... other stuff
)

Now we can use these two variables everywhere we like, for example inside our layer configs:


(auto-completion :variables                      
                  auto-completion-private-snippets-directory snippet_path
)
      
SdSaati
  • 798
  • 9
  • 18