Make dired printable keys start search

ober

d90dc6db307f3f17b926395ffefbb84f906486b3

diff --git a/lib/jerboa-emacs/qt/app.sls b/lib/jerboa-emacs/qt/app.sls
index 614ff9d..c46fd1d 100644
--- a/lib/jerboa-emacs/qt/app.sls
+++ b/lib/jerboa-emacs/qt/app.sls
@@ -1397,7 +1397,9 @@
                                                                                                (cond
                                                                                                  [(dired-buffer?
                                                                                                     buf)
-                                                                                                  (void)]
+                                                                                                  (isearch-start-with-text!
+                                                                                                    app
+                                                                                                    data)]
                                                                                                  [(image-buffer?
                                                                                                     buf)
                                                                                                   (void)]
diff --git a/lib/jerboa-emacs/qt/commands-edit.sls b/lib/jerboa-emacs/qt/commands-edit.sls
index 91e8f71..4c889db 100644
--- a/lib/jerboa-emacs/qt/commands-edit.sls
+++ b/lib/jerboa-emacs/qt/commands-edit.sls
@@ -11,7 +11,8 @@
    isearch-oth-bg-b isearch-highlight-all!
    isearch-find-nearest-forward isearch-find-nearest-backward
    isearch-update! isearch-next! isearch-exit!
-   isearch-handle-key! cmd-search-forward cmd-search-backward
+   isearch-handle-key! cmd-search-forward
+   isearch-start-with-text! cmd-search-backward
    qt-replace-line! cmd-toggle-comment cmd-transpose-chars
    qt-word-at-point cmd-upcase-word cmd-downcase-word
    cmd-capitalize-word cmd-kill-word string-replace-all
@@ -322,6 +323,13 @@
            (current-qt-editor app)))
        (set! *isearch-app* app)
        (echo-message! (app-state-echo app) "I-search: "))
+  (def (isearch-start-with-text! app text)
+       "Enter forward isearch and seed the query with TEXT."
+       (set! *isearch-active* 'forward) (set! *isearch-query* text)
+       (set! *isearch-start-pos*
+         (qt-plain-text-edit-cursor-position
+           (current-qt-editor app)))
+       (set! *isearch-app* app) (isearch-update! app))
   (def (cmd-search-backward app)
        "Enter incremental search backward mode."
        (set! *isearch-active* 'backward) (set! *isearch-query* "")
diff --git a/lib/jerboa-emacs/qt/commands.sls b/lib/jerboa-emacs/qt/commands.sls
index 984baa6..87fb04a 100644
--- a/lib/jerboa-emacs/qt/commands.sls
+++ b/lib/jerboa-emacs/qt/commands.sls
@@ -7,9 +7,10 @@
    qt-open-image-inline! *qt-app-ptr* *terminal-widget-map*
    *terminal-views-map* terminal-view-for-container
    terminal-ensure-view! qt-kill-ring-push! *isearch-active*
-   isearch-handle-key! *qreplace-active* qreplace-handle-key!
-   recent-files-add! recent-files-load! bookmarks-load!
-   session-save! session-restore-files *tab-bar-visible*
+   isearch-handle-key! isearch-start-with-text!
+   *qreplace-active* qreplace-handle-key! recent-files-add!
+   recent-files-load! bookmarks-load! session-save!
+   session-restore-files *tab-bar-visible*
    *auto-revert-tail-buffers* *file-mtimes* file-mtime-record!
    file-mtime-changed? *eldoc-mode* eldoc-display!
    *current-theme* *themes* theme-stylesheet load-theme!
diff --git a/src/jerboa-emacs/core.ss b/src/jerboa-emacs/core.ss
index 9293c69..830d3fb 100644
--- a/src/jerboa-emacs/core.ss
+++ b/src/jerboa-emacs/core.ss
@@ -357,6 +357,7 @@
       '(("n" . next-line) ("p" . previous-line) ("g" . revert-buffer)
         ("d" . dired-do-delete) ("R" . dired-do-rename) ("C" . dired-do-copy)
         ("+" . dired-create-directory) ("q" . kill-buffer-cmd) ("^" . dired)
+        ("/" . search-forward)
         ("m" . dired-mark) ("u" . dired-unmark) ("U" . dired-unmark-all)
         ("t" . dired-toggle-marks) ("D" . dired-do-delete-marked) ("x" . dired-do-delete-marked)))
     (mode-keymap-set! 'dired km))
diff --git a/src/jerboa-emacs/qt/app.ss b/src/jerboa-emacs/qt/app.ss
index f0c6f2a..d1389a5 100644
--- a/src/jerboa-emacs/qt/app.ss
+++ b/src/jerboa-emacs/qt/app.ss
@@ -1276,8 +1276,10 @@
                                                   (and cc (integer->char cc)))))
                                  (n (get-prefix-arg app))) ; Get prefix arg
                             (cond
-                              ;; Suppress in dired and image buffers
-                              ((dired-buffer? buf) (void))
+                              ;; Dired is read-only, but unbound printable keys should still be useful:
+                              ;; use them as type-to-search instead of dropping them.
+                              ((dired-buffer? buf)
+                               (isearch-start-with-text! app data))
                               ((image-buffer? buf) (void))
                               ;; In REPL buffers, only allow after the prompt
                               ((repl-buffer? buf)
diff --git a/src/jerboa-emacs/qt/commands-edit.ss b/src/jerboa-emacs/qt/commands-edit.ss
index 8b6e89b..f3027ea 100644
--- a/src/jerboa-emacs/qt/commands-edit.ss
+++ b/src/jerboa-emacs/qt/commands-edit.ss
@@ -276,6 +276,14 @@
   (set! *isearch-app* app)
   (echo-message! (app-state-echo app) "I-search: "))
 
+(def (isearch-start-with-text! app text)
+  "Enter forward isearch and seed the query with TEXT."
+  (set! *isearch-active* 'forward)
+  (set! *isearch-query* text)
+  (set! *isearch-start-pos* (qt-plain-text-edit-cursor-position (current-qt-editor app)))
+  (set! *isearch-app* app)
+  (isearch-update! app))
+
 (def (cmd-search-backward app)
   "Enter incremental search backward mode."
   (set! *isearch-active* 'backward)
diff --git a/src/jerboa-emacs/qt/commands.ss b/src/jerboa-emacs/qt/commands.ss
index 10eb584..3d5da5c 100644
--- a/src/jerboa-emacs/qt/commands.ss
+++ b/src/jerboa-emacs/qt/commands.ss
@@ -13,6 +13,7 @@
         qt-kill-ring-push!
         *isearch-active*
         isearch-handle-key!
+        isearch-start-with-text!
         *qreplace-active*
         qreplace-handle-key!
         recent-files-add!
diff --git a/tests/test-tier0.ss b/tests/test-tier0.ss
index 627f9da..cfe964e 100644
--- a/tests/test-tier0.ss
+++ b/tests/test-tier0.ss
@@ -160,6 +160,10 @@
     (check-true "dired-listing-vector" (vector? entries))
     (check "dired-listing-path-count" (vector-length entries) expected-paths)))
 
+(let ((buf (make-buffer "tests/" "tests" #f #f #f 'dired #f)))
+  (setup-mode-keymaps!)
+  (check "dired-slash-search-binding" (mode-keymap-lookup buf "/") 'search-forward))
+
 ;;; ========================================================================
 ;;; org-parse.sls
 ;;; ========================================================================