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

Disconnect between swiper and ivy-read API #53

Closed
stsquad opened this issue Apr 22, 2015 · 4 comments
Closed

Disconnect between swiper and ivy-read API #53

stsquad opened this issue Apr 22, 2015 · 4 comments

Comments

@stsquad
Copy link
Contributor

stsquad commented Apr 22, 2015

I have both swiper and ivy loading from MELPA so they are both bleeding edge. However swiper failed to launch citing:

swiper--ivy: Wrong number of arguments: (2 . 6), 7 [2 times]

It looks like the call to ivy passed one too many arguments. I patched the function to do:

(defun swiper--ivy (&optional initial-input)
  "`isearch' with an overview using `ivy'.
When non-nil, INITIAL-INPUT is the initial search pattern."
  (interactive)
  (swiper--init)
  (let ((candidates (swiper--candidates))
        (preselect (format
                    swiper--format-spec
                    (line-number-at-pos)
                    (regexp-quote
                     (buffer-substring-no-properties
                      (line-beginning-position)
                      (line-end-position)))))
        res)
    (unwind-protect
         (setq res (ivy-read
                    (replace-regexp-in-string
                     "%s" "pattern: " swiper--format-spec)
                    candidates
                    initial-input
                    swiper-map
                    preselect
                    #'swiper--update-input-ivy))
      (swiper--cleanup)
      (if (null ivy-exit)
          (goto-char swiper--opoint)
        (swiper--action res ivy-text)))))

Basically I just dropped the nil in (ivy-read ...) and now it works.

@abo-abo
Copy link
Owner

abo-abo commented Apr 22, 2015

The current state is this one:

(setq res (ivy-read
           (replace-regexp-in-string
            "%s" "pattern: " swiper--format-spec)
           candidates
           :initial-input initial-input
           :keymap swiper-map
           :preselect preselect
           :require-match t
           :update-fn #'swiper--update-input-ivy))

Make sure to remove the old ivy package. ivy.el was merged into the swiper package because of an issue in GNU ELPA.

@stsquad
Copy link
Contributor Author

stsquad commented Apr 22, 2015

A bit of digging shows that swipper packages it's own ivy but I also have an ivy package (I assume pulled in by something else) which is subtly different. Specifically this:

(defun ivy-read (prompt collection
                 &optional initial-input keymap preselect update-fn)

vs

(defun ivy-read (prompt collection
                 &optional predicate initial-input keymap preselect update-fn sort)

@stsquad
Copy link
Contributor Author

stsquad commented Apr 22, 2015

@abo-abo ahh crossing comments - OK I'll do that. I wonder why package.el didn't do it automatically?

@stsquad stsquad closed this as completed Apr 22, 2015
@abo-abo
Copy link
Owner

abo-abo commented Apr 22, 2015

I wonder why package.el didn't do it automatically?

I guess it doesn't have that option yet.

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

2 participants