Archive for the 'Editors' Category

Jedit TaskList plugin

Thursday, April 7th, 2005

I wrote a post praising PyPe’s todo comments a while back and it was one of the reasons to prefer PyPe over Jedit. But there is a plugin available for Jedit that provides the same functionality with some extensions and this fits right within my view of PyPe (simple with only the basic functionality) and Jedit (richer functionality but more complex). This is also good news for none-Python programmers since PyPe is only intended for Python programming.

The plugin is called TaskList and you can find it under “Project Management” in the builtin plugin manager. The first notable difference is that theTaskList plugin is not limited to todo comments. There are also debug, done, fixme, idea, note, question and “something i don’t get” comments. Not only that, you can change the available types of comments and add your own types if you like.

Let’s get visual, first some comments :
TaskList comments

The corresponding sidebar:
Tasklist sidebar

And a full Jedit screenshot :
Jedit screeenshot with the Tasklist plugin

In the default configuration, your comments must follow a strict format or your comments won’t be registered. The format is a start comment sign (#) followed by one or more spaces, the keyword, a colon, a space and your comment. Of the following todo comments, only the two first are valid.

# TODO: todo comment
# TODO:  todo comment
#TODO: todo comment
# TODO:todo comment
# TODO : todo comment
#TODO : todo comment

This is perfectly fine Python comments (and fine for many other languages too) but TaskList most likely also handles what is appropriate for your language. For Java, f.ex. you might use

// TODO: todo comment

The TaskList plugin is higly configurable and options include highlighting of your comments and task sorting. Not only that, you can modify the existing comment types (syntax rules and icons) and add your own types as seen on this screenshot :
TaskList configuration

If that’s not enough for you, install the TaskList plugin. Then, in the Help menu, choose Jedit Help, then scroll down to Plugins in the Help index and choose TaskList.

While we’re on the subject I should also mention that the upcoming PyPe 2.0 release (currently in beta) supports arbitrary comment tagging so you can use f.ex.

#bug: There is a bug here

to mark a potential bug. It’s mentioned on the PyPe screenshots page along with other promising features.

Brilliant feature #1 : PyPe todo comments

Thursday, December 30th, 2004

The Python editor PyPe is intended to be a simple editor that includes what you need and not much more. It does however include a nice little feature that I haven’t seen anywhere else. It’s called todo comments. A comment in Python looks like this
#A comment
A # sign followed by your comment. A PyPe todo comment is a perfectly valid Python comment and looks like this
#Todo: a todo comment
That’s a # sign followed by the word todo, a colon and the todo comment. Remember that you can’t have anything in front of it, so this line
a = 5 #Todo: a todo comment
includes a valid Python comment but it is not a valid todo comment because of the python code in front of it.

So what’s special about that? Let’s first take a look at a PyPe screenshot :

PyPe screenshot showing the text area, code browser and todo box

The PyPe view consists of a text area where you write your Python code, a browsable code tree to the upper right and a box with shortcuts to your todo comments to the lower right.

Whenever you think about something that needs to be done or find a problem with your Python code that you can’t fix instantly, add a todo comment and PyPe adds it to your todo list. The todo list is built when you open your file and refreshed everytime you press F5 (note: you might have to enable todo comments in the document menu).

Example todo comments:

Screenshot of example todo comments

This results in the following todo list :

Screenshot of the corresponding PyPe todo list

You can add todo comments anywhere in your code and when you doubleclick an entry in the todo list you are taken to the line that contains the todo comment. Simple, effective and brilliant!

Jedit 4.2 final is released

Monday, August 30th, 2004

At last! Get it here.
Jedit is a Java-based editor which is useful not just for Java programming, but for most other programming languages too.

One of its biggest strengths is the amount of available plugins combined with the built in plugin manager. To enhance Jedit you should first download the BufferTabs (or BufferSelector) plugin, both provides easy navigation between buffers. The Background and LookAndFeel plugins are what you need to make Jedit look cool.

Python programmers should download the JythonInterpreter plugin right away. It includes a Jython shell and a code browser for Python. WhiteSpace and JPyDebug makes Jedit even better for Python development.

There are also plugins for Java development (of course), PHP, Perl, XML, project management etc. Just open the Plugin Manager and explore.

Jext for J2SE 5 is available

Wednesday, August 25th, 2004

J2SE (Java 2 Standard Edition) 5.0 aka Tiger or 1.5 is still in beta, but Jext 5.0, a release for J2SE 5.0 is already available. Or it has been available for 1.5 months, but I didn’t know. The most visible change is a new look which is not a bad thing. Previous releases look a little boring in the original configuration.

If you don’t already know, Jext is a free source code editor built with Java and Python, originally based on an early version of Jedit. Jext includes support for all common languages, including code browsers for both PHP and Python.

PyPe and CherryClasses

Friday, August 20th, 2004

The CherryPy web framework (for Python) have some great features, like automatic url-to-method mapping. But it uses some “toy code” that makes it hard to handle for some Python editors. PyPe is a Python editor written in Python, so it’s easy to modify for a Python programmer. Let’s modify the builtin class browser so it handles CherryPy files perfectly. To follow this guide you should have PyPe installed (I have some problems with version 1.9.3, but 1.9.2 works perfectly) and a CherryClass (any .cpy file from the CherryPy distribution up to the current 0.10) or this file. Future versions of CherryPy will use only Regular Python code so unfortunately this guide will not be so useful within a few months. Let’s first take a look at the PyPe class browser’s presentation of a CherryClass :

CherryClass before

As you see, it only shows the functions. We want it to create a browsable tree with the CherryClass at the top level, sections as children of the CherryClass, and functions as children of the sections.

First, CherryPy uses an extension of Python classes called CherryClasses, identified by the keyword CherryClass. CherryClasses are divided into multiple sections called variable, aspect, mask, view and function. We need to make PyPe code parser aware of these keywords. The function we must modify is called fun and is a method of the function fast_parser in the parsers.py file. The fun function starts at line 35 (for PyPy 1.9.3). The relevant code is from line 100.

if ls[:4] == 'def ':
fun('def ', line, ls, line_no, stk)
elif ls[:6] == 'class ':
fun('class ', line, ls, line_no, stk)
elif ls[:1] == '#':
a = ls.lower().find('todo:')
if a+1:
todo.append((line_no, ls.count('!'), ls[a+5:].strip()))

You can see that it identifies class and function declarations and “todo” comments (a PyPe special feature). We just need to make it aware of the special CherryPy keywords. We also need 2 small hacks to make CherryClass sections reside within the CherryClass in the tree (because these are not indented) and to identify them as sections. The code to add, preferably after

elif ls[:6] == 'class ':
fun('class ', line, ls, line_no, stk)

is this:

elif ls[:12] == 'CherryClass ':
fun('CherryClass ', line, ls, line_no, stk)
elif ls[:9] == 'variable:':
ls = "section variable:"
line = " " + ls
fun('section ', line, ls, line_no, stk)
elif ls[:5] == 'mask:':
ls = "section mask:"
line = " " + ls
fun('section ', line, ls, line_no, stk)
elif ls[:5] == 'view:':
ls = "section view:"
line = " " + ls
fun('section ', line, ls, line_no, stk)
elif ls[:9] == 'function:':
ls = "section function:"
line = " " + ls
fun('section ', line, ls, line_no, stk)
elif ls[:7] == 'aspect:':
ls = "section aspect:"
line = " " + ls
fun('section ', line, ls, line_no, stk)

The 2 hacks are ls = "section keyword:" to add the section keyword before the type of section, and line = " " + ls to artificially indent the section identifier lines with one space. If you are normal, you have indented functions with at least two spaces and sections are then placed at a level above functions. Now, let’s take a look at how the PyPe class browser presents our CherryClass :

CherryClass after

Wohoo!!!! Just what we wanted!!!

One more thing to do is to modify the file browser so it associates .cpy files with Python/CherryPy. I’ll leave this as an exercise to the reader. Look at the code at line 101 and below in configuration.py and it should be quite easy.