Paste number 354730: emacs profile

Paste number 354730: emacs profile
Pasted by: janneke
When:4 years, 11 months ago
Share:Tweet this! |
Paste contents:
Raw Source | XML | Display As
(defun matches-in-string (regexp string)
  "return a list of matches of REGEXP in STRING."
  (let ((matches))
      (string-match "^" "")
      (while (string-match regexp string (match-end 0))
        (push (or (match-string 1 string) (match-string 0 string)) matches)))

(defun guix-switch-profile (&optional profile)
  "reset Emacs' environment by snarfing PROFILE/etc/profile"
  (interactive "fprofile: ")
  (let* ((output (shell-command-to-string (concat "/bin/sh -x " profile "/etc/profile")))
         (exports (matches-in-string "^[+] export \\(.*\\)" output)))
   (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.