Commit Graph

4592 Commits

Author SHA1 Message Date
Tim Allen
49ef9968c0 Support user-defined "str-to-str-map" options. 2018-08-21 18:24:14 +10:00
Frank LENORMAND
9a111b5ebe src: Improve error messages in RPC requests parsing
Cast errors in RPC requests currently make the client quit with an
error saying "uncaught exception", since `Kakoune::bad_value_cast`
exceptions are not explicitely handled.

This commit tries to catch ill-formatted requests and return a more
human-friendly error message, without quitting the client.
2018-08-18 09:28:30 +03:00
Maxime Coste
293610a432 Add a test case for -once hooks and code style tweaks 2018-08-16 21:09:51 +10:00
Maxime Coste
4387b1ac90 Merge remote-tracking branch 'lenormf/fix-hook-once' 2018-08-16 18:46:26 +10:00
Frank LENORMAND
97abfd403d src: Forbid empty menu entries
Empty entries in menus look weird, and don't serve any purpose. Empty
commands are still allowed.
2018-08-11 10:03:57 +03:00
Maxime Coste
f706b8c9be Add a -version switch to Kakoune
Closes #1035
2018-08-09 11:24:11 +02:00
Frank LENORMAND
e84dcf72c0 src: Allow hooks to be run only once
This commit implements the -once flag on the `:hook` command, which
automatically removes a hook after it was run, to avoid having to
declare a group and remove it in the hook implementation.

Closes #2277
2018-08-06 15:14:20 +03:00
Maxime Coste
472a5732e2 An empty string is not a valid number
Fixes #2284
2018-08-04 11:10:19 +01:00
Maxime Coste
3b77398c5b Add an assert to catch newpad returning a nullptr 2018-07-31 13:15:39 +01:00
Maxime Coste
075d1048ab Avoid invalid access to Optional
If the UI is not ok, the exit status of the client might not be
available. Return -1 in that case.
2018-07-30 10:32:38 +01:00
Maxime Coste
d2509e54f2 Fix compilation with gcc-5
Gcc-5 seems to have a bug in its handling of template variable.

Fixes #2267
2018-07-30 07:15:17 +01:00
Maxime Coste
2c9daf2378 Merge remote-tracking branch 'Delapouite/map-key-completer' 2018-07-28 19:48:24 +10:00
Maxime Coste
eef2ea5136 Lazily iterate over words instead of gathering them in a vector 2018-07-26 23:05:00 +10:00
Maxime Coste
eefe26b48b Fix shared string registry ref count stats 2018-07-26 22:20:19 +10:00
Maxime Coste
7cf3cbde8e Cleanup some trailing whitespaces and double semicolon 2018-07-26 21:56:34 +10:00
Maxime Coste
737807dde2 Replace a few loops with ranges 2018-07-26 21:23:06 +10:00
Maxime Coste
0919679e0d Make TransformView iterator's category match its underlying's
In particular, this make gathering a transformed range to a vector
faster because we can use the random access nature of underlying
iterator to get the size to allocate in the vector upfront.
2018-07-26 20:58:55 +10:00
Maxime Coste
62fa783bfd Fix missing override specifier 2018-07-26 20:16:48 +10:00
Maxime Coste
7905382b74 Obtain a new window for a client before releasing the current one
Creating a window potentially runs hooks, which themselves could
trigger shell evaluation, which could handle urgent input events
such as a resize, while waiting for the shell to finish. When that
happens, the client had a temporarily null window as it had already
released its own window.

Fixes #2225
2018-07-25 21:23:22 +10:00
Maxime Coste
a5f53dccb7 Micro optimize command parsing by avoiding utf8 decoding
Balanced quoted parsing does not need to decode utf8, neither does
unquoted word parsing. This improves startup time a bit, helping
for issue #2152
2018-07-25 20:58:07 +10:00
Maxime Coste
918fe6ddd8 Fix uninitialized context flags 2018-07-25 20:57:47 +10:00
Maxime Coste
0d6e04257b Fix memory leak in regex execution 2018-07-25 20:57:11 +10:00
Maxime Coste
b1187cf91d Quote every option type but integral types
Opt-in quoting was a bad choice, lets default to opt-out with
all integral types non quoted.
2018-07-24 20:26:24 +10:00
Maxime Coste
5f825cf0f5 Merge remote-tracking branch 'lenormf/fix-C-skip-empty-lines' 2018-07-23 21:14:23 +10:00
Maxime Coste
bbb508634e Support setting registers to empty lists
Note that empty registers still act as-if they contained a single
empty string.

