如何检查Emacs Lisp中是否存在服务器
我正在编写一个函数,用于测试组织模式缓冲区中的断开链接:如何检查Emacs Lisp中是否存在服务器,emacs,elisp,org-mode,Emacs,Elisp,Org Mode,我正在编写一个函数,用于测试组织模式缓冲区中的断开链接: (setq urls '("http://google.com" "http://bing.com" "http://www.yahoo.com" "http://thisdoesntexist.net")) (while (setq nextlink (car urls)) (if (url-http-file-exists-p nextlink) (message "Link wor
(setq urls '("http://google.com" "http://bing.com" "http://www.yahoo.com" "http://thisdoesntexist.net"))
(while (setq nextlink (car urls))
(if (url-http-file-exists-p nextlink)
(message "Link works: %s" nextlink)
(message "Broken Link found: %s" nextlink))
(setq urls (cdr urls)))
除非遇到一个不存在的web服务器,否则这是有效的。然后它抛出一个lisp错误并打开一个回溯缓冲区
我想要的是,首先测试服务器是否存在,如果存在,然后使用url-http-file-exists-p检查特定文档
谢谢
- 编辑以添加适合我的解决方案。谢谢你!
(while(setq nextlink(汽车URL)) (情况无) (如果(url-http-file-exists-p nextlink) (消息“链接工作:%s”下一个链接) (消息“找到断开的链接:%s”下一个链接)) ((错误)(消息“未找到服务器:%s”nextlink))) (setq URL(cdr URL)))
条件案例
块捕获错误
(while (setq nextlink (car urls))
(condition-case nil
(if (url-http-file-exists-p nextlink)
(message "Link works: %s" nextlink)
(message "Broken Link found: %s" nextlink))
((error) (message "Server not found: %s" nextlink)))
(setq urls (cdr urls)))