Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struggeling to rebind "C-s" in ctrlf-minibuffer-mode-map #131

Open
johannes-mueller opened this issue Jun 14, 2024 · 0 comments
Open

Struggeling to rebind "C-s" in ctrlf-minibuffer-mode-map #131

johannes-mueller opened this issue Jun 14, 2024 · 0 comments

Comments

@johannes-mueller
Copy link

johannes-mueller commented Jun 14, 2024

I've been using vanilla iserarch and bound C-s in isearch-mode to consult-line like so

(define-key isearch-mode-map (kbd "C-s") 'consult-line)

That enables me to switch to consult-line search when the usual isearch gets to far.

Now I wanted to it similarly with ctlrf and tried this:

(use-package ctrlf
  :bind (:map ctrlf-minibuffer-mode-map
              ("<down>" . ctrlf-next-match)
              ("<up>" . ctrlf-previous-match)
              ("C-<down>" . ctrlf-last-match)
              ("C-<up>" . ctrlf-first-match)
              ("C-s" . 'consult-line))
  :init (ctrlf-mode 1))

but for some reason the C-s key is not bound to consult-line but still does ctrlf-next-match.

Any ideas how to solve this?

I tried also

(define-key ctrlf-minibuffer-mode-map (kbd "C-s") 'consult-line)

but that did not help either.

Edit:

It turns out to be a bit more complicated. You can't just call consult-line from within the minibuffer. You can use this hack wrap the consult-line call in. Working around the original issue and binding it to C-S-s instead of C-s it looks like this:

(use-package ctrlf
  :bind (:map ctrlf-minibuffer-mode-map
              ("<down>" . ctrlf-next-match)
              ("<up>" . ctrlf-previous-match)
              ("C-<down>" . ctrlf-last-match)
              ("C-<up>" . ctrlf-first-match)
              ("M-<down>" . ctrlf-forward-alternate)
              ("M-<up>" . ctrlf-backward-alternate)
              ("C-S-s" . 'johmue/quit-search-and-consult-line))
  :init (ctrlf-mode 1))


(defun johmue/quit-search-and-consult-line ()
  (interactive)
  (put 'quit 'error-message "")
  (run-at-time nil nil
               (lambda ()
                 (put 'quit 'error-message "Quit")
                 (consult-line ctrlf--last-input)))
  (abort-recursive-edit))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant