summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-10-31 19:22:00 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-11-04 22:02:44 +0000
commit02312fe5ffbde195c4d68321ae407696789d79b9 (patch)
tree4e2067e049543de26ded317f789d7e82dc6f4199 /src
parent5e54705e26115e6ca77330b16744efb381ac902b (diff)
Allow to ommit the catch part in the try command
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc11
-rw-r--r--src/rc/cpp.kak10
-rw-r--r--src/rc/git-tools.kak4
3 files changed, 14 insertions, 11 deletions
diff --git a/src/commands.cc b/src/commands.cc
index eb560b4f..a331c94f 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -657,10 +657,12 @@ void info(CommandParameters params, Context& context)
void try_catch(CommandParameters params, Context& context)
{
- if (params.size() != 3)
+ if (params.size() != 1 and params.size() != 3)
throw wrong_argument_count();
- if (params[1] != "catch")
- throw runtime_error("try needs a catch");
+
+ const bool do_catch = params.size() == 3;
+ if (do_catch and params[1] != "catch")
+ throw runtime_error("usage: try <commands> [catch <on error commands>]");
CommandManager& command_manager = CommandManager::instance();
try
@@ -669,7 +671,8 @@ void try_catch(CommandParameters params, Context& context)
}
catch (Kakoune::runtime_error& e)
{
- command_manager.execute(params[2], context);
+ if (do_catch)
+ command_manager.execute(params[2], context);
}
}
diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak
index 8bcc987a..1db0ca5a 100644
--- a/src/rc/cpp.kak
+++ b/src/rc/cpp.kak
@@ -18,11 +18,11 @@ hook global WinSetOption filetype=cpp %~
addhl -group cpp-highlight regex "^\h*?#.*?(?<!\\)$" 0:macro
addhl -group cpp-highlight regex "(?<!')\".*?(?<!\\)(\\\\)*\"" 0:string
addhl -group cpp-highlight regex "(//[^\n]*\n)|(/\*.*?(\*/|\'))" 0:comment
- hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } catch %{} }
- hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s^\h+<ret>yj<a-h>P } catch %{} ] # preserve previous line indent
- hook window InsertKey \n -id cpp-hooks %[ try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] catch %{} ] # indent after lines ending with { or (
- hook window InsertKey \} -id cpp-hooks %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] catch %{} ] # deindent on insert } alone on a line
- hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s\h+$<ret>d } catch %{} ] # cleanup trailing white space son previous line
+ hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } }
+ hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s^\h+<ret>yj<a-h>P } ] # preserve previous line indent
+ hook window InsertKey \n -id cpp-hooks %[ try %[ exec -draft k<a-x><a-k>[{(]\h*$<ret>j<a-gt> ] ] # indent after lines ending with { or (
+ hook window InsertKey \} -id cpp-hooks %[ try %[ exec -draft <a-h><a-k>^\h+\}$<ret>< ] ] # deindent on insert } alone on a line
+ hook window InsertKey \n -id cpp-hooks %[ try %{ exec -draft k<a-x>s\h+$<ret>d } ] # cleanup trailing white space son previous line
~
hook global WinSetOption filetype=(?!cpp).* %{
diff --git a/src/rc/git-tools.kak b/src/rc/git-tools.kak
index 61b5ebd0..3cc005a4 100644
--- a/src/rc/git-tools.kak
+++ b/src/rc/git-tools.kak
@@ -39,7 +39,7 @@ def -shell-params git %{ %sh{
run_git_blame() {
(
echo "eval -client '$kak_client' %{
- try %{ addhl flag_lines magenta git_blame_flags } catch %{}
+ try %{ addhl flag_lines magenta git_blame_flags }
set buffer=$kak_bufname git_blame_flags ''
}" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session}
declare -A authors
@@ -92,7 +92,7 @@ def -shell-params git %{ %sh{
show|log|diff) show_git_cmd_output "$@" ;;
blame) run_git_blame ;;
show-diff)
- echo "try %{ addhl flag_lines black git_diff_flags } catch %{}"
+ echo "try %{ addhl flag_lines black git_diff_flags }"
update_diff
;;
update-diff) update_diff ;;