I often need to link to the emacs manuals, for example, this markdown link: (emacs) Echo Area, is created via M-x chunyang-Info-markdown-current-node-html
since it's difficult to do it manually. With the following, you can also type O
to open the corresponding HTML manuals in your web browser.
(defvar chunyang-Info-html-alist
'(
;; Special cases come first
("org" . "http://orgmode.org/manual/%s")
("find" . "https://www.gnu.org/software/findutils/manual/html_node/find_html/%s")
("standards" . "https://www.gnu.org/prep/standards/html_node/%s")
("magit" . "https://magit.vc/manual/magit/%s")
("slime" . "https://www.common-lisp.net/project/slime/doc/html/%s")
;; Haha, just for some fun
("geiser" . (lambda (_)
;; (info "(geiser) First aids")
;; http://www.nongnu.org/geiser/geiser_3.html#First-aids
(if (string= Info-current-node "Top")
"http://www.nongnu.org/geiser/"
(let ((node (replace-regexp-in-string " " "-" Info-current-node))
(number (save-excursion
(goto-char (point-min))
(re-search-forward "^[0-9]")
(match-string 0))))
(format "http://www.nongnu.org/geiser/geiser_%s.html#%s" number node)))))
("gawk" . "https://www.gnu.org/software/tar/manual/html_node/%s")
;; GNU info documents. Taken from my memory or see https://www.gnu.org/software/
(("awk" "sed" "tar" "make" "m4" "grep" "coreutils" "guile" "screen"
"libc" "make" "gzip" "diffutils" "wget" "grub") .
(lambda (software)
(format "https://www.gnu.org/software/%s/manual/html_node/%%s" software)))
("gcc-5" . "https://gcc.gnu.org/onlinedocs/gcc/%s")
(("gdb" "stabs") .
(lambda (software)
(format "https://sourceware.org/gdb/onlinedocs/%s/%%s" software)))
;; Emacs info documents. Taken from `org-info-emacs-documents'
(("ada-mode" "auth" "autotype" "bovine" "calc" "ccmode" "cl" "dbus" "dired-x"
"ebrowse" "ede" "ediff" "edt" "efaq-w32" "efaq" "eieio" "eintr" "elisp"
"emacs-gnutls" "emacs-mime" "emacs" "epa" "erc" "ert" "eshell" "eudc" "eww"
"flymake" "forms" "gnus" "htmlfontify" "idlwave" "ido" "info" "mairix-el"
"message" "mh-e" "newsticker" "nxml-mode" "octave-mode" "org" "pcl-cvs"
"pgg" "rcirc" "reftex" "remember" "sasl" "sc" "semantic" "ses" "sieve"
"smtpmail" "speedbar" "srecode" "todo-mode" "tramp" "url" "vip" "viper"
"widget" "wisent" "woman") .
(lambda (package)
(format "https://www.gnu.org/software/emacs/manual/html_node/%s/%%s" package)))))
(defun chunyang-org-info-map-anchor-url (node)
"Return URL associated to Info NODE."
(require 'org) ; for `org-trim'
;; See (info "(texinfo) HTML Xref Node Name Expansion") for the
;; expansion rule
(let* ((node (replace-regexp-in-string "[ \t\n\r]+" " " (org-trim node)))
(node (mapconcat (lambda (c)
(if (string-match "[a-zA-Z0-9 ]" (string c))
(string c)
(format "_%04x" c)))
(string-to-list node) ""))
(node (replace-regexp-in-string " " "-" node))
(url (if (string= node "")
""
(if (string-match "[0-9]" (substring node 0 1))
(concat "g_t" node)
node))))
url))
(defun chunyang-Info-get-current-node-html ()
(cl-assert (eq major-mode 'Info-mode))
(let* ((file (file-name-nondirectory Info-current-file))
(node Info-current-node)
(html (if (string= node "Top")
""
(concat (chunyang-org-info-map-anchor-url node) ".html")))
(baseurl (cl-loop for (k . v) in chunyang-Info-html-alist
when (cond ((stringp k) (equal file k))
((listp k) (member file k)))
return (if (stringp v) v (funcall v file)))))
;; Maybe it's a good idea to assuming GNU softwares in this case
(cl-assert baseurl nil "Unsupported info document '%s'" file)
(format baseurl html)))
(defun chunyang-Info-browse-current-node-html ()
(interactive)
(let ((url (chunyang-Info-get-current-node-html)))
(browse-url url)))
(bind-key "O" #'chunyang-Info-browse-current-node-html Info-mode-map)
(defun chunyang-Info-markdown-current-node-html (&optional arg)
"ARG will be passed to `Info-copy-current-node-name'."
(interactive "P")
(let ((description (Info-copy-current-node-name arg))
(link (chunyang-Info-get-current-node-html)))
(let ((markdown (format "[%s](%s)" description link)))
(kill-new markdown)
(message "Copied: %s" markdown))))
If you need the offline HTML manuals, you need to get a local copy, the easiest is goto https://www.gnu.org/software/emacs/manual/elisp.html and click "HTML compressed" to download the HTML manual for Emacs Lisp manual, you need to do the same thing for Emacs manual, then change chunyang-Info-html-alist
to your local file address.
You can also build the HTML manuals from source code, see https://github.com/casouri/emacs-manuals/blob/master/build.sh for example.