|
From: Bosse I. <bo...@us...> - 2013-07-17 13:07:35
|
Hi Edward,
I'm not entirely sure that I understand you correctly, but here goes...
There are only two built-in folding modes in jEdit: 'indent' and 'explicit'. Additionally, you can write plugins to add new folding modes, which is what the mentioned plugins do.
SideKick introduces the 'sidekick' folding mode, and ConfigurableFoldHandler introduces the 'custom' folding mode. Neither of these plugins has any effect on the default folding mode - that is for you to set up.
The 'sidekick' folding mode is provided by SideKick, but what it does is simply to create foldings for each of the assets in the tree-view, which means that it is up to the language (or edit mode) specific plugin that extends SideKick (Ctags in your case) to actually provide SideKick with data about where to start and end the foldings. This is just one really nice feature that SideKick provides.
The 'custom' folding mode is on the other hand the only thing that ConfigurableFoldHandler provides, and you seem to know how that works.
You can specify which folding mode to use for:an individual file: Either temporarily while in a buffer, using the Buffer Options, or permanently by setting the "folding" property directly in the source code file, e.g. with ":folding=sidekick:".as default for a particular edit mode (when there is no file-specific mode set for the buffer as described above): Go to "Editing" under Global Options, select the edit mode in "Change settings for mode", uncheck "Use default settings" and set the folding mode you want for that edit mode.as a global defalt, or a "fallback mode" if you like (for when no folding mode matching the above is set): Global Options > Editing > Change settings for mode="<global default>". I assume that this is the one you have been using?
At work as well as home, I have the fallback (method 3 above) set to 'indent'. For all edit modes (2) that I use a SideKick plugin for, I have the folding mode set to 'sidekick'. For a few edit modes (also 2) that we have created at work for site specific file formats, I use 'custom'. And finally, in a few rare cases, I have added ":folding=some_mode:" directly in the source code file (1) to force a folding mode other than the default for the edit mode. A typical example for the last variant is when a source file is badly structured, or even corrupt (not one of my own files then of course ;-), messing up the SideKick asset list so that it is better to use, for example, folding mode 'indent' or even 'none'.
I forgot what point I was trying to make :-/ but I guess it was that you do not need change the default folding mode for the edit mode if you just want to do it temporarily. Just use method 1 or 2 above depending on the situation.
As for your question about shortcuts for changing global options: I suppose that the reason for not having predefined commands for these is that there already are more commands than you can easily keep track of :-) Seriously though, this is is just the type of thing to do with a BeanShell macro (in jEdit I mean).
Admittedly, I totally suck at writing BeanShell macros, but practice makes perfect as they say. So I tried my hand at a macro to toggle back and forth between folding mode 'sidekick' and 'custom', and lo and behold, I actually got it working after only - ehrrmm - well, not too long ;-)
currFH = buffer.getFoldHandler().getName();newFH = currFH.equals("sidekick") ? "custom" : "sidekick";buffer.setFoldHandler(FoldHandler.getFoldHandler(newFH));buffer.setStringProperty("folding", newFH);buffer.invalidateFoldLevels();
This is probably not the best way to do it, but at least it works (apart from that the folding mode indicator on the status bar is not refreshed until switch buffer back and forth :-)
Just bind it to a shortcut of your choice and toggle away. Though, if you ask nicely on the mailing list, I'm sure that someone who is better than I at this can provide you with a much better macro variant.
/Bosse
> To: jed...@li...
> From: eld...@tr...
> Date: Tue, 16 Jul 2013 20:11:26 -0400
> Subject: Re: [ jEdit-users ] Plugin for folding based on string or regular expression
>
> On 7/15/2013 11:40 PM, Alan Ezust wrote:
> > Just because you are using sidekick for a particular mode, doesn't mean
> > you need to use sidekick folding also. You can override what folding
> > mode you want for each mode from the Global Options - Editing.
>
> I like Sidekick folding when it parses a file but I also like folding
> based on finding a string/RE on particular lines. I should be able to do
> either fairly easily at different times for the same source file(s). But
> I must manually change the folding mode for a file mode in order to use
> either one at different times. Furthermore JEdit does not offer
> shortcuts for changing individual options so I must always do it from
> the Global Options dialog.
>
> Has no one ever suggested that JEdit should support shortcut keys to
> change individual Global, Buffer, and Plugin options ? This would make
> it much easier to change a particular option rather than having to
> manually do it, which entails finding the right option to change amidst
> the option dialogs.
>
> >
> > On Mon, Jul 15, 2013 at 8:23 PM, Edward Diener <eld...@tr...
> > <mailto:eld...@tr...>> wrote:
> >
> > On 7/15/2013 8:51 PM, Alan Ezust wrote:
> > > That sounds like the description of the ConfigurableFoldHandler
> > plugin.
> >
> > Unfortunately this plugin wants the default folding mode to be custom.
> > Since I am also using Ctags Sidekick the folding mode is set to Sidekick
> > for my C++/Java source files. Surely it should be easier to use Ctags
> > Sidekick at one time to fold a buffer in a certain way and
> > ConfigurableFoldHandler at another time to fold a buffer in a different
> > way. But I would have to manually change the folding mode back and forth
> > in order to do this.
> >
> > BTW has no one ever suggested that JEdit's shortcuts should extend to
> > changing individual buffer options, global options, and plugin options
> > without having to bring up the appropriate dialogs.
> >
> > >
> > >
> > > On Mon, Jul 15, 2013 at 5:47 PM, Edward Diener
> > <eld...@tr... <mailto:eld...@tr...>
> > > <mailto:eld...@tr...
> > <mailto:eld...@tr...>>> wrote:
> > >
> > > I am looking for a plugin which can do folding based on a
> > string or
> > > regular expression. The plugin should fold based in lines
> > which contain
> > > the string or regular expression match. Does such a plugin
> > exist ? I
> > > want to be able to specify the string or RE on the flow in
> > order to do
> > > folding in the current buffer.
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> --
> -----------------------------------------------
> jEdit Users' List
> jEd...@li...
> https://lists.sourceforge.net/lists/listinfo/jedit-users
|