Use Emacs to navigate through FreeEMS source code

If you have a technical writeup you would like to share, feel free to post it in the articles submission area within.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Use Emacs to navigate through FreeEMS source code

Post by HotCat »

Emacs is my favorite editor, I started to use it since 2003 after graduating from high school, I can't image working on Unix-like environment without it, just like driving a car without steering wheel. Emacs is so Powerful, so flexible and so complex, I can't thoroughly explain how to use it. Instead I only focus on how to navigate through FreeEMS source code

1.First download GNU gtags package
1.png
2.Use Emacs compile mode to configure, compile and install package
2.png
3.Locate gtags elisp extension file and open it
3.png
Last edited by HotCat on Wed Jan 18, 2012 6:39 am, edited 1 time in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

4.Follow the comments to configure your emacs
4.png
5.Navigate to FreeEMS source directory and run shell command 'gtags' from Emacs
5.png
6.Three file should be generated
6.png
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

7.Explore what gtags can do with our source code, use 'gtags-parse-file' command to list C functions in a C source file and locate the function body
7.png
Press 'enter' key to locate the function body
8.png
here it is
9.png
Last edited by HotCat on Wed Jan 18, 2012 6:23 am, edited 3 times in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

8.Find the macro definition of 'cliConfiguredOffset' using 'gtags-find-tag' command

Place cursor around the 'cliConfiguredOffset' variable and issue 'gtags-find-tag' command
10.png
Press 'enter' key to locate whatever definition you prefer to see
11.png
See how it was defined for Hyundai
12.png
Last edited by HotCat on Wed Jan 18, 2012 6:36 am, edited 5 times in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

9.Find the definition of 'calculateFuelAndIgnition' using 'gtags-find-tag' command

Place cursor around the 'calculateFuelAndIgnition' function and issue 'gtags-find-tag' command
13.png
here it is
14.png
Last edited by HotCat on Wed Jan 18, 2012 6:31 am, edited 1 time in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

10.Find how the function was referenced using 'gtags-find-rtag' command

Place cursor around the 'generateDerivedVars' function and issue 'gtags-find-rtag' command
15.png
There maybe a few candidates, press 'enter' key to choose which one you love it
16.png
Here it is
17.png
Last edited by HotCat on Wed Jan 18, 2012 6:35 am, edited 4 times in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

11.Sometimes you have to use 'gtags-find-symbol' command to locate some macro definition

When 'gtags-find-tag' command does not work, try this one
18.png
you must choose
20.png
Here it is
21.png
Last edited by HotCat on Wed Jan 18, 2012 6:58 am, edited 2 times in total.
User avatar
HotCat
LQFP112 - Up with the play
Posts: 110
Joined: Wed Apr 13, 2011 2:35 am

Re: Use Emacs to navigate through FreeEMS source code

Post by HotCat »

End of this topic, thanks for watching :lol:
johntramp
LQFP112 - Up with the play
Posts: 119
Joined: Sat Apr 24, 2010 1:42 am
Location: New Zealand

Re: Use Emacs to navigate through FreeEMS source code

Post by johntramp »

Image
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Use Emacs to navigate through FreeEMS source code

Post by Fred »

HotCat, cool article, this is the most inspired I've EVER been to use emacs! (More than when my best friend tried to convince me) Still not enough to actually do it, though :-)

If you want to edit it freely in future I can leave it here, or I can promote it to article status in the article section. If I do that, though, you have to ask me to get it edited.

LOL @ johntramp :-)

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply