summaryrefslogtreecommitdiffstats
path: root/.emacs.d/ports.el
blob: eec38541eea0f81cc0cd53bf11e23a88c9910593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;; function copied from dim-ports.al by Dimitri Fontaine
;; http://git.naquadah.org/?p=~dim/emacs.d.git;a=summary
(defun lsb-release (&optional property)
  "Parse lsb-release output and return an alist, or the value for the given property"
  (when (file-executable-p "/usr/bin/lsb_release")
    (let* ((lsbr (shell-command-to-string "/usr/bin/lsb_release -a 2>/dev/null"))
           (props (split-string lsbr "[:\n]" t))
           (kv))
      (while (>= (length props) 2)
        ;; Don't keep extra spaces. This way seems like the easy one in elisp.
        (let ((key (mapconcat 'identity (split-string (car props)) " "))
              (val (mapconcat 'identity (split-string (cadr props)) " ")))
          (setq kv (add-to-list 'kv (cons key val)))
          (setq props (cddr props))))
      (if property
          (cdr (assoc property (lsb-release)))
        kv))))

;; function copied from dim-ports.al by Dimitri Fontaine
;; http://git.naquadah.org/?p=~dim/emacs.d.git;a=summary
(defmacro when-running-ubuntu (&rest body)
  "eval body only when running under Ubuntu"
  (when (equal (lsb-release "Distributor ID") "Ubuntu") ,@body))

;; function adapted from dim-ports.al by Dimitri Fontaine
;; http://git.naquadah.org/?p=~dim/emacs.d.git;a=summary
(defmacro when-running-fedora (&rest body)
  "eval body only when running under Fedora"
  (when (equal (lsb-release "Distributor ID") "Fedora") ,@body))