Skip navigation.

Log in | Sign up

Linux for Designers

a blog by Eckhard M. Jäger

gEdit Language Reference plugin

, , , , , , , , , ,

On my way bringing SweeTS - delicious TypoScript development to Linux, i wrote an plugin for opening an external language reference for the language you are editing in gEdit. The additional "gedit-plugins" package must be installed first. The plugin is localized in german and english.

How it works:
* The external language reference can be an PDF, a DocBook XML, a CHM Windows helpfile, a PostScript file or a HTML page
* Copy the files of the gedit_reference_plugin.zip into "~/.gnome2/gedit/plugins"
* Create a folder "help" in "~/.gnome2/gedit/"
* Copy your language references to "~/.gnome2/gedit/help"
* Set the filename of your reference document as the programming language name (you can get the name easily from "View > Highlight Mode"). An example: if you have a CHM documentation "python25.chm" then rename it into "Python.chm"
* Start gEdit and enable the plugin "Language Reference" in the preferences
* After a restart the plugin appears in the help menu
* Assign the shortcut "Alt+F1" to it
* Yelp (Docbook XML), CHMsee-GnoChm-XCHM-KCHMviewer (Windows comiled Help CHM), Firefox (HTML) or Evince (PDF, PS) are required
* Error dialogs based on Zenity

So now you have an easy access to your programming guides and preferences :smile:
If you are using Ubuntu you can grap a up-to-date version of GnoCHM at GetDeb.net.

Download:
http://files.myopera.com/area42/files/gedit_reference_plugin.zip

Other gEdit plugins i wrote:
http://my.opera.com/area42/blog/gedit-template-plugin
http://my.opera.com/area42/blog/gedit-browser-preview-plugin
A lot of other gEdit plugins can be found here.

^BS Contact VRML/X3D on Linux

Comments

Anonymous 13. December 2007, 20:01

Anonymous writes:

The plugin didn't appear when following your instructions.

As well as this, I had to read each instruction at least 5 times. Next time you make a guide like this, could you at least list the commands to type, so I can learn that way for future reference? I'm sure others are thinking the same thing, or going else where for a guide to this.

Disappointed, cheers, Anonymous.

area42 13. December 2007, 20:20

Hello,

1st: I didn't typed in anything, i did all by mouse in Nautilus
2nd: If you getting problems installing it you should write what kind of system and version you are using
3rd: Did the plugin appeared in the preferences? Have you activate it?
Did you restarted gEdit?
4th: Did you tried starting gEdit from a shell and getting error messages there?

Thanx.

Anonymous 17. December 2007, 09:56

Gocho writes:

A link with some external reference files (PDF, a DocBook XML, a CHM Windows helpfile, a PostScript file or a HTML page) would be great!

The PHP docs are here:
http://www.php.net/download-docs.php

area42 17. December 2007, 11:20

Hi Gocho,

no problem, take a look at:
http://www.pspad.com/en/helpfiles.htm

:smile:

Anonymous 5. February 2008, 11:21

DD writes:

hi there, I get this error:
'
Traceback (most recent call last):
File "/home/pawel/.gnome2/gedit/plugins/reference.py", line 71, in
lambda a: self._plugin.on_reference_activate(self._window))])
File "/home/pawel/.gnome2/gedit/plugins/reference.py", line 121, in on_reference_activate
ext = ext.split('.')[1]
IndexError: list index out of range
'
gedit v. 2.20.4
cheers

area42 5. February 2008, 12:39

Hello DD,

thanx for the feedback.
What are the names of the files located in "~/.gnome2/gedit/help"? Are there hidden files?

Anonymous 5. February 2008, 15:58

DD writes:

Hello. :)

~/.gnome2/gedit/help/php.chm ; from php site, link above, english ver opened with gnochm, no hidden files
and from your zip, and no other files:
~/.gnome2/gedit/plugins/reference.py
~/.gnome2/gedit/plugins/reference.gedit-plugin

cheers

area42 5. February 2008, 18:19

Ok,
i will try to find the bug. Thanx.

area42 1. March 2008, 21:23

