unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: The source linke in the help buffer
Date: Wed, 24 Sep 2008 23:48:41 +0200	[thread overview]
Message-ID: <48DAB5B9.7090407@gmail.com> (raw)
In-Reply-To: <48DA6534.6000507@gmail.com>

Lennart Borgman (gmail) wrote:
> martin rudalics wrote:
>>> It doesn't of course, sorry for the bad mixing of things here.
>>> (However before your changes the link in the help buffer could lead
>>> either to the installed tree or the checked out tree.)
>> But your function doesn't check these links.  So what can I do to help
>> you?  The function you're using seems to accomplish all you need.
> 
> Sorry for beeing unclear. I was (a bit too implicity) saying that
> instead of the variables you suggested to make the help buffer link go
> to either the install or the source tree it would suffice with a
> function like the one I provided.
> 
> I think it would be good if this function shared room with find-function
> and its relatives inside Emacs.

But I think this version would live a more pleasant and longer life there:

(defun find-emacs-other-file (display-file)
  "Find corresponding file to source or installed elisp file.
If you have checked out and compiled Emacs yourself you may have
Emacs lisp files in two places, the checked out source tree and
the installed Emacs tree.  If buffer contains an Emacs elisp file
in one of these places then find the corresponding elisp file in
the other place. Return the file name of this file.

When DISPLAY-FILE is non-nil display this file in other window
and go to the same line number as in the current buffer."
  (interactive (list t))
  (unless (buffer-file-name)
    (error "This buffer is not visiting a file"))
  (unless source-directory
    (error "Can't find the checked out Emacs sources"))
  (let* ((installed-directory (file-name-as-directory
                               (expand-file-name ".." exec-directory)))
         (relative-installed (file-relative-name
                              (buffer-file-name) installed-directory))
         (relative-source (file-relative-name
                           (buffer-file-name) source-directory))
         (name-nondir (file-name-nondirectory (buffer-file-name)))
         source-file
         installed-file
         other-file
         (line-num (line-number-at-pos)))
    (cond
     ((and relative-installed
           (not (string= name-nondir relative-installed))
           (not (file-name-absolute-p relative-installed))
           (not (string= ".." (substring relative-installed 0 2))))
      (setq source-file (expand-file-name relative-installed
source-directory)))
     ((and relative-source
           (not (string= name-nondir relative-source))
           (not (file-name-absolute-p relative-source))
           (not (string= ".." (substring relative-source 0 2))))
      (setq installed-file (expand-file-name relative-source
installed-directory))))
    (setq other-file (or source-file installed-file))
    (unless other-file
      (error "This file is not in Emacs source or installed lisp tree"))
    (unless (file-exists-p other-file)
      (error "Can't find the corresponding file %s" other-file))
    (when display-file
      (find-file-other-window other-file)
      (goto-line line-num))
    other-file))




  reply	other threads:[~2008-09-24 21:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 10:16 The source linke in the help buffer Lennart Borgman (gmail)
2008-09-24 12:18 ` martin rudalics
2008-09-24 12:53   ` Lennart Borgman
2008-09-24 13:20     ` martin rudalics
2008-09-24 13:51       ` Lennart Borgman
2008-09-24 13:53         ` martin rudalics
2008-09-24 14:05           ` Lennart Borgman
2008-09-24 14:12             ` martin rudalics
2008-09-24 16:05               ` Lennart Borgman (gmail)
2008-09-24 21:48                 ` Lennart Borgman (gmail) [this message]
2008-09-25  9:11                   ` martin rudalics
2008-09-25  9:59                     ` Lennart Borgman (gmail)
2008-09-24 14:31   ` Stefan Monnier
2008-09-24 14:57     ` martin rudalics
2008-09-24 15:42       ` Chong Yidong
2008-09-24 16:15         ` martin rudalics
2008-09-24 16:51           ` Chong Yidong
2008-09-24 16:46       ` Stefan Monnier
2008-09-25  9:11         ` martin rudalics

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=48DAB5B9.7090407@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /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).