From c18630295ca074b801aa8a4ad1f9004ba8cf44f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= <p@janouch.name>
Date: Wed, 7 Oct 2020 20:49:58 +0200
Subject: README.adoc: add configuration for elvish

And remove it from the "similar software" section.

Our relationship has progressed.

Other unusual shells I've checked before I gave up:
 - nushell lacks the ability to bind keys to user functions
 - yash can but is otherwise way too basic
---
 README.adoc | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

(limited to 'README.adoc')

diff --git a/README.adoc b/README.adoc
index b9ddbd5..103078c 100644
--- a/README.adoc
+++ b/README.adoc
@@ -124,6 +124,35 @@ bind -x '"\201": sdn-restore'
 bind '"\eo":"\200\C-m\201"'
 ----
 
+elvish
+~~~~~~
+To start using this navigator, put the following in your 'rc.elv':
+
+----
+use str
+edit:insert:binding[Alt-o] = {
+  local:reesc = [posix]{ str:replace "'\\''"  "''" $posix }
+  local:posix = [cmd]{ eval ($reesc $cmd)" </dev/tty >/dev/tty 2>&1" }
+
+  # XXX: the -dot is not a stable API, and may hence break soon
+  local:buffer = $edit:current-command
+  local:cursor = (str:to-codepoints $buffer[0..$edit:-dot] | count)
+  local:ns = (ns [&])
+  while ?(eval ($reesc (sdn $buffer $cursor |
+    sed 's/^local //' | slurp)) &ns=$ns) {
+    if (not-eq $ns[cd] "") { cd $ns[cd] }
+    if (not-eq $ns[insert] "") { edit:insert-at-dot $ns[insert]" " }
+    if (or (eq $ns[helper] "") (not ?($posix $ns[helper]))) { break }
+  }
+  edit:redraw &full=$true
+}
+----
+
+This shell is absolutely perverse.  And so is integrating 'sdn' into it because
+it already includes a custom file manager, bound to Ctrl-N (though I find
+the ranger-like interface confusing and resource-demanding).  Version 0.14.1 or
+newer is required.
+
 Configuration
 -------------
 
@@ -168,12 +197,6 @@ be hacked around in 'mc.ext' by turning on the `nroff` switch for a custom file
 extension, just without actually invoking 'nroff'), and thus it can't show the
 program help.  'sdn' is currently optimised for 'less' as the pager.
 
-Similar software
-----------------
- * https://elvish.io/ is an entire shell with an integrated ranger-like file
-   manager on Ctrl-N (I find this confusing and resource-demanding, preferring
-   to keep closer to "orthodox file managers")
-
 Contributing and Support
 ------------------------
 Use https://git.janouch.name/p/sdn to report any bugs, request features,
-- 
cgit v1.2.3

