help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: opening correct source file on compile error


From: kl . vanw
Subject: Re: opening correct source file on compile error
Date: 25 Oct 2006 04:41:38 -0700
User-agent: G2/1.0

Kevin Rodgers wrote:
> kl.vanw@gmail.com wrote:
> > Kevin Rodgers wrote:
> >> Ah, it works in Emacs 22.  To make it work in older versions, use
> >> find-file-hooks (plural) instead of find-file-hook.
> >
> > Yes, I have Emacs 21.3.1. I couldn't get that to work either. Maybe I'm
> > messing up the paths. To be more explicit, the files I edit are in
> > ~/project/math/src/lib/math/ and gmake puts them in
> > ~/project/math/include/math/.
>
> Ah, you didn't mention that the src/lib and include directories had
> their own subdirectory structure, so I assumed otherwise.
>
> (add-hook 'find-file-hooks
>         (lambda ()
>           (let ((alternate-file
>                  (replace-regexp-in-string "/include/"
>                                            "/src/lib/"
>                                            buffer-file-name
>                                            t ; fixedcase
>                                            t))) ; literal
>             (when (and (not (equal buffer-file-name alternate-file))
>                        (file-exists-p alternate-file))
>               (find-alternate-file alternate-file)))))
> 

That worked. You rock. Thanks.



reply via email to

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