Gedit Symbol Browser Plugin
November 14, 2007
I have written a symbol browser (function browser, class browser, etc.) plugin for Gedit, the default GNOME text editor. The plugin is based on Exuberant Ctags (ctags.sourceforge.net) which must be installed to use the plugin.
Features
View Screen Shots- Supports 34 programming languages (based on ctags)
- Symbols displayed in a tree grouped by symbol type
- Icons for symbols can be added for any symbol type ctags can parse
- Works with local and remote files (SSH, FTP, etc.)
- View symbols from active tab or from all opened documents
- Optionally show line number, programming language, and source file in the tree
- Double-click a symbol to jump to it in the source code
Installation
The plugin is written in C and thus needs to be compiled with the Gedit sources for your distribution if a binary package isn't available. You can check which binary packages are available on the Gedit Symbol Browser Plugin SourceForge project page. Binary Installationcp gedit-symbol-browser-plugin*.tar.gz ~/.gnome2/gedit/ tar -xzf gedit-symbol-browser-plugin*.tar.gzSource Installation If a binary package isn't available, you have to compile the plugin yourself. If you do so, please email the plugin files to me at email (at) micahcarrick.com so that I can provide a binary package. To compile the plugin, you must do so within the gedit source tree. Then, you can either install it with that build of gedit or copy the files yourself without compiling or installing gedit. Download and extract the gedit sources to a folder. Download Gedit Symbol Browser Plugin sources and extract to the gedit sources plugins folder (ex: gedit-2.20.3/plugins/). Edit configure.ac, adding 2 lines to AC_CONFIG_FILES
plugins/symbolbrowser/Makefile plugins/symbolbrowser/symbols/MakefileEdit plugins/Makefile.am, adding to 'symbolbrowser' to DIST_SUBDIRS and SUBDIRS. Run autoconf and automake, and ./configure in the gedit source dir and then make in the symbolbrowser plugin dir:
autoconf automake ./configure cd plugins/symbolbrowser makeNow if you were to run 'make install' here, it might not install the plugin to the right location. This is because many distributions, by default, install binary (rpm's, dep's, etc.) into a different location that files built from source (/usr/ vs. /usr/local/). So, the easiest way to install the plugin is to simply copy plugin files to your home dir:
cp symbolbrowser.gedit-plugin .libs/libsymbolbrowser.so ~/.gnome2/gedit/plugins/ cp -r symbols ~/.gnome2/gedit/If you want to install it for all users using 'make install', you'll have to pass the target during the ./configure step. You can find out where the other gedit plugins are already installed by doing:
updatedb locate gedit-2/pluginsAnd look for them in something like /usr/lib. Then, you can rerun the configure as shown above passing in the lib dir:
./configure --libdir=/usr/libAssuming you're okay with the simpler method (installing the plugin in your home dir), the entire process might look something like this:
# DOWNLOAD AND EXTRACT SOURCES cd ~ wget ftp://ftp.acc.umu.se/pub/GNOME/sources/gedit/2.20/gedit-2.20.3.tar.gz tar -xzf gedit-2.20.3.tar.gz cd gedit-2.20.3 cd plugins wget http://superb-west.dl.sourceforge.net/sourceforge/symbol-browser/gedit-symbol-browser-plugin-0.1.tar.gz tar -xzf gedit-symbol-browser-plugin-0.1.tar.gz # EDIT MAKE AND CONFIGURE FILES sed -i 's/SUBDIRS =/SUBDIRS = \t\\\n\tsymbolbrowser\t/g' Makefile.am sed -i 's/DIST_SUBDIRS =/DIST_SUBDIRS =\t\\\n\tsymbolbrowser\t/g' Makefile.am cd .. sed -i 's/AC_CONFIG_FILES(\[/AC_CONFIG_FILES(\[\nplugins\/symbolbrowser\/Makefile/g' configure.ac # BUILD THE PLUGIN autoconf automake ./configure cd plugins/symbolbrowser make # COPY TO HOME FOLDER # Note: if you ran ./configure --libdir=/usr/lib then make install may work cp symbolbrowser.gedit-plugin .libs/libsymbolbrowser.so ~/.gnome2/gedit/plugins/ cp -r symbols ~/.gnome2/gedit/
Adding Symbols
If ctags finds a type of symbol, then Gedit Symbol Browser Plugin adds it to the tree view. If it doesn't find the icon for that symbol you can add it yourself if you wish (send them to me too!). All symbol icons are simply named "symbol-<type>.png" and live in the '~./gnome2/gedit/symbols' directory where <type> is the type as determined by ctags. For example, ctags finds symbols of type 'function' and therefore, there is a png file called 'symbol-function.png'.Download
Download From SourceForge.net
User Contributions
- Build Instructions for CBLFS: Gedit - CBLFS
- Debian i386 Binary: gedit-symbol-browser-plugin-bin-debian-i386-0.1.tar.gz
Categories:
GTK+ Programming, Linux
Copyright © 2004 - 2010 Micah Carrick. All Rights Reserved.
86 Comments about "Gedit Symbol Browser Plugin"
RSS Feed
Symbol Browser in gedit it automatically gets grayed out...
Is there a way to fix this? I can't use this plugin because of this stupid bug. Haha :(
<code>
sudo apt-get install exuberant-ctags libgconf2-dev libgtksourceviewmm-2.0-dev intltool autoconf automake
</code>
Then followed the build instructions here :)
You can use the binary package for Ubuntu (which is available on sourceforge.net). It works for me on OpenSUSE 11.0, no need to compile from source (make sure you use the right architecture, 32- or 64-bit).
Other thing to do is to install ctags which is done easily through OpenSUSE Install Software package manager.
http://downloads.sourceforge.net/symbol-browser/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz?modtime=1195036992&big_mirror=0
Unpack this in ~/.gnome2/gedit
But when I try to enable Symbol Browser in gedit it automatically gets grayed out...
FYI, If you are installing it on freshly installed Ubuntu, it may not work because of missing 'libgnomeprintui'. Thanks to VR for posting this tip in his blog - http://oracology.net/2010/01/gedits-symbol-browser-caveat/
Run this to install both the dependencies for this plugin:
sudo apt-get install exuberant-ctags libgnomeprintui2.2-0
-Vik
Thank you so much for the 9.10 info!
I am having trouble in using this extension on 64 bit Ubuntu 9.10.
Installed the 'gedit-symbol-browser-plugin-bin-ubuntu-AMD64-0.1.tar.gz' binary from SourceForge. The extension shows up in the gEdit->Prefrences->plugins. But when I click on the check box, it just gets grayed out.
Has anyone else seen this problem?
Thanks.
and where to get the ftp link.It could be solved but the other issue is that my autoconf version is 2.64 and your plugin needs 2.61. how can this be fixed
Thanks man
needed to install a package:
sudo apt-get install sudo apt-get install libgnomeprintui2.2-0
$ gedit ../Nate\ Robbin\'s\ Tutorials/texture.c
** (gedit:15572): CRITICAL **: Could not execute ctags: Text ended before matching quote was found for '. (The text was 'ctags -n --fields=-k-f-s-t+K+l+n -f - /home/kip/Projects/Learn/OpenGL/Nate Robbin's Tutorials/texture.c')
Segmentation fault
In my .c and .cpp files the Symbol Browser seems to only show external variabes. It does not seem to show local variables defined inside functions. Is this normal?
Regards,
Bill
OPEN SOURCE ALWAYS WIN ;)
for all guys who couldn't get this plugin to work
be sure that you have this package "exuberant-ctags"
for debian & *ubuntu:
sudo apt-get install exuberant-ctags
Good luck
I used the previous entry (Jesus, who installed it via Synaptic - ctags) to install the plugin.
Works great for me :-)
I've modified the
static gchar * exec_ctags (gchar *filename)
function in your code, so that it detects the "php.inc" extension and forces the ctags binary to use the PHP language for these files.
While it works perfectly for my case, this is probably not the best way to do it ;-) Is there a better way to add additional file extensions?
Disregard my previous comment. Installed ctags from synaptic and now runs flawesly.
Me too, but I'm using i386.
Attached a screenshot:
http://img13.imageshack.us/img13/9624/symbolbrowser.png
Really nice plugin! I liked a lot.... It is very usefull...
Just to help you debuging it, I will report a bug, ok:
-Open a .c file in Gedit from a location with spaces on it, for example: "~/code/my test code"
Actual result: Symbol Browser plugin can't work with paths with spaces...
I don't know if you already know about this bug, if so, sorry :)
Congratulations again for the nice plugin!!
Best Regards,
Augusto
- Downloaded the amd64-bins.
- Activated the plugin.
- The "Symbol Browser" field is empty.
Yes, I do actually run 64bit.
The symbol browser plugin's icon shows up though, but there are no listings.
Also much thanks to the User contributed bins.
More tips here: http://mavimo.org/drupal/autocompletamento_drupal_gedit
Sya!
When I extract the binary to /usr/lib/gedit-2/plugins as suggested in one of the posts above (since ./gnome/gedit doesn't exist), I do see the plugin "symbol browser" in the plugin list under preferences. However, it doesn't get active (it remains like an unclickable button). Does anybody have any idea? I am using Ubuntu 8.10.
Thanks!
Paulo
As I'm somewhat of a newbie to the install from source thing, getting this to work wasn't smooth sailing. A few pointers that might help others like me:
- although you may have fixed the dependencies before compiling gedit, you might need to fix up the paths right. Compiling Gedit I got missing files for gtksourceview although I had just installed it. Symlinking /usr/local/include/gtksourceview-2.0 to /usr/include/gtksourceview-2.0/ did the trick
- I also had the empty sidebar/nothing displayed trick after opening gedit and getting symbol browser enabled. Fixing the permissions for the symbolbrowser plugin files fixed that.
Thanks for the great work on this, much appreciated :)
Regards
Fake
Crash on opening files containing an apostrophe in the name
Steps to reproduce:
1. Create an empty text file named:
Monter l'iso
2. Click on the file and choose "Open with gedit".
If gedit is already open, it automatically closes, otherwise it doesn't open.
Thanks again.
First, thanks a lot for the useful Gedit Symbol Browser Plugin.
I found a bug: if the path to the file (including the file name) contains a space, Symbol Browser Plugin doesn't work and stays empty. Here's the way to always reproduce this bug:
echo "int main (void) {return 0;}" > "example 1.c"
Open "example 1.c" with gedit and see the empty Symbol Browser panel. The main function isn't recognized. However, if we remove the space in the file name:
echo "int main (void) {return 0;}" > example1.c
and we open example1.c with gedit, the Symbol Browser Plugin recognizes this time the main function.
Thanks.
** (gedit:29810): WARNING **: /opt/gtksourceview/lib/libgtksourceview-2.0.so.0: undefined symbol: gtk_text_buffer_add_mark
** (gedit:29810): WARNING **: Could not load plugin file at /home/gh258/.gnome2/gedit/plugins/libsymbolbrowser.so
** (gedit:29810): WARNING **: Error, impossible to activate plugin 'Symbol Browser'
I have recompiled gtksourceview and reinstalled it with some different options, but nothing works. Do you know what is wrong? Thanks in advance
Please I need ur help in writing a gedit plugin in C in the form of a tutorial. Or is there any site available for learning how to write a gedit plugin in C [or Python]. I'd really appreciate a reply from you. I'm actually planning to write an auto-completion or "intellisense" gedit plugin. Thanks.
Thought I'd share the following. In a .cpp file, I have the habit of putting a //--------------- line between function implementations to keep the code more orderly. As it turns out, the symbol table only shows the symbol for the first function prior to that comment line. If I remove all the // comments, it will show all symbols. If I change the comment lines to, say: /*------*/, it shows all symbols too.
I haven't looked too deeply into this, and I'm far from an expert here, but from what I've read so far I gather the files are passed to ctags, and I'm guessing the problem lies there /shrug
For me, I think I'll just change my comment lines. Kinda sucks, but it's something I'll do only once, after which it'll be smooth sailing.
Find this kinda nice when used together with a project manager plugin, makes it feel like an IDE.
I did not know that. One of these days I'll get around to dinking with that.
I use ctags for parsing too, its output carries the information needed for class grouping. However, fully parsing the exuberant ctags output format in itself isn't so easy; it might be a much better solution to write specialized parsers for the most used languages.
In the current state the plugin is sufficient for me though.
Thanks heaps for this! A feature request (unless it's already implemented and I can't find it):
It would be good to be able to point to the TAGS file so if I have a tree of code in a heap of different directories, I can just run "etags -R" in the base directory, and then point the plugin to that TAGS file and get the listing for functions that may be in a header in an include directory, that is below the current source directory.
Nick
Yeah, I'll keep that in mind for future versions. I don't prefer working like that but I know some people do. I could have it be one of the preferences. Not too tricky.
I agree, grouping members into the classes would be ideal. Currently, I'm not actually parsing the code (as I don't know all of those 45 languages) as I'm relying on ctags to do that part. It's also missing proper HTML and CSS parsing. However, ctags is under constant development and I know some CVS versions were allowing for some of these things. Perhaps it is much simpler to use ctags with some hacks.
As for python, I originally planned on using Python but went with C since there are some times in my work where I might have as many as 25 open files, some of which are close to 10000 lines of code. I don't want any delay while that treeview loads and didn't want to mess with asychronous code at this point. That was my though process anyway....
Is there a chance, that you make a popup-window available
that could be used instead of the side pane. This would make
the workflow even better in my opinion. It could work
like the switcher or the snap-open plugin.
Best,
Marco
That's my first shot at a Python implementation. Several things are different:
- It groups by class/struct/etc instead of by tag type, which makes a lot more sense with OO code
- It strictly only works on a single file per tab
- It is capable of tracking line changes of tags
- No complicated compiling within the GEdit source tree needed, just extract the files to ~/.gnome2/gedit :)
I used the icons provided by your plugin. I hope that's okay.
Thanks for the plugin. There was a problem with the installation instructions for the binary package. ~/.gnome/gedit does not exist and I could not create the directory because a file called gedit did exist.
I did a system wide install by extracting the tar.gz to /usr/lib/gedit-2/plugins.
This put a plugins directory inside the already existing plugins directory so I copied the contents of the symbol-browser plugins directory into the main plugins directory and left the new symbols directory alone.
It works now.
Thanks
regards peter
sorry for disturbance but after ctags, the plugin worked :).
sudo apt-get install exuberant-ctags
Thank you very much for this nice idea, i tried the binary package but it does not work with me i hope if you make a debian package, i'm using Hardy heron.
I can find the plugin in the list of plugins available, i enabled it but when i open any file i did not get any symbols displayed :(
Best Regards
I'm trying to install gedit plugins but everything in the ~/.gnome2/gedit/plugins are ignored. All tutorials explain this installation directory but it doesn't work here on my out-of-the-box Red Hat installation. Anyone knows why?
Here we work with a particular scripting language called "chilli" for which it exists an unique parser, for UltraEdit32. But, since I don't use Windows, I was just looking for a tool/plugin that could permit me to add the support for this language to my gnome editors. After spending a week on Anjuta, I came across your gedit plugin, and it was immediately love :)
And now I have finally a function listing for the chilli language. Thanks again.
PS: Maybe should I send you the regexps?
i follow your istruction,everything go well(in compilation of plugin).but when i use the plugin ,for example with C file,in the your plugin sidebar nothing ! a clear windows!
I use gedit 2.22.0 in Arch Linux distribution. i hope you know the problem!
thanks for this well written article. I have customized my gedit in fedora 8. now it is so cool to work with. i downloaded binary files of symbol browser plugin and copied meant for ubuntu. it is working so smoothly. So why don't call it binary package for fedora also.
Just a note. I tried to install it on a PC running Ubuntu 7.04 and the plugin was not able to find the 2.0 version of the libgtksourceview library. Since it seems that version 2.0 is not present in the Ubuntu Feisty repository, I had to fix it by creating a new symbolic link (named 2.0) to the actually present 1.0 version and it seems to correctly work now.
Was it a known issue?
It needs to be compiled along with the Gedit sources, using Gedit's configure.ac. The instructions above explain how to edit gedit's configure scripts to make sure the plugin is compiled.
"I also noticed that you don't have any files in CVS at SF. Wouldn't it make sense to have the files in CVS or Subversion, rather than just posting tarballs?"
I don't expect it to be updated frequently enough nor be a popular enough project for that. But, perhaps down the road.
I also noticed that you don't have any files in CVS at SF. Wouldn't it make sense to have the files in CVS or Subversion, rather than just posting tarballs?
I have compiling on i386 Debian : ftp://ftp-developpez.com/nicolasj/temp/gedit-symbol-browser-plugin-bin-debian-i386-0.1.tar.gz
Ready to unpack in ~/.gnome2/gedit/ ;)
It passes the file to ctags, so it depends on how ctags determines the type. Curious, what does gedit report as the mime type? Perhaps I could use gedit's mime-type determination and force the type when calling ctags.
But the Symbol Browser panel it's empty.
I installed exuberant-ctags, but is still empty.
Then I renamed example.module to example.php and the plugin works :)
Can't symbol Browser detect the file type automatically?
It is based on ctags. So if ctags can find your class methods as methods, then it will show up in the plugin. It just parses the output of ctags and groups them in the treeview by type.
So you may want to read up on ctags at ctags.sourceforge.net for the language you are talking about.
http://downloads.sourceforge.net/symbol-browser/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz?modtime=1195036992&big_mirror=0
Unpack this in ~/.gnome2/gedit
Start gedit, edit > preferences > plugins and enable the symbol browser. It's that easy!
Sounds a bit like you didn't run autoconf, automake, and ./configure in the top-level gedit source directory. I know this can be a bit confusing for a beginner.
I think I have a Fedora installation on another machine, and I'll see if I can build a fedora binary (which you would just have to copy to the right folder instead of compiling).
I get following error when I run make inside directory gedit/plugins/symbolbrowser. Previous installing setps I did as told. I have Fedora Core 7.
*** No rule to make target `am--refresh'. Stop.
P.S. I am quite few experiences with linux yet.
Once ctags is installed, and the plugin is installed, you activate it through:
edit > preferences > plugins
If "Symbol Browser" isn't in the list, then the plugin isn't installed correctly. If it is in the list, make sure it's checked and that ctags is found. Click 'Configure' and the configure dialog should either show the output of 'ctags --version' or say 'NOT INSTALLED'.
Once it's installed and activated, the treeview lives in the left pane which can be seen using 'View' > 'Left Pane'
Thanks for the information! I'll have to modify the file so that it uses a define in the makefile to determine the ctags command it will used. Perhaps erhaps exuberant-ctags will work on all systems. I'll ask around.
Just one thing i noticed when i installed the plugin on my machine:
Gentoo renames the binary from "ctags" to "exuberant-ctags" due to another binary named ctags in the system.
In the ctags-ebuild from gentoo it says "namepace collision with X/Emacs-provided /usr/bin/ctags".
This requires to exchange "ctags" for "exuberant-ctags" twice in the file "gedit-symbol-browser-plugin-defs.h" , followed by a "make" and copying over the files for the plugin to work on this systems.
'sudo apt-get install ctags'
did the trick for me, but am still unable to figure out how to get that tree structure in my Gedit :(
Thank so much for this plugin. I like a lot and as you request I've compiled the source and I got the library (ia32). I wanted to mail you with it and my screenshot :) but I can't find your email.
If you are interested I have a tar.gz ready to send. I wrote down my email in the form so I suppose that you can reach me.
Thanks again.
Few notes on the source install instructions:
config.ac should be configure.ac
./configure needed after automake and before cd plugins/symbolbrowser
To get "make install" to put the symbols in the place the plugin is expecting I had to:
sed -i "s:symbolsdir = \$(libdir)/gedit-2/symbols:symbolsdir = \$(datadir)/gedit-2/symbolbrowser/symbols:" symbols/Makefile.am
i played around with it and started compiling ctags myself with css support using this source:
http://cssed.sourceforge.net/ctags/css.c
But the HTML support looks quite bad too :( But I'm not goog in regular expressions for doing something fine, i looked in the html.c of ctags sources and it looks really poor.
That is what i needed to port SweeTS ( typo3.area42.de ) to gEdit/ Linux.
Did you know how to add own formats to Ctags?
BTW I wrote some gEdit plugins too:
http://my.opera.com/area42/blog/gedit-browser-preview-plugin
http://my.opera.com/area42/blog/gedit-language-reference-plugin
Leave a Comment about "Gedit Symbol Browser Plugin"