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

How to override isearch-complete1 so that it uses ivy? #1882

Closed
Alexander-Shukaev opened this issue Jan 9, 2019 · 9 comments
Closed

How to override isearch-complete1 so that it uses ivy? #1882

Alexander-Shukaev opened this issue Jan 9, 2019 · 9 comments

Comments

@Alexander-Shukaev
Copy link

(defun isearch-complete1 ()
  ;; Helper for isearch-complete and isearch-complete-edit
  ;; Return t if completion OK, nil if no completion exists.
  (let* ((ring (if isearch-regexp regexp-search-ring search-ring))
         (completion-ignore-case case-fold-search)
         (completion (try-completion isearch-string ring)))
    (cond
     ((eq completion t)
      ;; isearch-string stays the same
      t)
     ((or completion ; not nil, must be a string
	  (= 0 (length isearch-string))) ; shouldn't have to say this
      (if (equal completion isearch-string)  ;; no extension?
	  (progn
	    (if completion-auto-help
		(with-output-to-temp-buffer "*Isearch completions*"
		  (display-completion-list
		   (all-completions isearch-string ring))))
	    t)
	(and completion
	     (setq isearch-string completion))))
     (t
      (message "No completion") ; waits a second if in minibuffer
      nil))))

Is there any way to advise or override it to filter candidates via ivy (similar to how completion-at-point does it)?

@abo-abo
Copy link
Owner

abo-abo commented Feb 6, 2019

What are you trying to achieve? What's the sequence of keys and commands you use?

@Alexander-Shukaev
Copy link
Author

One can do isearch-forward, then either isearch-complete or isearch-edit-string followed by isearch-complete-edit. This would eventually trigger the function pasted above isearch-complete1. That function of course does not behave in ivy flavor because this is yet to be implemented. I'm looking for a way to do it in a manner consistent with how, e.g. completion-at-point, was given ivy flavor.

@abo-abo
Copy link
Owner

abo-abo commented Feb 6, 2019

Please add a sequence of key bindings so I can experiment with it a bit.

@Alexander-Shukaev
Copy link
Author

That's a bit tricky because I don't use standard Emacs key bindings at all. But looking through the default keymaps, I see that C-sM-eM-TAB would get you to isearch-complete-edit.

@basil-conto
Copy link
Collaborator

Is there any way to advise or override it to filter candidates via ivy

If you really want to you can advise isearch-complete1 to temporarily advise display-completion-list, play around with temp-buffer-show-function, etc. Either way, I think your efforts would be better spent submitting an Emacs feature request for isearch to (re)use completion-in-region or similar.

@Alexander-Shukaev
Copy link
Author

You're probably right.

@abo-abo
Copy link
Owner

abo-abo commented Apr 4, 2019

I agree with @basil-conto here. Closing.

@abo-abo abo-abo closed this as completed Apr 4, 2019
@Alexander-Shukaev
Copy link
Author

See bug#39015.

@abo-abo
Copy link
Owner

abo-abo commented Jan 8, 2020

@Alexander-Shukaev Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants