jEdit Community - Resources for users of the jEdit Text Editor
Is there a Perl folding plugin?
Submitted by malibu on Saturday, 30 December, 2006 - 17:20
I have the CodeBrowser and the PerlSidekick plugins installed, but they don't seem to detect subroutines in Perl. All I can get are the script names in each view. I don't have any code folding except it does seem to match brackets. Does anyone know what I may be doing wrong? I'm using the newest version of jEdit and I haven't messed with the perl.xml modes file at all.
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Perl browsing
by shlomy on Mon, 01/01/2007 - 07:29
1. If your Perl files are properly indented, you can use the "indent" folding mode.

2. The CodeBrowser plugin uses the Exubertant Ctags tool to get the tag information from the current buffer. For CodeBrowser to work, Ctags must be installed and the path to the Ctags executable must be specified in the CodeBrowser plugin options. If you have Ctags installed, and its path is specified in the plugin options, you should verify that your version of Ctags supports Perl. Type:
[path-to-ctags] --list-languages
and check that Perl is in the output. If not, you should get a version of Ctags that has support for Perl. You can download it here: http://ctags.sourceforge.net

3. Finally, if you have a version of Ctags that supports Perl, try to run it manually (in a console window) on one of your Perl files:
[path-to-ctags] -f - [your-perl-file]
(e.g. ctags -f - myPerlScript.pl)
The output of Ctags consists of tag lines, one tag per line. The first column on each line is the tag name. Check if your subroutines appear on the list. If the output of Ctags is a single line, it means that Ctags did not parse the file correctly. This can happen due to the very special constructs of Perl (e.g. HERE documents). If this is the case, then you should consult Ctags support. (If you like, you can also try to reduce the Perl file to the minimal size that demonstrates the problem and post it here, and I will try to find the problem myself.)

4. I have written a relatively new plugin named CtagsSideKick, which does more or less what CodeBrowser does, but has better support for object-oriented languages. For example, it enables you to select how you want the tags grouped, so that tags belonging to a namespace (e.g. class or package) can be grouped under their namespace instead of under the tag kind. Currently my plugin does not have any special support for Perl but I can easily add it if it's useful.
 
Support for fox pro files
by dougis on Wed, 04/04/2007 - 18:45
Sorry to jump into the thread in the middle, but I need some help with CtagsSideKick.

I have just moved to 4.3 and gave up Code Browser for CtagsSideKick.
I write a lot of code in Visual Fox pro and so have a ctags.cnf file (I am in windows obviously) that defined a few of the common things I wanted to view in Code Browser. The same file does not generate any output for me in CtagsSideKick. (I parse the file but nothing shows in my list of objects).
If I run ctags manually it still sees my fox defines in the .cnf file so I am not sure what is causing the issue. (If I parse through a file manually I end up with a tags file that has parsed it out).
Any ideas of how I can get this to work?

Thanks for any help.
 
Found my issue
by dougis on Wed, 04/04/2007 - 18:50
In case this will help anyone else.
The original Code Browser module used the ctags.cnf file in the same dir as ctags (in my case C:\Program Files\jEdit).
The CtagsSideKick plug in is calling it in a manner such that ctags expects this file in one of the global locations.
See this post for more detail on where that might be.
Seems to be doing exactly what I needed now.
 
not working
by malibu on Tue, 02/01/2007 - 15:57
Thank you for your comments. I did notice the big yellow message about having the correct ctags installed and I had done so, and entered the correct path before my post. I am using jEdit through SFTP (awesome feature) and so I had to save some of my code locally in order to play around with it on the command line.

Here is an abbreviated version of my script, a normal log rotater:

#!/usr/bin/perl

$config_dir = "/var/adm/tidylog";

$l_date = `date +"%Y-%m-%d"`;
$l_time = `date +"%H:%M:%S"`;
chomp $l_date;
chomp $l_time;

sub perr {
$msg = $_[0];
print ("Error: $msg\n");
exit;
}

sub plog {
$msg = $_[0];
open (LOG, ">>$config_dir/tidylog.$l_date.log");
print LOG "$l_date $l_time $msg\n";
print "$l_date $l_time $msg\n" if ($do_stdout == 1);
close LOG;
}

