Is it possible to tell emacs on Windows to use the IE http proxy settings?

家住魔仙堡 提交于 2019-12-02 23:37:47

Yes, it's possible.

The basic idea is to define before-advice for the URL functions, and set those variables to appropriate values. This requires being able to retrieve the IE proxy settings from Windows, from within elisp.

The w32-registry package does this.

Therefore, on Windows, you can do this:

(eval-after-load "url"
  '(progn
     (require 'w32-registry)
     (defadvice url-retrieve (before
                              w32-set-proxy-dynamically
                              activate)
       "Before retrieving a URL, query the IE Proxy settings, and use them."
       (let ((proxy (w32reg-get-ie-proxy-config)))
         (setq url-using-proxy proxy
               url-proxy-services proxy)))))

If you are handling URL's via browse-url, you can also set it to Windows-specific function like this. Then the URL's will be handled by Windows (invoking your default browser).

browse-url-browser-function is a variable defined in `browse-url.el'.

Its value is browse-url-default-windows-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!