Skip to content

Latest commit

 

History

History
99 lines (67 loc) · 3.76 KB

README.md

File metadata and controls

99 lines (67 loc) · 3.76 KB

Melpa Status Melpa Stable Status Build Status

use-proxy

Introduction

With this package you can easily enable/disable proxies per protocol in you Emacs. You could also use this package to provide proxy settings for a group of s-expressions. This package respects your $HTTP_PROXY, $HTTPS_PROXY and $NO_PROXY shell environment variables.

Install

If you don't have ELPA package in your Emacs, clone this repository and load file.

git clone https://github.com/rayw000/use-proxy.git
(load-file "/path/to/use-proxy/use-proxy.el")
(require 'use-proxy)

Usage

Globally enable use-proxy-mode.

(use-proxy-mode)

You can bind keys to function use-proxy-toggle-proto-proxy and use-proxy-toggle-proxies-global, for example

(global-set-key (kbd "C-c C-p") 'use-proxy-toggle-proto-proxy)
(global-set-key (kbd "C-c C-g") 'use-proxy-toggle-proxies-global)

Customizations

This package provides these following variables you could customize:

  1. use-proxy-http-proxy

    HTTP proxy you could use. If not set, the value of $HTTP_PROXY in your environment will be used.

  2. use-proxy-https-proxy

    HTTPS proxy you could use. If not set, the value of $HTTPS_PROXY in your environment will be used.

  3. use-proxy-no-proxy

    A regular expression matches hosts you don't want to connect through proxy. If not set, the value of $NO_PROXY in your environment will be used.

  4. use-proxy-display-in-global-mode-string

    Boolean indicates whether display proxy states in global-mode-string. If non-nil, proxy states will also be added into global-mode-string. In which case even if you turn off minor mode list or work with diminish, proxy states would still be visible in your mode line if you enable %M substitution.

NOTICE: Do not forget to load your custom-file if you customized these variables.

Macros and functions

  1. Toggle specified proxy by protocol.
(use-proxy-toggle-proto-proxy)

Running this command will prompt you available protocols to choose to enable the corresponding proxy. Enabled proxies will be shown in the minor mode lighter.

  1. Toggle proxies global or not (respect no_proxy settings or not).
(use-proxy-toggle-proxies-global)

If using proxies globally, a g will be appended to lighter.

  1. Temporarily enable proxy for a batch of s-expressions. You are only required to provide a protocol list which you want to enable proxies for. This macro will read corresponding proxy settings from your customization variables.
(use-proxy-with-custom-proxies '("http" "https")
  (browse-url-emacs "https://www.google.com"))
  1. Toggle all proxies on/off
(use-proxy-toggle-all-proxies)
  1. Temporarily enable proxy for a batch of s-expression. You are required to provide a proxy setting association list.
(use-proxy-with-specified-proxies '(("http" . "localhost:8080")
                                    ("https" . "localhost:8081"))
                                  (browse-url-emacs "https://www.google.com"))

How it works

All use-proxy does is manipulating your url-proxy-services variable. Every time you toggle proxies, url-proxy-services will be saved into your custom.el file. When use-proxy-mode is on, this variable will be loaded.

Similar packages

with-proxy, proxy-mode