New features: permanent filters and custom sorting

0 views
Skip to first unread message

Max E. Kuznecov

unread,
Dec 4, 2009, 6:00:54 AM12/4/09
to xyz...@googlegroups.com
I've recently implemented two new features in :sys:panel plugin -
permanent filters and custom sorting.
Permanent filters can be used to permanently filter out any kind of
filesystem objects from displaying in panel.
Therere are three plugin configuration options dealing with filtering:

* filters_enabled: Boolean (default False) -- Flag indicating whether
to enable filtering. If set to False filters won't ever be applied.
* filters_policy: Boolean (default True) -- Determines filtering
policy. If set to True - filter out objects which match the rule, if
set to False - filter out objects which do not match the rule.
* filters: list of strings -- List of rules to be sequentially applied
to objects list. Each string here is a FSRule string, describing
desired object properties.

Example - filtering out hidden (dot) files:

In your ~/.xyzcmd/conf/plugins.xyz put:

plugin_conf(":sys:panel", {
"filters_enabled": True,
"filters": [r'type{file} and name{"^\\.{1}[^.]"}']
})

To disable permanent filter on the fly, type in management console:
plugin_conf(":sys:panel", {"filters_enabled": False})

To change filter list on the fly:
plugin_conf(":sys:panel", {"filters": ["filter-1", "filter-2", "filter-n"]})

***

Another feature is sorting. Default sorting used in XYZCommander is:
sort by name and then put all directories first.
Now it is possible to override default sorting policy. There are two
configuration options for :sys:panel plugin dealing with sorting:

* sorting_policy: string or None -- If set to None default sorting
policy is used, otherwise it must be a string sorting policy name from
`sorting` configuration dict
* sorting: dictionary -- Defined sorting policies. Each key
corresponds to a policy name and value is either a function with two
arguments (VFSObject) behaving like cmp() or a list of those
functions. If value is a list, each function applied sequentially.

Example - sort objects in reverse order:

In your ~/.xyzcmd/conf/plugins.xyz put:

plugin_conf(":sys:panel", {
"sorting_policy": "reversed",
"sorting": {
"reversed": lambda a, b: -1 * cmp(a.name, b.name)
})

It is possible to change sorting policy on the fly, providing `new`
sorting policy was defined, in management console type:
plugin_conf(":sys:panel", {"sorting_policy": "new"})

Both these new features are already available in trunk and will be
included in 0.0.3.

--
~syhpoon
Reply all
Reply to author
Forward
0 new messages