/[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.1.4.1 by ossau, Tue Nov 13 00:29:59 2001 UTC revision 1.1.4.2 by ossau, Tue Mar 12 20:49:00 2002 UTC
# Line 217  to which new docstrings should be added. Line 217  to which new docstrings should be added.
217                                           (match-end 1))))                                           (match-end 1))))
218            (if (string-equal matched "@c module ")            (if (string-equal matched "@c module ")
219                (setq module (read (current-buffer)))                (setq module (read (current-buffer)))
220              (setq matched              (let ((type (buffer-substring (match-beginning 2)
221                    (concat (buffer-substring (match-beginning 2)                                            (match-end 2))))
222                                              (match-end 2))                (if (string-equal type "{C Function}")
223                            " "                    nil
224                            (buffer-substring (match-beginning 3)                  (setq matched
225                                              (match-end 3))))                        (concat type
226              (message "Found docstring: %S: %s" module matched)                                " "
227              (let ((descriptions (assoc module alist)))                                (buffer-substring (match-beginning 3)
228                (setq alist                                                  (match-end 3))))
229                      (cons (cons module (cons matched (cdr-safe descriptions)))                  (message "Found docstring: %S: %s" module matched)
230                            (if descriptions                  (let ((descriptions (assoc module alist)))
231                                (delete descriptions alist)                    (setq alist
232                              alist))))))))                          (cons (cons module (cons matched (cdr-safe descriptions)))
233                                  (if descriptions
234                                      (delete descriptions alist)
235                                    alist))))))))))
236      alist))      alist))
237    
238  ;; Return the docstring from the specified LOCATION.  LOCATION is a  ;; Return the docstring from the specified LOCATION.  LOCATION is a
# Line 428  new snarfed docstring file.\n\n") Line 431  new snarfed docstring file.\n\n")
431      (insert "\n")      (insert "\n")
432    
433      (goto-char (point-min))      (goto-char (point-min))
434        (local-set-key "d" 'docstring-ediff-this-line)
435    
436      ;; Popup the issues buffer.      ;; Popup the issues buffer.
437      (let ((pop-up-frames t))      (let ((pop-up-frames t))
# Line 535  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.1.4.1  
changed lines
  Added in v.1.1.4.2

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