Fixes #2228
2018-07-23 08:35:13 +10:00
Maxime Coste
f27700cc53 Restore SIGPIPE handler to default before spawning shell
Fixes #2238
2018-07-23 08:32:17 +10:00
Maxime Coste
6270ce4a80 Merge remote-tracking branch 'lenormf/fix-face-name-format' 2018-07-22 21:13:48 +10:00
Maxime Coste
3c51da4488 Merge remote-tracking branch 'lenormf/fix-development-version' 2018-07-22 15:58:41 +10:00
Maxime Coste
7b9f162e7d Opt-in types for quoting of option lists
This avoid quoting ints in int-lists for example, as they do not
risk containing whitespaces.

Fixes #2223
2018-07-22 15:51:32 +10:00
Frank LENORMAND
a2f9c68a7c src: Change the bullet point symbols in the version notes 2018-07-20 13:55:16 +03:00
Frank LENORMAND
60bd8df3c2 src: Don't print a number for the development version 2018-07-20 13:49:36 +03:00
Frank LENORMAND
2b0c143808 src: Allow face names to contain an underscore
Closes #2229
2018-07-20 09:47:30 +03:00
Maxime Coste
7195100609 Re-introduce kill_session::exit_status, @lenormf was right
As discussed in #2186, in the end we need the exit status for the
case where the local client exited first (the server forked to
background) then another client trigger the kill command.
2018-07-19 19:27:56 +10:00
Maxime Coste
56a5dc66ff Merge remote-tracking branch 'lenormf/kill-clients-exit-code' 2018-07-19 18:42:22 +10:00
Maxime Coste
40a91b1120 Add a -debug '...' switch to Kakoune startup that sets the debug option
This gives an easy way to profile startup by running with -debug profile.
2018-07-19 18:36:49 +10:00
Maxime Coste
7ed5d53fe6 Fix RegexCompileFlags::Backwards having the same value as Optimize
That means every Optimized regex had the Backwards version
compiled as well, which doubled the time it took to compile them
and doubled the memory usage of regex.

This should improve #2152
2018-07-19 18:34:40 +10:00
Frank LENORMAND
5543a4d58c src: Propagate to clients the kill exit code
Fixes #2177
2018-07-19 10:54:49 +03:00
Maxime Coste
56912dd22c Merge remote-tracking branch 'icetan/buffer-reload-hook' 2018-07-19 08:29:22 +10:00
Maxime Coste
b1d5fda960 Reduce confusion in add-highlighter docstring
Closes #2222
2018-07-19 08:26:25 +10:00
Maxime Coste
c58457a3c0 Fix manual insert completion menu not getting automatically hidden
Fixes #2208
2018-07-15 11:46:02 +10:00
Maxime Coste
d23ac09fc1 Add support for <a-;> in prompt mode
Fixes #2096
Closes #2060
2018-07-15 11:17:16 +10:00
Maxime Coste
bde726d034 Change autoshowcompl to auto_complete with insert|prompt possible values 2018-07-15 11:10:32 +10:00
Maxime Coste
2f815511da Merge remote-tracking branch 'Screwtapello/fix-info-docstring' 2018-07-14 23:17:10 +10:00
Maxim Baz
3ca424d10f
Fix description of ui_options 2018-07-13 22:46:24 +02:00
Tim Allen
591a9ab093 The info command only takes one content string, not one-or-more. 2018-07-10 17:51:57 +10:00
Christopher Fredén
ae6c214f52
Add BufReload hook which is triggered on buffer reload 2018-07-09 14:20:52 +02:00
Maxime Coste
79ec8d0010 Rename highlighters that used an underscore to use a dash
For example `show_matching` is now `show-matching`.
2018-07-08 19:14:15 +10:00
Maxime Coste
1b5f665664 Refactor WrapHighlighter::next_split_pos to avoid non-linear complexity
Previous Implementation was constantly computing byte/column count
from the begining of the line, leading to a non-linear complexity
with respect to the length of a line.

Fixes #2146
2018-07-08 18:51:11 +10:00
Maxime Coste
51ec1194f1 Use a memory mapped file for sourcing 2018-07-08 17:25:12 +10:00
Maxime Coste
cde0c51cd6 Tweak comment to make it less ambiguous 2018-07-08 16:58:19 +10:00
Maxime Coste
b6933a2bdb Fix infinite loop on SIGHUP with the NCursesUI
Fixes #2126
2018-07-08 15:54:01 +10:00
Maxime Coste
f89ea657ef Fix asserts with -sync flag handling and slight code cleanup 2018-07-05 08:30:57 +10:00
Maxime Coste
63d4c8c311 Change a on end of line behaviour to be consistent
`a` will just jump on next line, `a` on last end of line opens a new
line beneath it.

Fixes #1164
2018-07-05 08:00:14 +10:00
Maxime Coste
55a5ec3bbd Tweak how highlighter names are auto-generated 2018-07-05 07:54:28 +10:00
Maxime Coste
2e0e206951 Make recurse regex opt-in with a -recurse switch instead of opt-out 2018-07-05 07:54:28 +10:00
Maxime Coste
f9fda70de6 Fix add-highlighter docstring 2018-07-05 07:54:28 +10:00
Maxime Coste
63d7984b89 Fix bug in recursive region highlighting 2018-07-05 07:54:28 +10:00
Maxime Coste
6993b0f347 Fix region highlighters validation that the delegate type exists 2018-07-05 07:54:28 +10:00
Maxime Coste
96c9718144 Parse unknown switches as positional for region highlighters 2018-07-05 07:54:28 +10:00
Maxime Coste
073b630e7a Prevent adding region/default-region highlighters to non-regions parents 2018-07-05 07:54:28 +10:00
Maxime Coste
711150f4ac Allow removing region from regions highlighter 2018-07-05 07:54:28 +10:00
Maxime Coste
1574748d4e Invalidate cache when RegionsHighlighter subregions are modified 2018-07-05 07:54:28 +10:00
Maxime Coste
64d0fd91ae Auto-generate highlighter name if only path is given 2018-07-05 07:54:28 +10:00
Maxime Coste
b0ccf97b44 Refactor RegionsHighlighters to define each region as a separate command 2018-07-05 07:54:28 +10:00
Maxime Coste
c9cdae4364 Add HashMap::items to access item list 2018-07-05 07:54:28 +10:00
Maxime Coste
d6b0297ac8 Fix ParameterParser::position_from with arbitrary indices 2018-07-05 07:54:28 +10:00
Maxime Coste
b4b335155e Refactor add-highlighter to make naming explicit
The highlighter name must be given as part of the path of the
highlighter, as the last element.

Fixes #1712
2018-07-05 07:54:28 +10:00
Maxime Coste
18dfecfa9d Introduce a "double_up" function for doubling up escaping 2018-07-05 07:54:28 +10:00
Maxime Coste
6a31d0ebc7 Fix auto escaping of command argument completion 2018-07-05 07:54:28 +10:00
Maxime Coste
7abf04babd Improve highlighting of Kakrc string regions
Unfortunately Strings that start with a quoted quote (like '''str')
are still incorrectly highlighted, a deeper refactoring of the regions
highlighter will be necessary.
2018-07-05 07:54:28 +10:00
Maxime Coste
eab98c88bd Refactor handling of startup info to make it configurable
A new `status_info_version` option allows user to disable info
message regarding changes that happened at that version or
earlier.
2018-07-05 07:54:28 +10:00
Maxime Coste
74e4925de0 Expand %reg{} inside double quotes only to the main selection value 2018-07-05 07:54:28 +10:00
Maxime Coste
124a5d4905 Tolerate restoring invalid coordinates from register
Clamp those selection after updating them to the current timestamp

Fixes #2078
2018-07-05 07:54:28 +10:00
Maxime Coste
ed123a2cc9 Reference the big breaking refactoring in the startup message 2018-07-05 07:54:28 +10:00
Maxime Coste
27163106c7 Make register expansions expand to the full register content
Now that we have a nice standard way to express lists of strings,
registers can be fully exposed. An new $kak_main_reg_... env var
was added to provide the previous behaviour which is relied on by
doc.kak.
2018-07-05 07:54:28 +10:00
Maxime Coste
d6c6ed9bbf Store each selection as a separate element in a register
It makes more sense to use the list nature of the register to store
the selections instead of storing them as a single string separated
by spaces.
2018-07-05 07:54:28 +10:00
Maxime Coste
8aba0b3cb4 Change set-register command to take a list of values
Registers are lists of strings, so this make it possible to set
the whole list instead of forcing registers to a single element
when going through the set-register command.
2018-07-05 07:54:28 +10:00
Maxime Coste
183f32803b Fix selection save/restore from registers post selection list syntax change 2018-07-05 07:54:28 +10:00
Maxime Coste
087a940fbe Add 'skip(size_t)' range utility to skip a number of elements 2018-07-05 07:54:28 +10:00
Maxime Coste
76093f252c Change env vars that are lists to use the general list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
8b2e5ea862 Make selection lists use the option list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
b548dd3a6f Change option lists to be specified as separate arguments on commands line
Option lists and maps are specified using separate arguments, avoiding
the need for additional escaping of their separator and reusing the
existing command line spliting logic instead.

As discussed on #2087, this should make it much easier to work with
list options, and make the general option system feel cleaner.
2018-07-05 07:54:28 +10:00
Maxime Coste
5eeec8bd4d Make expansion of strings support quoting of % by doubling up 2018-07-05 07:54:28 +10:00
Maxime Coste
c829595d01 Refactor command line parsing
Command line parsing now works as follow:

* Quoted strings ('...', "..." and %~...~ with '~' non nestable)
  use 'doubling-up' for escaping their delimiter, if the delimiter
  appears twice in a row, it is considered as part of the string and
  represent one delimiter character. So 'abc''def' == "abc'def". No
  other escaping takes place in those strings.

* Balanced strings (%{...}) do not support any kind of escaping, but
  finds the matching closing delimiter by taking nesting into account.
  So %{abc{def}} == "abc{def}".

* Non quoted words support escaping of `;` and whitespaces with `\`,
  `%`, `'` and '"` can be escaped with `\` at the start of the word,
  they do not need escaping (and will not be escaped) else where in
  a word where they are treated literally. Any other use of '\' is a
  literal '\'. So \%abc%\;\ def == "%abc%; def"

As discussed in #2046 this should make our command line syntax more
robust, provide a simple programmatic way to escape a string content
(s/<delim>/<delim><delim>/g), be well defined instead of ad-hoc
undocumented behaviour, and interact nicely with other common
escaping by avoiding escaping hell (:grep <regex> can in most case
be written with the regex unquoted).
2018-07-05 07:54:28 +10:00
Maxime Coste
24d8a58b0d Add -with-hooks to execute-keys and make -no-hooks evaluate-commands specific 2018-07-05 07:54:28 +10:00
Maxime Coste
9082564ab7 Make -with-maps only available for execute-keys command
It does not make a lot of sense to have this switch for
evaluate-commands.
2018-07-05 07:54:28 +10:00
Maxime Coste
5902c7b790 Do not save any registers by default in evaluate-commands 2018-07-05 07:54:28 +10:00
Maxime Coste
ec16969609 Do not reparse %sh{...} strings
Automatic reparsing of %sh{...}, while convenient in many cases,
can be surprising as well, and can lead to security problems:

'echo %sh{ printf "foo\necho bar" }' runs 'echo foo', then 'echo bar'.
we make this danger explicit, and we fix the 'nop %sh{...}' pattern.

To reparse %sh{...} strings, they can be passed to evaluate-commands,
which has been fixed to work in every cases where %sh{...} reparsing
was used..
2018-07-05 07:54:28 +10:00
Maxime Coste
3b9818c10b Merge remote-tracking branch 'lenormf/edit-readonly-flag' 2018-07-04 19:47:05 +10:00
Maxime Coste
86616c207d Merge remote-tracking branch 'lenormf/synchronized-write' 2018-07-04 19:46:40 +10:00
Frank LENORMAND
5309b7b5e5 src: Add a -sync flag to the write commands 2018-07-04 09:49:53 +03:00
Frank LENORMAND
dd17b20bbf src: Allow the edit command to create readonly buffers 2018-07-03 14:34:48 +03:00
dahlbaek
2a509ba73f Mark unused variables with the [[gnu::unused]] attribute 2018-07-02 19:33:52 +02:00
Frank LENORMAND
266ce73de7 src: Make C skip empty lines
This commits changes the way `C` behaves when the next line is empty:
instead of stopping the selection, it will now jump to the next line
that can hold a selection as big as the current one.

The primitive's count parameter holds the maximum amount of selections
that should be added to the current one.

Closes #2061
2018-06-30 14:39:15 +03:00
Frank LENORMAND
1cb51cacb7 src: Fix cycle hogging when using C at EOF 2018-06-30 11:53:28 +03:00
Maxime Coste
43b72770ec Fix wrong logic for moving filedescriptors leading to closed stdin
With this fix, tests can now use /dev/null as stdin.

Fixes #2165
2018-06-28 22:56:50 +10:00
Olivier Perret
67655de947 Use a dedicated vm op for dot when match-newline is false 2018-06-24 12:41:50 +02:00
Olivier Perret
b5ee1db1c4 Use bit-flags for storing regex regex options 2018-06-24 12:41:50 +02:00
Olivier Perret
8edef8b3f1 Add support for regex flag to toggle dot-matches-newline 2018-06-24 12:41:50 +02:00
Maxime Coste
667777521b Refactor the way main selection is determined after rotating contents
Fixes #2133
2018-06-21 08:07:17 +10:00