emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: doc-strings in src/ and the first line


From: Eric M. Ludlam
Subject: Re[2]: doc-strings in src/ and the first line
Date: Wed, 14 Nov 2001 20:30:09 -0500

>>> address@hidden (Pavel =?iso-8859-2?q?Jan=EDk?=) seems to think that:
>
>   From: Eli Zaretskii <address@hidden>
>   Date: Wed, 14 Nov 2001 13:36:10 +0200 (IST)
>
>   > > It is embarrassing that we had accumulated so many mistakes.
>   > 
>   > How about writing something for src/Makefile.in which would find such 
>   > mistakes?  Any takers?
>
>We already have this check implemented in checkdoc (but it can only check
>for these bugs in elisp files). BTW - if anyone considers creating such
>Makefile target: what about checking only the contents of the DOC file
>directly (or make-docfile.c)? It should be quite straightforward then.
>
>Hmm, when this mail was in my outgoing queue, I gave it a try. I did not
>wanted to spend more than 10 minutes on it, so here is a result:

Here is a quick hack of mine to convert an entry from the DOC file
into something lispy, and then run checkdoc-defun on it.

In theory, a little more hacking can get it to output specific errors
to be fixed using checkdoc's logging mechanism, and then the whole
DOC file could be checked.

Have fun
Eric

--------------
(defun checkdoc-defun-DOC (&optional no-error)
  "Examine the current docstring of the function under point in DOC.
The DOC file contains documentation strings associated with the built in
commands for Emacs.
Optional argument NO-ERROR is passed to `checkdoc-defun'."
  (interactive)
  (let ((text (buffer-substring-no-properties
               (save-excursion (re-search-backward "\C-_" nil t)
                               (beginning-of-line)
                               (point))
               (save-excursion (re-search-forward "\C-_" nil t)
                               (beginning-of-line)
                               (forward-line -1)
                               (point))))
        )
    (save-excursion
      (save-window-excursion
        (switch-to-buffer (get-buffer-create "*checkdoc tmp*"))
        (erase-buffer)
        (emacs-lisp-mode)
        (insert text)
        (goto-char (point-min))
        (cond ((looking-at "(")
               (insert "(defun ")
               (delete-char 1)
               (forward-sexp 1)
               (skip-syntax-forward "-")
               (insert " (")
               (re-search-forward ")")
               (delete-region (point) (progn (forward-sexp 1) (point)))
               (forward-char 1)
               )
              (t
               (insert "(defvar ")
               (delete-char 2)
               (end-of-line)
               (insert " nil")
               (forward-char 1)
               ))
        (insert "\"")
        (goto-char (point-max))
        (insert "\")")
        (goto-char (point-min))
        (forward-word 1)
        (checkdoc-defun no-error)
        (sit-for 1)
        ))))

-- 
          Eric Ludlam:                 address@hidden, address@hidden
   Home: www.ultranet.com/~zappo            Siege: www.siege-engine.com
Emacs: http://cedet.sourceforge.net               GNU: www.gnu.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]