all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* opening correct source file on compile error
@ 2006-10-18 16:08 kl.vanw
  2006-10-19 16:14 ` Kevin Rodgers
       [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: kl.vanw @ 2006-10-18 16:08 UTC (permalink / raw)


Here's my situation. My header files (C++) are located in a dir named
src/lib. These are the files I edit and are CVS managed. When I run
'make', make copies the headers into include/, which my other source
files include. Then if there was an error in one of the headers, and I
use 'next-error' in the compilation buffer to open the header, emacs
opens the file in the include/ directory, but I really need it to open
the header in src/lib. Can I some how help emacs find the right file?

Unfortunately, I don't have the option of changing the way our makefile
works or the #include statements.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-18 16:08 opening correct source file on compile error kl.vanw
@ 2006-10-19 16:14 ` Kevin Rodgers
       [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2006-10-19 16:14 UTC (permalink / raw)


kl.vanw@gmail.com wrote:
> Here's my situation. My header files (C++) are located in a dir named
> src/lib. These are the files I edit and are CVS managed. When I run
> 'make', make copies the headers into include/, which my other source
> files include. Then if there was an error in one of the headers, and I
> use 'next-error' in the compilation buffer to open the header, emacs
> opens the file in the include/ directory, but I really need it to open
> the header in src/lib. Can I some how help emacs find the right file?
> 
> Unfortunately, I don't have the option of changing the way our makefile
> works or the #include statements.

Try this:

(add-hook 'find-file-hook
	  (lambda ()
	    (let* ((file (file-name-nondirectory buffer-file-name))
		   (directory (file-name-directory buffer-file-name))
		   (alternate-file (expand-file-name file "../src/lib")))
	      (when (and (equal (file-name-nondirectory
				 (directory-file-name directory))
				"include")
			 (file-exists-p alternate-file))
		(find-alternate-file alternate-file)))))

-- 
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
       [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
@ 2006-10-20 14:00   ` kl.vanw
  2006-10-23 16:15     ` Kevin Rodgers
       [not found]     ` <mailman.162.1161620177.27805.help-gnu-emacs@gnu.org>
  2006-10-23 17:29   ` Ushnish Basu
  1 sibling, 2 replies; 13+ messages in thread
From: kl.vanw @ 2006-10-20 14:00 UTC (permalink / raw)



Kevin Rodgers wrote:
> kl.vanw@gmail.com wrote:
> > Here's my situation. My header files (C++) are located in a dir named
> > src/lib. These are the files I edit and are CVS managed. When I run
> > 'make', make copies the headers into include/, which my other source
> > files include. Then if there was an error in one of the headers, and I
> > use 'next-error' in the compilation buffer to open the header, emacs
> > opens the file in the include/ directory, but I really need it to open
> > the header in src/lib. Can I some how help emacs find the right file?
> >
> > Unfortunately, I don't have the option of changing the way our makefile
> > works or the #include statements.
>
> Try this:
>
> (add-hook 'find-file-hook
> 	  (lambda ()
> 	    (let* ((file (file-name-nondirectory buffer-file-name))
> 		   (directory (file-name-directory buffer-file-name))
> 		   (alternate-file (expand-file-name file "../src/lib")))
> 	      (when (and (equal (file-name-nondirectory
> 				 (directory-file-name directory))
> 				"include")
> 			 (file-exists-p alternate-file))
> 		(find-alternate-file alternate-file)))))
>
> --
> Kevin

I tried that, but it didn't work. I also tried specifing the full paths
in the above, but it didn't work either. Did you verify that it works
for you?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-20 14:00   ` kl.vanw
@ 2006-10-23 16:15     ` Kevin Rodgers
       [not found]     ` <mailman.162.1161620177.27805.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2006-10-23 16:15 UTC (permalink / raw)


kl.vanw@gmail.com wrote:
> Kevin Rodgers wrote:
>> kl.vanw@gmail.com wrote:
>>> Here's my situation. My header files (C++) are located in a dir named
>>> src/lib. These are the files I edit and are CVS managed. When I run
>>> 'make', make copies the headers into include/, which my other source
>>> files include. Then if there was an error in one of the headers, and I
>>> use 'next-error' in the compilation buffer to open the header, emacs
>>> opens the file in the include/ directory, but I really need it to open
>>> the header in src/lib. Can I some how help emacs find the right file?
>>>
>>> Unfortunately, I don't have the option of changing the way our makefile
>>> works or the #include statements.
>> Try this:
>>
>> (add-hook 'find-file-hook
>> 	  (lambda ()
>> 	    (let* ((file (file-name-nondirectory buffer-file-name))
>> 		   (directory (file-name-directory buffer-file-name))
>> 		   (alternate-file (expand-file-name file "../src/lib")))
>> 	      (when (and (equal (file-name-nondirectory
>> 				 (directory-file-name directory))
>> 				"include")
>> 			 (file-exists-p alternate-file))
>> 		(find-alternate-file alternate-file)))))
>>
>> --
>> Kevin
> 
> I tried that, but it didn't work. I also tried specifing the full paths
> in the above, but it didn't work either. Did you verify that it works
> for you?

Ah, it works in Emacs 22.  To make it work in older versions, use
find-file-hooks (plural) instead of find-file-hook.

-- 
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
       [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
  2006-10-20 14:00   ` kl.vanw
@ 2006-10-23 17:29   ` Ushnish Basu
  2006-10-23 20:07     ` Kevin Rodgers
       [not found]     ` <mailman.175.1161634161.27805.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 13+ messages in thread
From: Ushnish Basu @ 2006-10-23 17:29 UTC (permalink / raw)


Kevin Rodgers <ihs_4664@yahoo.com> writes:

> kl.vanw@gmail.com wrote:
>> Here's my situation. My header files (C++) are located in a dir named
>> src/lib. These are the files I edit and are CVS managed. When I run
>> 'make', make copies the headers into include/, which my other source
>> files include. Then if there was an error in one of the headers, and I
>> use 'next-error' in the compilation buffer to open the header, emacs
>> opens the file in the include/ directory, but I really need it to open
>> the header in src/lib. Can I some how help emacs find the right file?
>> Unfortunately, I don't have the option of changing the way our makefile
>> works or the #include statements.
>
> Try this:
>
> (add-hook 'find-file-hook
> 	  (lambda ()
> 	    (let* ((file (file-name-nondirectory buffer-file-name))
> 		   (directory (file-name-directory buffer-file-name))
> 		   (alternate-file (expand-file-name file "../src/lib")))
> 	      (when (and (equal (file-name-nondirectory
> 				 (directory-file-name directory))
> 				"include")
> 			 (file-exists-p alternate-file))
> 		(find-alternate-file alternate-file)))))
>
> -- 
> Kevin
>

I have a similar problem, except that my CVS has *.F files (in say ../src) for
the fortran preprocessor, and make gives me corresponding *.f files in the
current directory. How would one modify the above example for this case?
Sorry, I don't understand (e)lisp well enough to do it myself, but I am
planning to learn. 

-- 
Ushnish Basu          ubasu@ce.berkeley.edu          
+1 510 644-1906       www.ce.berkeley.edu/~ubasu

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-23 17:29   ` Ushnish Basu
@ 2006-10-23 20:07     ` Kevin Rodgers
       [not found]     ` <mailman.175.1161634161.27805.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2006-10-23 20:07 UTC (permalink / raw)


Ushnish Basu wrote:
> Kevin Rodgers <ihs_4664@yahoo.com> writes:
> 
>> kl.vanw@gmail.com wrote:
>>> Here's my situation. My header files (C++) are located in a dir named
>>> src/lib. These are the files I edit and are CVS managed. When I run
>>> 'make', make copies the headers into include/, which my other source
>>> files include. Then if there was an error in one of the headers, and I
>>> use 'next-error' in the compilation buffer to open the header, emacs
>>> opens the file in the include/ directory, but I really need it to open
>>> the header in src/lib. Can I some how help emacs find the right file?
>>> Unfortunately, I don't have the option of changing the way our makefile
>>> works or the #include statements.
>> Try this:
>>
>> (add-hook 'find-file-hook
>> 	  (lambda ()
>> 	    (let* ((file (file-name-nondirectory buffer-file-name))
>> 		   (directory (file-name-directory buffer-file-name))
>> 		   (alternate-file (expand-file-name file "../src/lib")))
>> 	      (when (and (equal (file-name-nondirectory
>> 				 (directory-file-name directory))
>> 				"include")
>> 			 (file-exists-p alternate-file))
>> 		(find-alternate-file alternate-file)))))
>>
>> -- 
>> Kevin
>>
> 
> I have a similar problem, except that my CVS has *.F files (in say ../src) for
> the fortran preprocessor, and make gives me corresponding *.f files in the
> current directory. How would one modify the above example for this case?

(add-hook 'find-file-hook
  	  (lambda ()
  	    (let* ((file (file-name-nondirectory buffer-file-name))
  		   alternate-file)
  	      (when (and (equal (file-name-extension file) "f")
			 (file-exists-p
			  (setq alternate-file
				(expand-file-name (concat (file-name-sans-extension file)
							  ".F")
						  "../src"))))
  		(find-alternate-file alternate-file)))))

> Sorry, I don't understand (e)lisp well enough to do it myself, but I am
> planning to learn. 

You will be greatly rewarded for your efforts!

-- 
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
       [not found]     ` <mailman.175.1161634161.27805.help-gnu-emacs@gnu.org>
@ 2006-10-23 22:23       ` Ushnish Basu
  0 siblings, 0 replies; 13+ messages in thread
From: Ushnish Basu @ 2006-10-23 22:23 UTC (permalink / raw)


Kevin Rodgers <ihs_4664@yahoo.com> writes:

> Ushnish Basu wrote:
>> I have a similar problem, except that my CVS has *.F files (in say ../src)
>> for
>> the fortran preprocessor, and make gives me corresponding *.f files in the
>> current directory. How would one modify the above example for this case?
>
> (add-hook 'find-file-hook
>   	  (lambda ()
>   	    (let* ((file (file-name-nondirectory buffer-file-name))
>   		   alternate-file)
>   	      (when (and (equal (file-name-extension file) "f")
> 			 (file-exists-p
> 			  (setq alternate-file
> 				(expand-file-name (concat (file-name-sans-extension file)
> 							  ".F")
> 						  "../src"))))
>   		(find-alternate-file alternate-file)))))
>

Great, thanks a bunch, I will try it out soon.

>> Sorry, I don't understand (e)lisp well enough to do it myself, but I am
>> planning to learn.
>
> You will be greatly rewarded for your efforts!
>

That's what I have heard. I just got Paul Graham's ANSI Common Lisp, so I will
go to elisp once I get familiar with lisp itself.

Ushnish

--
Ushnish Basu          ubasu@ce.berkeley.edu          
+1 510 644-1906       www.ce.berkeley.edu/~ubasu

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
       [not found]     ` <mailman.162.1161620177.27805.help-gnu-emacs@gnu.org>
@ 2006-10-24 12:04       ` kl.vanw
  2006-10-24 12:46         ` Burton Samograd
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: kl.vanw @ 2006-10-24 12:04 UTC (permalink / raw)



Kevin Rodgers wrote:
> kl.vanw@gmail.com wrote:
> > Kevin Rodgers wrote:
> >> kl.vanw@gmail.com wrote:
> >>> Here's my situation. My header files (C++) are located in a dir named
> >>> src/lib. These are the files I edit and are CVS managed. When I run
> >>> 'make', make copies the headers into include/, which my other source
> >>> files include. Then if there was an error in one of the headers, and I
> >>> use 'next-error' in the compilation buffer to open the header, emacs
> >>> opens the file in the include/ directory, but I really need it to open
> >>> the header in src/lib. Can I some how help emacs find the right file?
> >>>
> >>> Unfortunately, I don't have the option of changing the way our makefile
> >>> works or the #include statements.
> >> Try this:
> >>
> >> (add-hook 'find-file-hook
> >> 	  (lambda ()
> >> 	    (let* ((file (file-name-nondirectory buffer-file-name))
> >> 		   (directory (file-name-directory buffer-file-name))
> >> 		   (alternate-file (expand-file-name file "../src/lib")))
> >> 	      (when (and (equal (file-name-nondirectory
> >> 				 (directory-file-name directory))
> >> 				"include")
> >> 			 (file-exists-p alternate-file))
> >> 		(find-alternate-file alternate-file)))))
> >>
> >> --
> >> Kevin
> >
> > I tried that, but it didn't work. I also tried specifing the full paths
> > in the above, but it didn't work either. Did you verify that it works
> > for you?
>
> 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/.

--
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-24 12:04       ` kl.vanw
@ 2006-10-24 12:46         ` Burton Samograd
  2006-10-24 14:10           ` kl.vanw
  2006-10-24 21:53         ` Kevin Rodgers
       [not found]         ` <mailman.216.1161726966.27805.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 13+ messages in thread
From: Burton Samograd @ 2006-10-24 12:46 UTC (permalink / raw)


kl.vanw@gmail.com writes:

> Kevin Rodgers wrote:
>> kl.vanw@gmail.com wrote:
>> > Kevin Rodgers wrote:
>> >> kl.vanw@gmail.com wrote:
>> >>> Here's my situation. My header files (C++) are located in a dir named
>> >>> src/lib. These are the files I edit and are CVS managed. When I run
>> >>> 'make', make copies the headers into include/, which my other source
>> >>> files include. Then if there was an error in one of the headers, and I
>> >>> use 'next-error' in the compilation buffer to open the header, emacs
>> >>> opens the file in the include/ directory, but I really need it to open
>> >>> the header in src/lib. Can I some how help emacs find the right
>> >>> file?

Might variable this help?  I was having a similar problem and this
fixed it right up.

compilation-search-path Variable:

*List of directories to search for  source files named in error
messages.

-- 
burton samograd                                             kruhft .at. gmail
    generative a/v artwork : http://kruhft.boldlygoingnowhere.org

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-24 12:46         ` Burton Samograd
@ 2006-10-24 14:10           ` kl.vanw
  2006-10-24 22:31             ` Burton Samograd
  0 siblings, 1 reply; 13+ messages in thread
From: kl.vanw @ 2006-10-24 14:10 UTC (permalink / raw)



Burton Samograd wrote:
> kl.vanw@gmail.com writes:
>
> > Kevin Rodgers wrote:
> >> kl.vanw@gmail.com wrote:
> >> > Kevin Rodgers wrote:
> >> >> kl.vanw@gmail.com wrote:
> >> >>> Here's my situation. My header files (C++) are located in a dir named
> >> >>> src/lib. These are the files I edit and are CVS managed. When I run
> >> >>> 'make', make copies the headers into include/, which my other source
> >> >>> files include. Then if there was an error in one of the headers, and I
> >> >>> use 'next-error' in the compilation buffer to open the header, emacs
> >> >>> opens the file in the include/ directory, but I really need it to open
> >> >>> the header in src/lib. Can I some how help emacs find the right
> >> >>> file?
>
> Might variable this help?  I was having a similar problem and this
> fixed it right up.
>
> compilation-search-path Variable:
>
> *List of directories to search for  source files named in error
> messages.
>

That certainly sounds like what I need, but it doesn't work for me. I
think I've spent too much time on the minor annoyance. Thanks for your
help.

--
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-24 12:04       ` kl.vanw
  2006-10-24 12:46         ` Burton Samograd
@ 2006-10-24 21:53         ` Kevin Rodgers
       [not found]         ` <mailman.216.1161726966.27805.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2006-10-24 21:53 UTC (permalink / raw)


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

-- 
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
  2006-10-24 14:10           ` kl.vanw
@ 2006-10-24 22:31             ` Burton Samograd
  0 siblings, 0 replies; 13+ messages in thread
From: Burton Samograd @ 2006-10-24 22:31 UTC (permalink / raw)


kl.vanw@gmail.com writes:

> Burton Samograd wrote:
>> kl.vanw@gmail.com writes:
>>
>> > Kevin Rodgers wrote:
>> >> kl.vanw@gmail.com wrote:
>> >> > Kevin Rodgers wrote:
>> >> >> kl.vanw@gmail.com wrote:
>> >> >>> Here's my situation. My header files (C++) are located in a dir named
>> >> >>> src/lib. These are the files I edit and are CVS managed. When I run
>> >> >>> 'make', make copies the headers into include/, which my other source
>> >> >>> files include. Then if there was an error in one of the headers, and I
>> >> >>> use 'next-error' in the compilation buffer to open the header, emacs
>> >> >>> opens the file in the include/ directory, but I really need it to open
>> >> >>> the header in src/lib. Can I some how help emacs find the right
>> >> >>> file?
>>
>> Might variable this help?  I was having a similar problem and this
>> fixed it right up.
>>
>> compilation-search-path Variable:
>>
>> *List of directories to search for  source files named in error
>> messages.
>>
>
> That certainly sounds like what I need, but it doesn't work for me. I
> think I've spent too much time on the minor annoyance. Thanks for your
> help.

Try this:

(setq compilation-search-path
   '("/path/to/where/you/want/compile/to/load/files"
     "/another/path/to/search"))

-- 
burton samograd                                             kruhft .at. gmail
    generative a/v artwork : http://kruhft.boldlygoingnowhere.org

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: opening correct source file on compile error
       [not found]         ` <mailman.216.1161726966.27805.help-gnu-emacs@gnu.org>
@ 2006-10-25 11:41           ` kl.vanw
  0 siblings, 0 replies; 13+ messages in thread
From: kl.vanw @ 2006-10-25 11:41 UTC (permalink / raw)



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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-10-25 11:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-18 16:08 opening correct source file on compile error kl.vanw
2006-10-19 16:14 ` Kevin Rodgers
     [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
2006-10-20 14:00   ` kl.vanw
2006-10-23 16:15     ` Kevin Rodgers
     [not found]     ` <mailman.162.1161620177.27805.help-gnu-emacs@gnu.org>
2006-10-24 12:04       ` kl.vanw
2006-10-24 12:46         ` Burton Samograd
2006-10-24 14:10           ` kl.vanw
2006-10-24 22:31             ` Burton Samograd
2006-10-24 21:53         ` Kevin Rodgers
     [not found]         ` <mailman.216.1161726966.27805.help-gnu-emacs@gnu.org>
2006-10-25 11:41           ` kl.vanw
2006-10-23 17:29   ` Ushnish Basu
2006-10-23 20:07     ` Kevin Rodgers
     [not found]     ` <mailman.175.1161634161.27805.help-gnu-emacs@gnu.org>
2006-10-23 22:23       ` Ushnish Basu

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.