summaryrefslogtreecommitdiff
path: root/rc/detection/modeline.kak
AgeCommit message (Collapse)Author
2023-06-02rc detection modeline: optimize modeline pre-filteringJohannes Altmanninger
modeline-parse leads by matching an expensive regex against the entire buffer, which can take a long time on huge files. Perl takes too long on this regex and it seems not even ripgrep optimizes the \z component $ ruby -e '10000.times { puts "a" * 10000 }' > big $ time rg --multiline --only-matching '\A(.+\n){1,5}|(.+\n){1,5}\z' big | wc -l 10 __________________________ Executed in 419.81 millis usr time 399.84 millis sys time 20.78 millis where $ time kak big -e q __________________________ Executed in 179.19 millis usr time 133.61 millis sys time 53.50 millis Let's lose the regex. Fixes #4911
2022-10-17rc modeline: fix error trying to write readonly global variableJohannes Altmanninger
When running modeline-parse on this file: # kakoune: filetype=ledger:indentwidth=4 I get this error from dash (and a similar one from bash): sh: 53: readonly: key: is read only This is because the readonly variable "key" is used elsewhere, both times as global. Fix this by making both variables local. While at it, remove an unused variable. Fixes #4478
2022-07-05Make `x` just select the full linesMaxime Coste
`x` is often criticized as hard to predict due to its slightly complex behaviour of selecting next line if the current one is fully selected. Change `x` to use the previous `<a-x>` behaviour, and change `<a-x>` to trim to fully selected lines as `<a-X>` did. Adapt existing indentation script to the new behaviour
2021-12-31modeline-parse: parse `set` and `:` correctlythrowawayaccount12345-1
When `set` or `se` is found at the start of the modeline, it should stop parsing options after `:`. When `modeline-parse` is called in the following file, it should _not_ recognize `tabstop=4` and `invalid_option=3`. ``` # kak: set indentwidth=0 tabstop=16: tabstop=4 invalid_option=3 ``` More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
2020-12-20Use stderr/fail to return errors in modeline.kakMaxime Coste
2020-09-18rc modeline: Print the final command directlyFrank LENORMAND
2020-09-18rc modeline: Factorise the use of `kakquote`Frank LENORMAND
2020-09-18rc modeline: Error out on unsupported formatsFrank LENORMAND
This commit makes `:modeline-parse` grab all lines that look like modelines, and lets the parser deal with invalid formats. This allows actually printing an error on unsupported modelines formats, instead of ignoring them upfront.
2020-09-18rc modeline: Use more idiomatic shellFrank LENORMAND
2020-09-18rc modeline: Print error messages correctlyFrank LENORMAND
2020-09-18rc modeline: Prevent command executionFrank LENORMAND
This commit prevents specially crafted modelines from making the editor execute arbitrary Kakoune commands. By using a tabulation character as a separator, commands can be injected in the value of the options listed in the modeline. For example: # kak: tabstop=2;set-option buffer pwned yes Fixes #3735.
2020-09-16rc modeline: Don't select more lines than configuredFrank LENORMAND
This commit addresses an off-by-one error that selected `modelines`+1 lines when looking for modelines in a buffer. Note that setting `modelines` to 0 will still select one line. Fixes #3733.
2020-08-24Avoid accidentally using environment variables in sh scopesJohannes Altmanninger
On the instances with altfile this was already the case, but this makes it more obvious. Closes #3673
2020-06-03src: Introduce a <percent> named keyFrank LENORMAND
Similarly to the <semicolon> key, make it easier to write `:execute-keys` commands by replacing <percent> with `%`. Highlighters can keep escaping the sign when regular expressions are not quoted, but built-in scripts that use `%` as an editing primitive have been modified to use the named key, for clarity.
2019-11-08rc modeline: Support spelling language optionsFrank LENORMAND
2019-03-21Add categories in rc/Alex Leferry 2
Closes #2783