emacs-w3m查看html帮助手册

*/-->

code {color: #FF0000}
pre.src {background-color: #002b36; color: #839496;}

emacs-w3m查看html帮助手册

1 使用效果

使用快捷键C-c C-j之后,打开如图所示的输入界面,可以用 正则表达式 搜索想要的API,查找非常方便:

用emacs-w3m打开html文件的效果如图:

2 为什么要用emacs-w3m来查看html的帮助手册?

  • 每次打开firefox,要等待较长时间,只为查看一个API的用法,感觉不爽。
  • 直接用emacs将html文件当作文本文件打开,一堆的tags不方便看。
  • 用浏览器搜索命令不够方便,不如emacs的正则表达式来的带劲。
  • 就是喜欢在emacs中做所有的事,这一条就够了。

4 配置

;;; init-emacs-w3m.el --- Summary
;;; Commentary:
;; comments ;;; Code:
(use-package w3m
:commands (w3m)
:config
;; (require 'w3m-load)
(setq w3m-coding-system 'utf-8
w3m-file-coding-system 'utf-8
w3m-file-name-coding-system 'utf-8
w3m-input-coding-system 'utf-8
w3m-output-coding-system 'utf-8
w3m-terminal-coding-system 'utf-8)
(setq w3m-use-cookies t)
(setq w3m-cookie-accept-bad-cookies t)
(setq w3m-home-page
(if (file-readable-p (expand-file-name "html/home.html" unimacs-tempfiles-dir))
(concat "file://" (expand-file-name "html/home.html" unimacs-tempfiles-dir))
"http://www.baidu.com")) ;; set proxy
(defun toggle-env-http-proxy ()
"set/unset the environment variable http_proxy which w3m uses"
(interactive)
(let ((proxy "http://proxynj.huawei.com:8080"))
(if (string= (getenv "http_proxy") proxy)
;; clear the the proxy
(progn
(setenv "http_proxy" "")
(message "env http_proxy is empty now")
)
;; set the proxy
(progn
(setenv "http_proxy" proxy)
(message "env http_proxy is %s now" proxy)
)))) (setq w3m-use-toolbar t
w3m-key-binding 'info) ;; show images in the browser
;; (setq w3m-default-display-inline-images t)
;; (setq w3m-default-toggle-inline-images t)
(setq w3m-view-this-url-new-session-in-background t)
;;显示图标
(setq w3m-show-graphic-icons-in-header-line t)
(setq w3m-show-graphic-icons-in-mode-line t) (setq w3m-search-default-engine "b")
(eval-after-load "w3m-search"
'(progn
;; C-u S g RET <search term> RET
(add-to-list 'w3m-search-engine-alist '("b" "http://www.baidu.com/search?hl=en&q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("g" "http://www.google.com.au/search?hl=en&q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("wz" "http://zh.wikipedia.org/wiki/Special:Search?search=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("q" "http://www.google.com.au/search?hl=en&q=%s+site:stackoverflow.com" utf-8))
(add-to-list 'w3m-search-engine-alist '("s" "http://code.ohloh.net/search?s=%s&browser=Default" utf-8))
(add-to-list 'w3m-search-engine-alist '("bl" "http://blogsearch.google.com.au/blogsearch?q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("w" "http://en.wikipedia.org/wiki/Special:Search?search=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("d" "http://dictionary.reference.com/search?q=%s" utf-8))
(add-to-list 'w3m-search-engine-alist '("j" "http://www.google.com.au/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&btnI=1&q=%s+site:developer.mozilla.org" utf-8))
)) (setq w3m-command-arguments '("-F" "-cookie")
w3m-mailto-url-function 'compose-mail
browse-url-browser-function 'w3m
mm-text-html-renderer 'w3m) ;; bind this function to ‘a’, which is the normal w3m bookmark binding:
(eval-after-load "w3m" '(progn
(w3m-lnum-mode 1)
)) ;; external browser
(setq browse-url-generic-program
(cond
(*is-a-mac* "open")
(*linux* (executable-find "firefox"))
))
(setq browse-url-browser-function 'browse-url-generic) ;; use external browser to search programming stuff
(defun w3mext-hacker-search ()
"search word under cursor in google code search and stackoverflow.com"
(interactive)
(require 'w3m)
(let ((keyword (w3m-url-encode-string (thing-at-point 'symbol))))
;; google
(browse-url-generic
(concat "http://www.google.com.au/search?hl=en&q=%22"
keyword
"%22"
(if buffer-file-name
(concat "+filetype%3A" (file-name-extension buffer-file-name))
"") ))
(browse-url-generic
(concat "http://www.google.com.au/search?hl=en&q="
keyword
"+site:stackoverflow.com" ))
;; koders.com
(browse-url-generic
(concat "http://code.ohloh.net/search?s=\""
keyword
"\"&browser=Default&mp=1&ml=1&me=1&md=1&filterChecked=true" ))
)) (defun w3mext-open-link-or-image-or-url ()
"Opens the current link or image or current page's uri or any url-like text under cursor in firefox."
(interactive)
(let (url)
(if (or (string= major-mode "w3m-mode") (string= major-mode "gnus-article-mode"))
(setq url (or (w3m-anchor) (w3m-image) w3m-current-url)))
(browse-url-generic (if url url (car (browse-url-interactive-arg "URL: "))))
))
(global-set-key (kbd "C-c b") 'w3mext-open-link-or-image-or-url) (defun w3mext-search-js-api-mdn ()
"search current symbol under cursor in Mozilla Developer Network (MDN)"
(interactive)
(let ((keyword (thing-at-point 'symbol)))
(w3m-search "j" keyword)
)) (add-hook 'prog-mode-hook '( lambda () (local-set-key (kbd "C-c ; h") 'w3mext-hacker-search))) ;; Find in blog.
;; @see: http://blog.csdn.net/superwen_go/article/details/8241601
(add-hook 'w3m-fontify-after-hook 'remove-w3m-output-garbages)
(defun remove-w3m-output-garbages ()
"去掉w3m输出的垃圾."
(interactive)
(let ((buffer-read-only))
(setf (point) (point-min))
(while (re-search-forward "[\200-\240]" nil t)
(replace-match " "))
(set-buffer-multibyte t))
(set-buffer-modified-p nil))
) (provide 'init-emacs-w3m)
;;; init-emacs-w3m.el ends here

5 额外资源

如果找不到w3m的执行程序,可以在我的github上面下载,这个是最新版的:
https://github.com/yangwen0228/unimacs/tree/master/utils/extra-bins/msys64

也可以下载我的配置,或者使用其中的部分配置,配置文件放置在 personal/configures中。

Date: 2016-12-31 10:38

Created: 2017-03-11 周六 21:53

Emacs 26.0.50.4 (Org mode 8.2.10)

Validate

emacs-w3m查看html帮助手册的更多相关文章

  1. Emacs 快速指南 - 原生中文手册

    Emacs 快速指南 -折叠目录 1. 小结(SUMMARY) 2. 基本的光标控制(BASIC CURSOR CONTROL) 3. 如果 EMACS 失去响应(IF EMACS STOPS RES ...

  2. Emacs 之查看帮助

    // */ // ]]> Emacs  之查看帮助 Table of Contents 1. Emacs 入门 1.1. 查看简单的帮助 1.2. 执行elisp代码 1 Emacs 入门   ...

  3. linux 命令 - man, help, info(查看命令帮助手册)

    man, help, info - 查看命令帮助手册   help xxx  # 显示内置命令帮助信息: xxx --help  # 显示外置命令帮助信息: man xxx  # 没有内建与外部命令的 ...

  4. Navi.Soft30.产品.Net对象查看器.操作手册

    1系统简介 1.1功能简述 在软件开发过程中,我们会编写各种类以及创建类的属性,方法,事件等.特别是第三方控件或组件,刚拿到手时,若没有完善的开发文档,很难下手.这时,若是可以查看这些DLL的成员对象 ...

  5. Ubuntu 下查看中文man手册方法

    转载自:http://blog.chinaunix.net/uid-24830506-id-3266493.html Ubuntu 中文man手册安装方法 分类: LINUX Ubuntu 下查看中文 ...

  6. ubuntu下安装pthread的manpages(man 手册) 在Ubuntu中查看STL帮助

    http://blog.csdn.net/leisure512/article/details/4881391 由于学习多线程编程,所以用到pthread,但是man的时候却发现没有pthread函数 ...

  7. Emacs 从入门到精通

    1 前言 不想再说废话了,既然你会阅读这篇文档,说明你多少对Emacs有 些兴趣,或者已 经非常熟悉Emacs的基础操作了,并且希望有所提高.因此我不需要再把"编辑器 之神,还是神的编辑器& ...

  8. Emacs阅读chm文档

    .title { text-align: center; margin-bottom: .2em } .subtitle { text-align: center; font-size: medium ...

  9. Emacs 快速指南(中文翻译)

      Emacs 快速指南 目录 1. 小结(SUMMARY) 2. 基本的光标控制(BASIC CURSOR CONTROL) 3. 如果 EMACS 失去响应(IF EMACS STOPS RESP ...

随机推荐

  1. poj1285 Combinations, Once Again(泛化背包)

    题目传送门 Combinations, Once Again Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1897   A ...

  2. Java Console/控制台 打印表格

    功能:控制台打印表格,支持字段动态长度,左对齐,右对齐,居中,设置最大列长,设置列间隔符,设置最多打印多少行. 类下载地址:http://download.csdn.net/download/j506 ...

  3. Riverside Curio

    Riverside Curio time limit per test1 second memory limit per test256 megabytes Arkady decides to obs ...

  4. C的基本数据类型小结

    代码 /** * 基本数据类型 */ #include <stdio.h> #include <limits.h> /* 定义 32 位时的 long 与 unsigned l ...

  5. shell选项和参数

  6. VBA-数据库操作

    基本概念 1 怎么样才能操作数据库?使用ADO建立和数据库的连接,然后用ADO对象和sql语言对数据库进行操作. 2 SQL是什么?SQL(Structured Query Language)是一种查 ...

  7. java面试题最容易犯错

    1. static 和 final 的用法 static 的作用从三个方面来谈,分别是静态变量.静态方法.静态类. 静态变量:声明为 static 的静态变量实质上就是全局变量,当声明一个对象时,并不 ...

  8. MyISAM和InnoDB引擎的区别

    MySQL默认采用的是MyISAM. MyISAM不支持事务,而InnoDB支持.InnoDB的AUTOCOMMIT默认是打开的,即每条SQL语句会默认被封装成一个事务,自动提交,这样会影响速度,所以 ...

  9. Rectangle类详解

    一,概括: 乍一看,可能感觉是一个矩形类,矩形类就是画一个长方形吗??这是我一开始见到这个类的感觉. 其实不是的Rectangle是一个“区域”类,它的最大作用就是定义一个矩形的区域,如果问为什么是矩 ...

  10. php socket简单原理及实现笔记

    1.什么是socket? socket:网络上的两个程序通过一个双向的通信连接实现数据的交换,连接的一端称为一个socket. 因此socket运行是置少有2个端组成,一个为服务端一个为客户端(客户端 ...