进melpa后再改回来应该就不会管了吧
感谢啊 喵✨
MELPA有些事情管太严了,比如我喜欢写(when (not ...) ...)
非得让我改成(unless ... ...)
每次看unless form都费我好大劲才明白
我觉得 unless 太方便了, 因为偷懒习惯了
我也看不懂unless,但是从开始的讨厌变成现在自己也用了,只是每次看到还是在心里默念“if not ……”
后来我想了个办法规避melpa的检查
(cond
((not pred)
do-something-here...)
(t
nil))
可以这样,写的时候 when,提交的时候改回 unless (误)
不过,我倒是写了一个 emacs-refactor 函数用来切换 when/less:
(defun emr-el--toggle-when-unless (sym rep)
"Toggle the enclosing when/unless form from SYM to REP."
(let ((pos (emr-lisp-find-upwards sym)))
(when pos
(save-excursion
;; replace symbol
(goto-char pos)
(forward-char)
(mark-sexp)
(delete-and-extract-region (region-beginning) (region-end))
(insert (format "%s" rep))
;; toggle condition form
(let (cond-form)
(forward-sexp)
(backward-sexp)
(cond
;; remove (not...) wrap
((looking-at "(not\\b")
(save-excursion
(down-list)
(forward-sexp 2)
(backward-sexp)
(mark-sexp)
(setq cond-form (delete-and-extract-region (region-beginning) (region-end))))
(mark-sexp)
(delete-region (region-beginning) (region-end))
(insert cond-form))
;; add (not...) wrap
(t
(mark-sexp)
(setq cond-form (delete-and-extract-region (region-beginning) (region-end)))
(insert "(not " cond-form ")"))))))
pos))
(defun emr-el-toggle-when-unless ()
"Toggle between when and unless in the enclosing when/unless form."
(interactive)
(or (emr-el--toggle-when-unless 'when 'unless)
(emr-el--toggle-when-unless 'unless 'when)))
(emr-declare-command 'emr-el-toggle-when-unless
:title "toggle when/unless"
:modes 'emacs-lisp-mode
:predicate (lambda ()
(or (emr-lisp-find-upwards 'when)
(emr-lisp-find-upwards 'unless))))
unless
展开成(if cond nil ...body)
然后byte-opt里有道步骤把(if cond nil ...body)
转换成(if (not cond) (progn ...body))
,等效(when (not cond) ...body)
。可能这就叫做脱裤子放屁吧
MELPA 的审核主要是为了让排版好看一些吧,底层怎么负负得正就不管了。
那是因为英语不是母语,老外都习惯 unless
不是的,unless念成“除非”我也还是想不明白,因为从学写代码开始就只会用“如果”来思考……
所以现在很多语言支持把unless放后面,这就是老外的自然语言思维
有这个检查?是人工给的建议吧?貌似还没这个自动化检查。如果我来审核,我多半也会给同样的建议,因为有些人不知道有 unless
,如果你偏好 (when (not ...
,不改没所谓的啦,解释下就完了。
;; eww
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|10.*\\)")
("http" . "127.0.0.1:8123") ;; notice without protocol, do NOT add protocol
("https" . "127.0.0.1:8123")))
M-x eww
RET https://www.google.com RET
# FILENAME: $HOME/.w3m/config
use_proxy 1
http_proxy http://127.0.0.1:8123
https_proxy http://127.0.0.1:8123 # not https
M-x w3m-goto-url
RET https://www.google.com RET
# To set globally, add to your $HOME/.profile
export http_proxy=http://127.0.0.1:8123
export https_proxy=$http_proxy
# or if you want to use SOCKS proxy
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=$http_proxy
;; To set curl options
(setq request-curl-options
(nconc '("--proxy" "socks5://127.0.0.1:1080")))
v2ray配置
"inbounds": [
{
"tag": "socks-in",
"port": 1080,
"listen": "::",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1"
}
},
{
"tag": "http-in",
"port": 8123,
"listen": "::",
"protocol": "http"
}
],
manual
抱歉,挖了个坟。按照这个代理设置始终连不上网络,有没有类似问题的。 版本master-branch。win10.
;;; proxy
;;socks proxy
(setq url-gateway-method 'socks)
(setq socks-server '("Default server" "localhost" 1080 5))
;;http proxy
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
("http" . "localhost:1081")
("https" . "localhost:1081")))
url-gateway-method 'socks 和 url-proxy-services 能同时设置吗?一个设置 socks 代理,一个设置 http 代理。假设能的话,哪一个生效?
好像 url-gateway-method 'socks 只支持 http,不支持 https:
(setq url-gateway-method 'socks)
(setq socks-server
'("Default server" "localhost" 12345 5))
;; 没用到 socks 代理,正常访问
(display-buffer
(url-retrieve-synchronously
"https://example.com"))
;; 用到 socks 代理,提示代理有问题
(display-buffer
(url-retrieve-synchronously
"http://example.com"))
现在网站大多采用 HTTPS,而上面的 socks 代理对 HTTPS 没效果,所以应该改用 http 代理。
这是我使用的命令,只要改 url-proxy-services,不用碰别的:
(defun chunyang-toggle-url-proxy ()
"Toggle proxy for the url.el library."
(interactive)
(cond
(url-proxy-services
(message "Turn off URL proxy")
(setq url-proxy-services nil))
(t
(message "Turn on URL proxy")
(setq url-proxy-services
'(("http" . "localhost:1087")
("https" . "localhost:1087")
("no_proxy" . "0.0.0.0"))))))
多谢,细致的解释,起作用了。一直以为两者可以并存。
楼上大伙们用的url-proxy-services只能针对基于url
这个内置包的众多package,由于emacs发起网络请求是基于make-network-process
的,所以最根本的方法是临时设置环境变量到`process-environment‘里。
可以麻烦你详细说一下怎么操作吗?最近安装all-the-icons遇到这个open-network-stream: make client process failed: Connection refusedopen-network-stream: make client process failed: Connection refused问题。