Commit Graph

592 Commits

Author SHA1 Message Date
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
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
Maxime Coste
665d3fa196 Fix edit -fifo without -scroll when the buffer is already opened
Scrolling was taking place in that case even though it was not
desired.
2018-06-13 07:11:03 +10:00
Maxime Coste
68fb3ba88f Rework fail command not to display command call stack
`fail` triggers "expected" errors, and hence should just display
the provided message.
2018-05-26 21:31:17 +10:00
Maxime Coste
9b89652b0b Fix potential assert on itersel selection restoration
We cannot guarantee after an itersel that selections are going to
still be in ascending order, but we were calling a SelectionList
constructor that was assuming this was the case.
2018-05-24 08:08:51 +10:00
Maxime Coste
ec0f8fe574 Extend try command to support multiple catches.
If a catch command fails, and another catch is availabe following
it, that following catch gets executed.
2018-05-19 14:15:16 +10:00
Maxime Coste
14d12fac04 Rename -allow-override switch to -override
Closes #2057
2018-05-19 14:15:16 +10:00
Maxime Coste
75eb293f98 Rename Context::Flags::Transient to Context::Flags::Draft
Draft is well establish and all draft context are transient.
2018-05-14 08:23:00 +10:00
Maxime Coste
b204e773d4 Do not push jumps implicitely in transient contexts
This should improve performance in draft contexts.
2018-05-14 08:23:00 +10:00
Maxime Coste
da1d78a3c2 Do not let exception propagate out of register restoring lambda
It is called during a std::vector destruction, which is noexcept,
leading to terminate being called.
2018-05-05 07:57:37 +10:00
Maxime Coste
a19ce37634 Tweak the way register restorers are created to try to fix OSX compilation 2018-05-03 08:14:15 +10:00
Maxime Coste
4288f0fb3a Move ScopedEdition to context_wrap
No need to create it both in context_wrap and in the called function.
2018-05-01 22:49:01 +10:00
Maxime Coste
286a244aa2 Replace RegisterRestorer with a on_scope_end + lambda 2018-05-01 22:48:14 +10:00
Maxime Coste
8438b33175 Add a debug regex command to dump regex instructions 2018-04-27 08:35:09 +10:00
Maxime Coste
4eb6740794 Add a -always switch to hook command to ignore hooks disabled
Hooks specified as always will run regardless of the hook disabled
status.
2018-04-26 08:28:11 +10:00
Maxime Coste
e207bd30d4 Extract a for_n_best algorithm from completion function
Provide the heap based n-best algorithm through a nice interface.
2018-04-19 07:58:42 +10:00
Maxime Coste
d571c207e6 Make version available through $kak_version and debug info 2018-04-09 17:06:02 +10:00
Maxime Coste
57baad4afd Make FaceRegistry scoped
set-face now takes a scope argument, and faces can be overridden on
a buffer or window basis.

colorscheme apply on global scope, which should be good enough for
now.

Fixes #1411
2018-04-07 16:27:50 +10:00
Maxime Coste
6adb28ec12 Ignore current buffer when completing the :buffer command
Closes #1901
Fixes #1782
2018-04-07 16:27:44 +10:00
Delapouite
cb02186c77 Make error messages more consistent 2018-04-06 16:56:53 +02:00
Delapouite
1b7b3fea09 Fix typo in on-key command description 2018-03-28 07:33:43 +02:00
Maxime Coste
a6b1d142fa Cleanup client name validation code 2018-03-25 16:53:27 +11:00
Maxime Coste
435b5b7ff9 Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers"
they must be in [a-zA-Z0-9_-]. Option names are the same except they
do not allow '-' as they need to be made available through the env vars
and '-' is not supported there.

Fixes #1946
2018-03-25 16:35:33 +11:00
Maxime Coste
1cdeace128 Merge remote-tracking branch 'Delapouite/doc-commands' 2018-03-21 06:42:31 +11:00
Delapouite
00cb49438a Docs: add missing [<switches>] in commands signatures 2018-03-20 09:13:09 +01:00
Maxime Coste
826977eb1b Fix remove of highlighters with trailing / in their name
Fixes #1914
2018-03-20 05:35:37 +11:00
Maxime Coste
9518f279fb Tweak option documentation helper to support -add
Fixes #1939
2018-03-19 03:04:50 +11:00
Maxime Coste
a480e566dc ranges: Add transform overload taking directly a pointer to member
This overload will forward to the general transform implementation
using std::mem_fn to generate a callable.
2018-03-13 14:24:03 +11:00
Delapouite
abc2d28570 Docs: extend explanations about line_flags, ranges and replace-ranges 2018-03-06 12:15:55 +01:00
Maxime Coste
07113e7ee5 Add a GlobalSetOption hook 2018-03-05 10:39:14 +11:00
Delapouite
c4eb4438d2 Remove <scope> from user-modes commands 2018-03-02 09:28:27 +01:00
Delapouite
a6a1c34288 Add -lock switch to enter-user-mode command 2018-02-27 19:55:00 +01:00
Maxime Coste
4d11bb20c3 Always collapse jumps in exec/eval, remove -collapse-jumps switch
There does not seem to be any reasonable use cases of not collapsing
jumps when the input is not comming from the user. Always collapse
them.

It could make sense to move jump collapsing out of context_wrap as
in general any action not comming directly from the user should
collapse them, at the moment a comment or mapping will not collapse
jumps, which is unfortunate.
2018-02-24 19:02:15 +11:00
aver-d
da009b0ef5 Fix typos in C++ string literals
informations, dont, incrementaly, alignement
2018-02-22 20:28:01 +00:00
Maxime Coste
2c0eba9d95 user-modes: Fix incorrect use of keymap mode
The keymap mode was passed to on_next_key_with_autoinfo, which
means the mapping was applied directly by the InputHandler.

That led to the first key being interpretted as a mapping, then
all following keys being executed normally, as if typed in the
parent mode of the user mapping.
2018-02-19 21:03:29 +11:00
Maxime Coste
fc60e29870 Small code tweaks regarding user modes 2018-02-18 20:24:34 +11:00
Maxime Coste
f88195d2d9 Merge remote-tracking branch 'Delapouite/user-mode' 2018-02-18 20:20:35 +11:00
Delapouite
6b447a0ecb Add declare-user-mode / enter-user-mode commands 2018-02-12 14:19:58 +01:00
Maxime Coste
f3c19ba7fa Prevent whitespaces in command names
Fixes #1843
2018-02-11 20:35:21 +11:00
Maxime Coste
90c16d2b0d Profile the time it takes to source a file
`:source` command will now generate timings if profile is enabled
in the debug option, to help find which script can be slow to load.

This should help for #1823
2018-02-01 09:03:16 +11:00
Maxime Coste
d22c989984 Rename InputModeChange hook to ModeChange
InputModeChange is a bit long to type and its pretty clear in Kakoune
that "Mode" means "Input mode", so use a shorter and as clear name.
2018-01-21 10:34:09 +11:00
Maxime Coste
2366af29e2 Slight refactor of jump collapsing code 2018-01-12 07:50:52 +11:00
Maxime Coste
bf66302d29 Small code style tweak 2018-01-11 13:57:33 +11:00
Maxime Coste
996d8abef4 Write new buffers even when unmodified
Fixes #1794
2018-01-08 09:42:26 +11:00
Maxime Coste
9b83589b18 Completion: Use a heap to gather the best matches instead of sorting
Generalize the behaviour of `shell-candidates` to insert completion,
gather the best 100 matches by using a heap and poping max a hundred
times.
2017-12-21 12:55:29 +11:00
Maxime Coste
e0b28fa421 Introduce InputModeChange hook
InputModeChange <old mode>:<new mode> is intended to replace the various
<Mode>Begin/<Mode>End hooks.

Fixes #1772
2017-12-18 11:09:54 +11:00
Maxime Coste
4b06c09c68 Make edit command work fine when running from an empty context
This way, the kind of context we get from a piped command allows
for opening a buffer and working with it directly.
2017-12-12 18:22:05 +11:00
Maxime Coste
99636c6230 Remove Vector returning split functions, use range adaptor
Do not allocate temporary vectors to store splitted data, use the
'split' range adaptor along with transform(unescape) to provide the
same feature with less allocations.
2017-12-06 17:18:44 +08:00