.. mainline follows



When I saved it locally and ran ctags on it I get the following:

perr tidylog.pl /^sub perr {$/;" s
plog tidylog.pl /^sub plog {$/;" s

Oh and now I do see the tags in the code browser. But still nothing for my scripts across SFTP. All of my source code is on other servers.
 
CtagsSideKick works across SFTP
by shlomy on Wed, 03/01/2007 - 06:34
The plugin that I wrote, CtagsSideKick, does the same (more or less) as CodeBrowser, and it does work across SFTP. It doesn't really care where the files are located since it takes the contents of the files from jEdit directly - so my plugin will work with any file that jEdit can open in a buffer.
Just install my plugin (CtagsSideKick), and open its SideKick window. In the options of the plugin, select "group by kind" to get the same tree as CodeBrowser. Also, disable the icons in the plugin options, since I haven't added icons for Perl tags.
 
That sounds great.. but I ins
by malibu on Thu, 04/01/2007 - 02:59
That sounds great.. but I installed the plugin, set the ctags path, unchecked the icons (group by kind was selected by default) and I didn't get anything in the sidekick window? I selected CTAGS in the parser type, I assume this is correct..

It doesn't seem to work for me?
 
There may be a number of reasons
by shlomy on Thu, 04/01/2007 - 06:32
1. SideKick has a known problem that sometimes the combo-box for selecting the parser does not work. To work around that, you can associate the 'ctags' parser with perl mode in the SideKick plugin options (Plugins -> Plugin Options -> SideKick -> Parsers). Once you do this, every buffer that is opened in perl mode will automatically by parsed by CtagsSideKick. Try to open a new Perl source file and see if it solved the problem.

2. Verify that the Perl file you're editing was really opened with the perl edit mode. By default, the edit mode of the buffer is specified in the status bar (on the right), but if you don't see it there, use the menu "Utilities -> Buffer Options" and check that the edit mode is perl.

3. It may be that the Perl file was incorrectly parsed by ctags. However, there should be no difference from CodeBrowser. If you save the file locally, and CodeBrowser shows you the functions, so will CtagsSideKick.
Like my first reply, you should run ctags manually on the file to check if it produces the tags. Note that ctags usually determines the language of the file from the filename extension - if your Perl source file is named something like 'myfile.pl.txt', ctags will not consider it to be a Perl file (as far as I know). The file should have a standard Perl extension ('.pl', '.pm', ...).

4. Make sure you set the ctags path correctly. Maybe try to open a simple C file and see if it does show sometimes.
 
results
by malibu on Thu, 04/01/2007 - 14:19
Ineresting results..

1. I went in and associated the Perl mode directly with ctags and it made no difference.

2. Yes it's always been in perl mode.

3. Yeah my files all have the .pl extension. I can't even get it to work on my local Perl file mentioned earlier in the thread. I ran ctags manually on it, even copying from the path field as specified in the plugin config and it works fine:

perr tidylog.pl /^sub perr {$/;" s
plog tidylog.pl /^sub plog {$/;" s

..but the sidekick window remains blank.

4. I tried the following C file locally:

#include <stdio.h>

int print_hello() {
printf("Hello there!\n");
}

int main() {
print_hello();
return(0);
}

And it worked great as soon as I hit 'parse'. But I then saved it to my SFTP server, closed everything and opened just the SFTP file and it didn't work. The sidekick window remains blank.

So to me it seems like there is actually two problems:
a) It doesn't want to work with SFTP
b) It doesn't want to work with Perl.
 
Oops
by shlomy on Fri, 05/01/2007 - 00:02
Oops, sorry, my mistake. I added the support for remote files after the plugin was released, so if you got the plugin using the Plugin Manager, the version you have only supports local files.
If you like, you can download the updated version (the one supporting remote files) here:
http://community.jedit.org/?q=node/view/3044

Just copy the jar file over to .jedit/jars in your home directory, and then disable and re-enable CtagsSideKick using the Plugin Manager.
If you like, you can check-out the plugin sources from SVN and build it instead. I sometimes add new features there.

Regarding "doesn't want to work with Perl": I have just tried it myself and it worked fine on a Perl module opened from the web: http://search.cpan.org/src/EWILHELM/CAD-Drawing-0.26/lib/CAD/Drawing.pm

Once you install the new version, try it on this Perl module and see if it works. In any case, it should behave the same as CodeBrowser. If it does not behave the same, please let me know.
 
thanks!
by malibu on Fri, 05/01/2007 - 04:04
Thank you for your help (and the plugin!). It works now. At first it didnt. I loaded the new plugin version and it wasn't working for Perl on a local file, but codebrowser was. It would only show the filename at the top, nothing more. I played around for a bit and ended up selecting 'sort tags by line number' in the CtagsSideKick flyout. Everything appeared immediately. Does that make sense to you?

later edit:
I think there may be a problem (possibly deeper then the plugin) with setting of default values from the menus. I was having a problem getting CtagsSideKick to reparse for a second perl script even though 'Parse on buffer switch' was checked. Finally I unchecked the option and re-checked it and everything worked fine.
 
Clarification
by shlomy on Sat, 06/01/2007 - 14:08
Did you mean 'sort tags by name'? There is nothing like 'sort tags by line number' in the CtagsSideKick plugin options.
(What's the word 'flyout'? I couldn't find this word in dictionaries)

It could be that CtagsSideKick did not work because of problems with reading/writing the options in jEdit. After all, it requires the path to the Ctags executable in order to work. If for some reason this wasn't ok in the jEdit properties file, it could not work. Other than this, I don't see how one setting or another of CtagsSideKick could affect the behavior in such a way. The same tags are generated in any case, it's just the grouping and/or sorting that you define using the options.
 
options
by malibu on Mon, 08/01/2007 - 02:54
When I select Plugins->CtagsSideKick I get a submenu with the following options:



Sidekick
--------
Group tags by kind
Group tags by namespace (multi-level)
Group tags by namespace (flat)
--------
Sort tags by line number
Sort tags by name
Sort tags by name, fold preceding leafs



When I selected 'Sort tags by line number' above, it started to work.

Furthermore, in the 'Sidekick' window docked at the side, I couldn't get a list of the subroutines when I switched the buffer (ie. I couldn't get it to re-parse). I noticed when I right clicked on the 'parse' button at the top left I got some options:

_ Follow caret
Parse on...
_ Buffer change
_ Buffer save

Even though 'Buffer change' was selected, I had to unselect and reselect before it would reparse.


The path to ctags.exe was always correct. I had even tested it by copying it from the settings and pasting it into the command line when I did the command line test.
 
Thanks for the info
by shlomy on Mon, 08/01/2007 - 08:04
... but, no idea why this happens. The code of CtagsSideKick always runs Ctags the same way (no matter which options are selected), and the sorting only affects the order of tags in the tree.

If you find CtagsSideKick useful, I can add the special support for Perl , it only takes a few minutes. Are you using object-oriented Perl, or simple Perl?
Special support means: Allow you to group Perl objects (subroutines / variables) under their namespace (as far as I remember, in Perl, a pacakge is used as a namespace), and also provide icons for Perl tag kinds (e.g. a different icon for a subroutine/hash/scalar etc), depending on the information I get from Ctags.
 
Well I really think the plugi
by malibu on Mon, 08/01/2007 - 16:30
Well I really think the plugin is great as it is. But if it could show objects/modules that would be even better! I'm using object oriented Perl.

Yes, objects are implemented as a file that begins with a 'package' declaration. The variables for the object are all stored within a single construct which goes through the 'bless' function (basically binding the construct to the object). Within each class subroutine, the blessed construct is then passed as the first parameter.

Modules are kind of like library files.. Not sure if you would want to include those or not.
 
Not much to do for Perl
by shlomy on Wed, 10/01/2007 - 12:12
I now see that Ctags only provides 3 kinds of tags for Perl: subroutines, labels, and constants. It does not tell you the objects inside packages. I forgot that in Perl you don't declare these, but rather members are usually keys inside a hash, so Ctags can't know about them.
Hence, there is nothing for me to do for Perl support other than provide icons for the 3 tag kinds (subroutines, labels, constants). Sorry.
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300