aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaniel Gorin <jcpetruzza@gmail.com>2020-06-24 18:30:16 +0100
committerRobert Helgesson <robert@rycee.net>2020-08-12 22:44:33 +0200
commitd1f4d1514d6295907759b386d8d7c8d85a864564 (patch)
treeb64cfba1de9e74845eff3d2161c9e3a4cdaa71c2 /modules
parent861690ff29c146172b15aa13188392c295e7f6a9 (diff)
kakoune: escape showWhitespace separators
We were passing the separators for the `show-whitespaces` highlighter verbatim. This was problematic in case one wanted to use, spaces, quotes or `%` as separators since the resulting kakoune configuration would be invalid. According to kakoune's docs, the separator has to be one character long, so we can use a simple rule for escaping them. It is possible that people has been working this around by passing, e.g. `"' '"` as separator in order to get a space (i.e., escaped explicitly by the user), so we just let longer strings be used verbatim. PR #1357
Diffstat (limited to 'modules')
-rw-r--r--modules/programs/kakoune.nix22
1 files changed, 16 insertions, 6 deletions
diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix
index d2fd8eb10a1..3c2349151c1 100644
--- a/modules/programs/kakoune.nix
+++ b/modules/programs/kakoune.nix
@@ -506,12 +506,22 @@ let
];
showWhitespaceOptions = with cfg.config.showWhitespace;
- concatStrings [
- (optionalString (tab != null) " -tab ${tab}")
- (optionalString (tabStop != null) " -tabpad ${tabStop}")
- (optionalString (space != null) " -spc ${space}")
- (optionalString (nonBreakingSpace != null) " -nbsp ${nonBreakingSpace}")
- (optionalString (lineFeed != null) " -lf ${lineFeed}")
+ let
+ quoteSep = sep:
+ if sep == "'" then
+ ''"'"''
+ else if lib.strings.stringLength sep == 1 then
+ "'${sep}'"
+ else
+ sep; # backwards compat, in case sep == "' '", etc.
+
+ in concatStrings [
+ (optionalString (tab != null) " -tab ${quoteSep tab}")
+ (optionalString (tabStop != null) " -tabpad ${quoteSep tabStop}")
+ (optionalString (space != null) " -spc ${quoteSep space}")
+ (optionalString (nonBreakingSpace != null)
+ " -nbsp ${quoteSep nonBreakingSpace}")
+ (optionalString (lineFeed != null) " -lf ${quoteSep lineFeed}")
];
uiOptions = with cfg.config.ui;