Hi,

i updated my reference plugin, now it works with unsaved files too. Please read the instructions about the changed naming of your reference documents.

Anonymous 4. April 2008, 23:59

mp writes:

Plugin comes up in list, but when clicking check-box to activate it, selection becomes greyed out and plugin is not activated.

::Ubuntu 7.10, Gedit 2.20.3, Python 2.5 (default install)

Ran from a shell and this was the output:

~/ $ gedit src/deal/deal.c
Traceback (most recent call last):
File "~/.gnome2/gedit/plugins/reference.py", line 29, in
from gpdefs import *
ImportError: No module named gpdefs

** (gedit:1047): WARNING **: Cannot load Python plugin 'Language Reference' since file 'reference' cannot be read.

** (gedit:1047): WARNING **: Error activating plugin 'Language Reference'

area42 5. April 2008, 08:08

Hi,

thanx for the feedback. This is exactly my configuration too.

I have gEdit and gEdit additional plugins installed (in the repros too) and it still works fine.

I will take look at it.

area42 5. April 2008, 15:42

Hi,

i checked it out, you need to install the package gedit-plugins. This is a very usefull package and will add the following features:
* Show/Hide Tabbar: Add a menu entry to show/hide the tabbar.
* Bracket Completion: Automatically adds closing brackets.
* Draw Spaces: Draw Spaces and Tabs
* Embedded Terminal: Embed a terminal in the bottom pane.
* Color Picker: Pick a color from a dialog and insert its hexadecimal representation.
* Session Saver: Save and restore your working sessions
* Join/Split Lines: Join several lines or split long ones
* Smart Spaces: Forget you're not using tabulations.
* Character Map: Insert special characters just by clicking on them.
* Code comment: Comment out or uncomment a selected block of code.

The package is included in Ubuntu.

Anonymous 5. May 2008, 06:31

Miguel Hermo writes:

Great plugin, thank you!!
I had the same problem than some guy before, i get the error:
Traceback (most recent call last):
File "/home/miguel/.gnome2/gedit/plugins/reference.py", line 79, in
lambda a: self._plugin.on_reference_activate(self._window))])
File "/home/miguel/.gnome2/gedit/plugins/reference.py", line 127, in on_reference_activate
lang_name = doc.get_language().get_name()
AttributeError: 'NoneType' object has no attribute 'get_name'

---
This error happens when "view>highlighting mode" is set to "none". I suppose this can be trivially solved by checking that "doc" is a "noneType" object, but I'm sorry to say that I know nothing about python so I cannot contribute. :(

Also I noted that someone had problems with php, and he/she had the help file for php named as:
~/.gnome2/gedit/help/php.chm

This is not valid, because PHP is listed uppercase on the "highlighting mode" dropdown menu, and *nix is case-sensitive. So it must be named:
~/.gnome2/gedit/help/PHP.chm

The same goes for Python, it must be Python.chm and not python.chm. Just check the list from the menu and copy literally.

Hope it helped!

I hope it's usefull

area42 5. May 2008, 09:17

Thanx. I will update the plugin soon to support the new search features of envince and will try to fix this small issues too.

Anonymous 23. March 2009, 13:14

Thomas writes:

Hi,

Thanks for your efforts.

Could you kindly also support Java. At present on opening a java file, the "language reference" menu item under help is not activated (visible).

Also a cool feature would be the ability to obtain some sought of context sensitive help using this mechanism, if this is possible. For instance if gnochm or xchm (or evince ...) can accept command line options to search the document for a particular keyword or phrase and open that page on starup. This would provide an easy context sensitive help.

regards

Anonymous 23. March 2009, 13:28

Thomas writes:

Sorry, reference does work for Java. I had messed up my gedit config accidently.

regards

Anonymous 12. May 2009, 16:16

Charel writes:

Hey dude ,

great plugin, it should be added to the shipped plugins by gEdit , but something other , I checked up your python code and I saw that you just execute System commands , so , I can also change the shell commands , and use another software? no?

Kind regards - Charel

http://webdude.kunsmann.eu/

http://twitter.com/azunix

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies