Function: doc-file-to-info
doc-file-to-info is an autoloaded, interactive and byte-compiled
function defined in help-fns.el.gz.
Signature
(doc-file-to-info FILE)
Documentation
Produce a texinfo buffer with sorted doc-strings from the DOC file.
Probably introduced at or before Emacs version 24.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
;; Replaces lib-src/sorted-doc.c.
;;;###autoload
(defun doc-file-to-info (file)
"Produce a texinfo buffer with sorted doc-strings from the DOC file."
(interactive (list (read-file-name "Name of DOC file: " doc-directory
internal-doc-file-name t)))
(or (file-readable-p file)
(error "Cannot read file `%s'" file))
(let ((i 0) type name doc alist)
(with-temp-buffer
(insert-file-contents file)
;; The characters "@{}" need special treatment.
(while (re-search-forward "[@{}]" nil t)
(backward-char)
(insert "@")
(forward-char 1))
(goto-char (point-min))
(while (search-forward "\^_" nil t)
(when (/= (following-char) ?S)
(setq type (char-after)
name (buffer-substring (1+ (point)) (line-end-position))
doc (buffer-substring (line-beginning-position 2)
(if (search-forward "\^_" nil 'move)
(1- (point))
(point)))
alist (cons (list name type doc) alist))
(backward-char 1))))
(pop-to-buffer (generate-new-buffer "*info-doc*"))
(setq buffer-undo-list t)
;; Write the output header.
(insert "\\input texinfo @c -*-texinfo-*-\n"
"@setfilename emacsdoc.info\n"
"@settitle Command Summary for GNU Emacs\n"
"@finalout\n"
"\n@node Top\n"
"@unnumbered Command Summary for GNU Emacs\n\n"
"@table @asis\n\n"
"@iftex\n"
"@global@let@ITEM@item\n"
"@def@item{@filbreak@vskip5pt@ITEM}\n"
"@font@tensy cmsy10 scaled @magstephalf\n"
"@font@teni cmmi10 scaled @magstephalf\n"
"@def\\{{@tensy@char110}}\n" ; this backslash goes with cmr10
"@def|{{@tensy@char106}}\n"
"@def@{{{@tensy@char102}}\n"
"@def@}{{@tensy@char103}}\n"
"@def<{{@teni@char62}}\n"
"@def>{{@teni@char60}}\n"
"@chardef@@64\n"
"@catcode43=12\n"
"@tableindent-0.2in\n"
"@end iftex\n")
;; Sort the array by name; within each name, by type (functions first).
(setq alist (sort alist (lambda (e1 e2)
(if (string-equal (car e1) (car e2))
(<= (cadr e1) (cadr e2))
(string-lessp (car e1) (car e2))))))
;; Print each function.
(dolist (e alist)
(insert "\n@item "
(if (char-equal (cadr e) ?\F) "Function" "Variable")
" @code{" (car e) "}\n@display\n"
(nth 2 e)
"\n@end display\n")
;; Try to avoid a save size overflow in the TeX output routine.
(if (zerop (setq i (% (1+ i) 100)))
(insert "\n@end table\n@table @asis\n")))
(insert "@end table\n"
"@bye\n")
(setq buffer-undo-list nil)
(texinfo-mode)))