emacs-devel
[Top][All Lists]
Advanced

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

Re: building directory


From: Stefan Monnier
Subject: Re: building directory
Date: Fri, 04 Apr 2003 09:51:06 -0500

> I'd like to prepare an user interface to access emacs C source
> files easily. M-x describe-function is very good entry point for
> my goal.

I'd like that too.  And also for built-in variables.
I've been using a patch (that I posted to this list a while back)
to do what you suggest.  There are several different possible
approaches to do what you want.

You want to be careful about the fact that source files
might have been edited since the last build so the source-line info
might be off.  This means that even if you have the line number,
you'll have to search for the right DEFUN, so the line info is not
that useful anyway.

I think an other approach along the lines of yours would be
to simply adjust the initial `load-history'.  That would
give you the equivalent of `source-file', but using `symbol-file'.
It's probably not that different in the end.  Although
the generalization to built-in variables is more obvious.

My patch (see below) simply relies on having TAGS built in the
source directory.  It's not a bad approach although it's not
great either: the main problem is that the etags.el functions
make it a bit difficult to locally use a tags table without impacting
other uses of tags that might be going on already.  Of course
the other problem is that it requires TAGS, but I find that it's
not a big problem and even has the advantage that it even works
in the case where a function is moved from one file to another.
Also it does not require any extra information in Emacs, so people
who don't use it don't pay anything for it.  This is relevant
(though maybe not too important) because it is a feature
likely to be used only by a small minority of the users.
I wanted to fix etags.el so that my patch could be made cleaner,
but I haven't gotten to it (mostly because it works well enough
for me :-( ).


        Stefan


Index: help-fns.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.30
diff -u -r1.30 help-fns.el
--- help-fns.el 12 Feb 2003 23:13:43 -0000      1.30
+++ help-fns.el 4 Apr 2003 14:43:23 -0000
@@ -285,9 +286,36 @@
       (princ "'")
       ;; Make a hyperlink to the library.
       (with-current-buffer standard-output
        (save-excursion
          (re-search-backward "`\\([^`']+\\)'" nil t)
-         (help-xref-button 1 'help-function-def function file-name)))))
+         (help-xref-button 1 'help-function-def function file-name))))
+     ;; If it's a subr, try to make a link to the C source.
+     ((and (subrp def) (symbolp function)
+          (file-exists-p (expand-file-name "src/TAGS" source-directory)))
+      (let ((src-tags-file (expand-file-name "src/TAGS" source-directory))
+           (tags-file-name (if (boundp 'tags-file-name) tags-file-name)))
+       (unless (equal tags-file-name src-tags-file)
+         (setq tags-file-name nil)
+         (visit-tags-table src-tags-file))
+       (let ((buf (condition-case nil
+                      (save-excursion
+                        (visit-tags-table-buffer)
+                        (find-tag-in-order
+                         (concat "\"" (symbol-name function) "\"")
+                         find-tag-search-function find-tag-tag-order
+                         find-tag-next-line-after-failure-p
+                         "containing" t))
+                    (error nil))))
+         (when buf
+           (let ((pos (with-current-buffer buf (point))))
+             (princ " in `")
+             (princ (with-current-buffer buf (file-name-nondirectory
+                                              buffer-file-name)))
+             (princ "'")
+             (with-current-buffer standard-output
+               (save-excursion
+                 (re-search-backward "`\\([^`']+\\)'" nil t)
+                 (help-xref-button 1 'help-function-def pos buf)))))))))
     (princ ".")
     (terpri)
     (when (commandp function)
 





reply via email to

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