;; -*- lexical-binding: t; -*- (defun set-proxy (proxy) (setq url-proxy-services `(("https" . ,proxy) ("http" . ,proxy) ("no_proxy" . "^\\(127\\.0\\.0\\.1\\|localhost\\|.*local\\|169\\.254\\.169\\.254\\|.*kdc\\.capitalone\\.com\\|.*cloud\\.capitalone\\.com\\|.*clouddqt\\.capitalone.com\\)"))) (setenv "https_proxy" proxy) (setenv "http_proxy" proxy) (setenv "no_proxy" "127.0.0.1,localhost,.local,.internal,169.254.169.254,.kdc.capitalone.com,.cloud.capitalone.com,.clouddqt.capitalone.com,.cloud.uk.capitalone.com,.clouddqt.uk.capitalone.com")) (defun cofproxy () (interactive) (request "http://127.0.0.1:44444/proxy.pac" :sync t :success (cl-function (lambda (&key data &allow-other-keys) (let ((line)) (with-temp-buffer (insert data) (search-backward "return \"PROXY") (setq line (string-trim (thing-at-point 'line t)))) (setq line (string-trim-right (string-trim-left line "return \"PROXY ") "\";")) (setq line (concat "http://" line)) (set-proxy line) (message "Proxy Set: %s" line)))))) (add-hook 'after-init-hook #'cofproxy) (provide 'init-cof)