guile-devel
[Top][All Lists]
Advanced

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

Re: typo


From: Neil Jerram
Subject: Re: typo
Date: 08 Mar 2002 12:31:51 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "thi" == Thien-Thi Nguyen <address@hidden> writes:

    thi> forget the spellcheck script idea -- here's a better one: i
    thi> would love to have a script that, given some lines from a
    thi> texi file, determines if those lines are somehow processed
    thi> from source code (snarfed) and if so, list the suspected
    thi> snarf method/target.  this tool would make it easy for casual
    thi> docs maintainers (like me and you) to find out the Real Place
    thi> to fix things if need be, instead of worrying that any
    thi> applied fix might be overridden later by snarfing.  does this
    thi> make sense?

Happy to oblige ...  I've added the following to
doc/maint/docstring.el in the HEAD branch.  Entry point is `M-x
docstring-show-source'.

        Neil

(defvar docstring-libguile-directory (expand-file-name "libguile"
                                                       guile-core-dir)
  "*The directory containing the C source for libguile.")

(defun docstring-display-location (file line)
  (let ((buffer (find-file-noselect
                 (expand-file-name file docstring-libguile-directory))))
    (if buffer
        (let* ((window (or (get-buffer-window buffer)
                           (display-buffer buffer)))
               (pos (save-excursion
                      (set-buffer buffer)
                      (goto-line line)
                      (point))))
          (set-window-point window pos)))))

(defun docstring-show-source ()
  "Given that point is sitting in a docstring in one of the Texinfo
source files for the Guile manual, and that that docstring may be
snarfed automatically from a libguile C file, determine whether the
docstring is from libguile and, if it is, display the relevant C file
at the line from which the docstring was snarfed.

Why?  When updating snarfed docstrings, you should usually edit the C
source rather than the Texinfo source, so that your updates benefit
Guile's online help as well.  This function locates the C source for a
docstring so that it is easy for you to do this."
  (interactive)
  (let* ((deffn-line
           (save-excursion
             (end-of-line)
             (or (re-search-backward "address@hidden " nil t)
                 (error "No docstring here!"))
             (buffer-substring (point)
                               (progn
                                 (end-of-line)
                                 (point)))))
         (guile-texi-file
          (expand-file-name "guile.texi" docstring-libguile-directory))
         (source-location
          (save-excursion
            (set-buffer (find-file-noselect guile-texi-file))
            (save-excursion
              (goto-char (point-min))
              (or (re-search-forward (concat "^"
                                             (regexp-quote deffn-line)
                                             "$")
                                     nil t)
                  (error "Docstring not from libguile"))
              (forward-line -1)
              (if (looking-at "address@hidden snarfed from 
\\([^:]+\\):\\([0-9]+\\)$")
                  (cons (match-string 1)
                        (string-to-int (match-string 2)))
                (error "Corrupt docstring entry in guile.texi"))))))
    (docstring-display-location (car source-location)
                                (cdr source-location))))




reply via email to

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