Commit Graph

15 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
Frank LENORMAND
ab2eade28d rc: Synchronize important file writes
Fixes #2178
2018-07-04 09:55:05 +03:00
Tim Allen
3d0c19f8fb Prevent the :format command from triggering hooks.
The :format command is often called from a BufWritePre hook to format the
current buffer, however the :format command itself calls `:write` to store the
buffer in a temporary location, potentially causing an infinite recursion.

If we disable hooks while running :format, there's no danger of that occurring.
2018-06-20 21:11:58 +10:00
Frank LENORMAND
9127ed0d55 src rc: Rename exec/eval into execute-keys/evaluate-commands 2017-11-03 11:09:45 +03:00
Frank LENORMAND
c9b280b712 rc: Don't use command aliases to highlight keywords properly 2017-11-03 10:34:41 +03:00
Maxime Coste
9c4448ac41 Remove echo -color support, superseeded by echo -markup
`echo -color Error "blah"` is the same as `echo -markup '{Error}blah'`
Fixes #1512
2017-07-19 17:18:52 +02:00
Frank LENORMAND
74babc36b1 rc formatter: Don't force selection restoration
The `|` primitive now correctly restores selections, we don't need to
forcibly restore the main one after formatting anymore.
2017-07-14 11:21:48 +03:00
Delapouite
a932b6b21e Add error message when using format command with no formatcmd specified 2017-06-26 22:10:04 +02:00
Frank LENORMAND
6376aa6206 rc formatter: Make sure the formatter returned successfully
The previous implementation used to replace the contents of the buffer with
whatever the `formatcmd` was returning, regardless of the exit code of the
command, which led to the buffer being wiped out on error.

This commit does the formatting in a temporary file, and only replaces the
current buffer with the contents of the -formatted- temporary file if the
`formatcmd` returned successfully.

Fixes #1357
2017-06-23 15:12:23 +03:00
Frank LENORMAND
b9cdccd53a rc: Document non-hidden options with -docstring 2017-05-16 14:35:43 +03:00
Frank LENORMAND
f6a2925950 Fix, complete and add docstring documentation to builtin commands
Level out the builtin commands loaded at startup in terms of format and
expressiveness. The following convention was followed:
* commands that take more than one argument have to be described along
  with their parameters prior to the actual documentation, otherwise the
  docstring consists in a capitalized sentence
  e.g. `command <arg1>: do something`
* optional arguments are enclosed in square brackets, to comply with the
  format used for hardcoded commands
  e.g. `cd [<directory>]`
* describe the effects of the command in the documentation string and
  omit implementation details unless they are relevant. Usually command
  names include the name of the tool they use, so they don't need to be
  redundantly mentioned
  e.g. `tmux-new-pane <arguments>: open a new pane`
* document the format the parameters to the commands, or list them if
  they are to be chosen among a list of static values (c.f. `spell.kak`)
2016-10-11 10:26:17 +03:00
Kylie McClain
3ec0cbd07a formatter.kak: Use sed rather than ${variable//string/replacement}
Using ${variable//string/replacement} is a bash extension, it is not part
of POSIX shell scripting.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
2016-09-21 19:54:17 -04:00
Frank LENORMAND
a20f5fc6a2 Pass a generic pattern to printf calls, use echo when possible 2016-04-23 10:00:36 +03:00
Frank LENORMAND
84a21f8cfb Replace non POSIX calls to echo with printf %s 2016-04-23 09:56:53 +03:00
Maxime Coste
fef0277998 Reorganise rc/ into subdirectories
* core: set of tools to work on kakoune source code
 * base: very common languages and tools
 * extra: less common languages and tools
2016-01-29 09:03:23 +00:00