unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: building directory
Date: Fri, 04 Apr 2003 09:51:06 -0500	[thread overview]
Message-ID: <200304041451.h34Ep6QO007292@rum.cs.yale.edu> (raw)
In-Reply-To: 20030404.171320.107253085.jet@gyve.org

> 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)

  parent reply	other threads:[~2003-04-04 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04  8:13 building directory Masatake YAMATO
2003-04-04 10:27 ` Masatake YAMATO
2003-04-04 12:10   ` Thien-Thi Nguyen
2003-04-04 12:21   ` Jan D.
2003-04-05  8:12   ` Richard Stallman
2003-04-04 14:51 ` Stefan Monnier [this message]
2003-04-05  8:12   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200304041451.h34Ep6QO007292@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).