/[guile]/guile/guile-core/doc/maint/docstring.el
ViewVC logotype

Diff of /guile/guile-core/doc/maint/docstring.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by ossau, Fri Nov 16 15:04:16 2001 UTC revision 1.5 by ossau, Fri Mar 8 13:13:36 2002 UTC
# Line 539  new snarfed docstring file.\n\n") Line 539  new snarfed docstring file.\n\n")
539  ;(find-tracking-docstring '(guile) "primitive sloppy-assq")  ;(find-tracking-docstring '(guile) "primitive sloppy-assq")
540  ;(find-snarfed-docstring '(guile) "primitive sloppy-assq")  ;(find-snarfed-docstring '(guile) "primitive sloppy-assq")
541    
542    (defvar docstring-libguile-directory (expand-file-name "libguile"
543                                                           guile-core-dir)
544      "*The directory containing the C source for libguile.")
545    
546    (defun docstring-display-location (file line)
547      (let ((buffer (find-file-noselect
548                     (expand-file-name file docstring-libguile-directory))))
549        (if buffer
550            (let* ((window (or (get-buffer-window buffer)
551                               (display-buffer buffer)))
552                   (pos (save-excursion
553                          (set-buffer buffer)
554                          (goto-line line)
555                          (point))))
556              (set-window-point window pos)))))
557    
558    (defun docstring-show-source ()
559      "Given that point is sitting in a docstring in one of the Texinfo
560    source files for the Guile manual, and that that docstring may be
561    snarfed automatically from a libguile C file, determine whether the
562    docstring is from libguile and, if it is, display the relevant C file
563    at the line from which the docstring was snarfed.
564    
565    Why?  When updating snarfed docstrings, you should usually edit the C
566    source rather than the Texinfo source, so that your updates benefit
567    Guile's online help as well.  This function locates the C source for a
568    docstring so that it is easy for you to do this."
569      (interactive)
570      (let* ((deffn-line
571               (save-excursion
572                 (end-of-line)
573                 (or (re-search-backward "^@deffn " nil t)
574                     (error "No docstring here!"))
575                 (buffer-substring (point)
576                                   (progn
577                                     (end-of-line)
578                                     (point)))))
579             (guile-texi-file
580              (expand-file-name "guile.texi" docstring-libguile-directory))
581             (source-location
582              (save-excursion
583                (set-buffer (find-file-noselect guile-texi-file))
584                (save-excursion
585                  (goto-char (point-min))
586                  (or (re-search-forward (concat "^"
587                                                 (regexp-quote deffn-line)
588                                                 "$")
589                                         nil t)
590                      (error "Docstring not from libguile"))
591                  (forward-line -1)
592                  (if (looking-at "^@c snarfed from \\([^:]+\\):\\([0-9]+\\)$")
593                      (cons (match-string 1)
594                            (string-to-int (match-string 2)))
595                    (error "Corrupt docstring entry in guile.texi"))))))
596        (docstring-display-location (car source-location)
597                                    (cdr source-location))))
598    
599    
600  (provide 'docstring)  (provide 'docstring)
601    
602  ;;; docstring.el ends here  ;;; docstring.el ends here

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26