[comp.emacs] GnuEmacs documentation scanner.

obh@IFI.UIO.NO (12/06/87)

	When I  first started writing  Gnu-lisp  I  found myself quite
often browsing trough the lisp-function manual to find some function I
could use. I hated it, so I wrote a  function to search for the wanted
function and print it/them.

	This version read  a modified  DOC file, search for a reg-exp,
print the function/variable in a temporary buffer, loop.

	Bugs: This will not work for any function/variable not defined
in the DOC file. Hopefully, FSF will change this in v.19?

------------------------ Cut here ----------------------------------
;; Finding DOCstrings  (C) 1987, Ole Bj|rn Hessen. (chardef |=\o).

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY.  The author accepts no responsibility to
;; anyone for the consequences of using it or for whether it serves
;; any particular purpose or works at all.
;;
;; Everyone is granted permission to copy, modify, and redistribute
;; this function.
;;
;; This notice must be preserved on all copies.

(defvar emacs-doc-file "~obh/emacs/man/emacs.doc"
  "The modified doc file resides here.")
;Change this filespec!

;run this function first.
(defun create-man()
  "Creates a readable and sorted version of the /etc/DOC file."
  (interactive)
  (save-excursion
    (find-file-read-only
        (expand-file-name (concat "DOC-" emacs-version)  exec-directory))
    (let (mode-line-format)
      (setq mode-line-format " Wait, it might take some time !! ")
      (sit-for 0)
      (toggle-read-only)		;clear any read-only flag
      (set-visited-file-name emacs-doc-file)
      (auto-save-mode 0)		;no auto saving.
      (sort-regexp-fields nil "\C-_[^\C-_]*" "\C-_[A-Za-z---]*"
			  (point-min) (point-max))
      ;sorts the file: First functions (alphabetic) and then the variables.
      (goto-char (point-min))
      (while (not (eobp))		;make ``pretty'' doc strings
	(delete-char 2)
	(insert-char ?\n 2)
	(skip-chars-forward "^\n\t ")
	(insert-char ?: 2)
	(skip-chars-forward "^" (point-max)))
      (setq mode-line-format " Saving the DOC file !! ")
      (sit-for 0)
      (save-buffer))))			;save changes made
;     (kill-buffer (current-buffer)))))	;kill the buffer.


(defun DocFind (s)
  "Prints every function and variable containing REGEXP in doc file.
The search is case sensitive. That way you're able to search for
functions accepting e.g. STRING argument. "
  (interactive "sFind DOC-regexp: ")
  (let (start-doc)
    (save-excursion
      (find-file emacs-doc-file)
      (goto-char (point-min))
      (setq case-fold-search nil)
      (with-output-to-temp-buffer "*Help*"
	(while (re-search-forward s (point-max) 0)
	  (if (not (looking-at "[A-Za-z---]*::"))
	      (search-backward "::"))
	  (beginning-of-line)
	  (setq start-doc (point))
	  (forward-line 1)
	  (search-forward "::")
	  (beginning-of-line)
	  (princ (buffer-substring start-doc (point)))))
      (bury-buffer (current-buffer)))))

;Uses DocFind after appending header delimiter.
(defun DocApropo (s)
  (interactive "sApropo DOC-regexp: ")
  (DocFind (concat s ".*::")))
-------------------------- Cut here ------------------

	I've also written some functions for commenting next/ previous
line; deleting any empty comment  before moving on  (like  the  `true'
emacs), functions for making a  permutation  of a list  or lines in  a
region.  (Actually,   believe  it or   not, somebody  complained about
Gnuemacs not  having  such functions!!  *;^). And  a major simula mode
(alpha-version). If somebody interested I'll send it.

	BTW:   I'm looking for the sources for the unix-version of
	ISPELL. I've got the .MID source, but.... If anybody could
	tell me where I can find ispell, I'd sure be very happy!!!
	

	
Arpa:	obh@ifi.uio.no					(OBH)