[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: [kate] addons/kate/pate/src/plugins/expand: add first dynamic expansion for CMake: `ife?c?`
From:       Dominik Haumann <dhaumann () kde ! org>
Date:       2014-04-22 8:32:30
Message-ID: 5902382.ueV0uxqWF5 () obiwan
[Download RAW message or body]

Please take care of porting this to KF5's kate/framworks branch. Otherwise 
this change will be lost in KF5 at some point.

Greetings,
Dominik

On Monday, April 21, 2014 13:22:25 Alex Turbov wrote:
> Git commit 519354159b68d3b508f27379520f42f73d7598b7 by Alex Turbov.
> Committed on 21/04/2014 at 13:22.
> Pushed by turbov into branch 'master'.
> 
> add first dynamic expansion for CMake: `ife?c?`
> 
> A  +9    -0   
> addons/kate/pate/src/plugins/expand/templates/if-else.cmake.tpl A  +59   -0
>    addons/kate/pate/src/plugins/expand/text_x-cmake.expand
> 
> http://commits.kde.org/kate/519354159b68d3b508f27379520f42f73d7598b7
> 
> diff --git a/addons/kate/pate/src/plugins/expand/templates/if-else.cmake.tpl
> b/addons/kate/pate/src/plugins/expand/templates/if-else.cmake.tpl new file
> mode 100644
> index 0000000..2e74ff1
> --- /dev/null
> +++ b/addons/kate/pate/src/plugins/expand/templates/if-else.cmake.tpl
> @@ -0,0 +1,9 @@
> +if(${cond})
> +#%- if want_else %#
> +    ${cursor}
> +else(#% if duplicate_condition %#${cond}#% endif -%#)
> +    #% else %#
> +    ${cursor}
> +#%- endif %#
> +endif(#% if duplicate_condition %#${cond}#% endif %#)
> +### kate: hl cmake
> diff --git a/addons/kate/pate/src/plugins/expand/text_x-cmake.expand
> b/addons/kate/pate/src/plugins/expand/text_x-cmake.expand new file mode
> 100644
> index 0000000..93caa31
> --- /dev/null
> +++ b/addons/kate/pate/src/plugins/expand/text_x-cmake.expand
> @@ -0,0 +1,59 @@
> +# -*- coding: utf-8 -*-
> +#
> +# CMake related expansion functions
> +#
> +# NOTE Expansion plugin can complete available expansion functions for
> current +# document. To get help (via tooltip) for the selected expansion
> function use +# Ctrl+Shift+E shotcut.
> +#
> +# Copyright (C) 2014 Alex Turbov <i.zaufi@gmail.com>
> +#
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +import re
> +import sys
> +
> +from PyKDE4.kdecore import i18nc
> +
> +import kate
> +
> +import expand
> +import expand.args as arg_helpers
> +
> +
> +@expand.jinja_environment_configurator
> +def __setup_jinga__(env):
> +    env.block_start_string = '#%'
> +    env.block_end_string = '%#'
> +    env.variable_start_string = '#<'
> +    env.variable_end_string = '>#'
> +    env.line_statement_prefix = '##%'
> +    env.line_comment_prefix = '###'
> +    return env
> +
> +
> +@expand.dynamic(re.compile('^if(?P<want_else>e)?(?P<duplicate_condition>c)?
> $')) +@expand.jinja('if-else.cmake.tpl')
> +@expand.postprocess
> +def __dynamic_struct(params, match):
> +    kate.kDebug('@dynamic `if`: got params={}, match={}'.format(params,
> match.groups())) +
> +    data = {}
> +    data['want_else'] = match.group('want_else') is not None
> +    data['duplicate_condition'] = match.group('duplicate_condition') is not
> None +
> +    return data
> +
> +
> +# kate: hl python;

_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic