diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-12-10 19:13:08 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-12-10 19:13:08 -0500 |
commit | 2c302df3a13236bfbf8ea1b771d13618fcda8d71 (patch) | |
tree | f26dc9f22861dc37610de319d05255de058c221b /lisp/help-fns.el | |
parent | 0c747cb143fa227e78f350ac353d703f489209df (diff) | |
parent | 175069efeb080517afefdd44a06f7a779ea8c25c (diff) | |
download | emacs-2c302df3a13236bfbf8ea1b771d13618fcda8d71.tar.gz |
Merge from trunk
Diffstat (limited to 'lisp/help-fns.el')
-rw-r--r-- | lisp/help-fns.el | 106 |
1 files changed, 105 insertions, 1 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index c707baf98c2..65bcdbcb8f8 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -912,7 +912,111 @@ BUFFER should be a buffer or a buffer name." (insert "\nThe parent category table is:") (describe-vector table 'help-describe-category-set)))))) + +;;; Replacements for old lib-src/ programs. Don't seem especially useful. + +;; Replaces lib-src/digest-doc.c. +;;;###autoload +(defun doc-file-to-man (file) + "Produce an nroff buffer containing the 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)) + (pop-to-buffer (generate-new-buffer "*man-doc*")) + (setq buffer-undo-list t) + (insert ".TH \"Command Summary for GNU Emacs\"\n" + ".AU Richard M. Stallman\n") + (insert-file-contents file) + (let (notfirst) + (while (search-forward "" nil 'move) + (if (looking-at "S") + (delete-region (1- (point)) (line-end-position)) + (delete-char -1) + (if notfirst + (insert "\n.DE\n") + (setq notfirst t)) + (insert "\n.SH ") + (insert (if (looking-at "F") "Function " "Variable ")) + (delete-char 1) + (forward-line 1) + (insert ".DS L\n")))) + (insert "\n.DE\n") + (setq buffer-undo-list nil) + (nroff-mode)) + +;; 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) + (unless (looking-at "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))) + (provide 'help-fns) -;; arch-tag: 9e10331c-ae81-4d13-965d-c4819aaab0b3 ;;; help-fns.el ends here |