From 17284e30244d0dd635708cec51e19bafcd9a528b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 22 Oct 2010 19:46:06 -0700 Subject: Replace digest-doc and sorted-doc C programs with Lisp commands. * lib-src/digest-doc.c, lib-src/sorted-doc.c: Remove files. * lib-src/Makefile.in (UTILITIES): Remove digest-doc and sorted-doc. (digest-doc${EXEEXT}, sorted-doc${EXEEXT}): Remove rules. * lib-src/makefile.w32-in (ALL): Remove digest-doc and sorted-doc. ($(BLD)/sorted-doc.exe, $(BLD)/digest-doc.exe, sorted-doc, digest-doc) ($(BLD)/digest-doc.$(O), $(BLD)/sorted-doc.$(O)): Remove rules. (install): Don't install digest-doc.exe or sorted-doc.exe. * lisp/help-fns.el (doc-file-to-man, doc-file-to-info): New commands. * doc/lispref/help.texi (Documentation Basics): Remove mentions of digest-doc and sorted-doc. * INSTALL, nt/README, nt/README.W32: Do not mention digest-doc and sorted-doc. * etc/NEWS: Mention this change. --- lisp/help-fns.el | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) (limited to 'lisp/help-fns.el') diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 9739762637a..d49b06a16e6 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -887,7 +887,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 -- cgit v1.2.1