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

Can't set ivy-format-function any more #2130

Closed
Lenbok opened this issue Jul 11, 2019 · 7 comments
Closed

Can't set ivy-format-function any more #2130

Lenbok opened this issue Jul 11, 2019 · 7 comments

Comments

@Lenbok
Copy link

@Lenbok Lenbok commented Jul 11, 2019

This used to be a single variable, which I had set to ivy-format-function-line, but now it seems that that ivy-format-function has been obseleted, referring me to ivy-format-functions-alist.

The built-in help for that variable tells me it can be customized, but when I try to customize it there is an error, and the value cannot be customized.

If I try to add (setq ivy-format-functions-alist '((t . ivy-format-function-line))) to my init.el, this makes swiper-isearch crash when I enter the first character, with

Error in post-command-hook (ivy--queue-exhibit): (wrong-type-argument sequencep 5)

How can I set the format function back to the ivy-format-function-line that I had previously?

@lmintmate
Copy link

@lmintmate lmintmate commented Jul 13, 2019

I had the same problem too, because I was using ivy-rich, which recommends the change to ivy-format-function-line. The solution was thankfully recently posted by the author of ivy-rich on its README and it is:

(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)

This has solved the issue for me. Hopefully it'll work for you as well.

@Lenbok
Copy link
Author

@Lenbok Lenbok commented Jul 13, 2019

@lmintmate Thanks for that, swiper-isearch now functions again (although I note that it isn't respecting my choice to use ivy-format-function-line, which is perhaps a separate bug)

@lmintmate
Copy link

@lmintmate lmintmate commented Jul 15, 2019

I looked into this (because I hadn't noticed this was happening until you mentioned it), and it seems that swiper-isearch in particular not using ivy-format-function-line is intentional. Specifically, checking the value of ivy-format-functions-alist with C-h v shows the following values (for me at least):

((counsel-compile-env . counsel-compile-env--format-hint)
 (counsel-colors-web . counsel--colors-web-format-function)
 (counsel-colors-emacs . counsel--colors-emacs-format-function)
 (counsel-evil-registers . counsel--yank-pop-format-function)
 (counsel-yank-pop . counsel--yank-pop-format-function)
 (counsel-git-log . counsel--yank-pop-format-function)
 (counsel-faces . counsel--faces-format-function)
 (swiper-isearch . swiper-isearch-format-function)
 (swiper-multi . swiper--all-format-function)
 (counsel-describe-face . counsel--faces-format-function)
 (t . ivy-format-function-line))

This shows that swiper-isearch uses swiper-isearch-format-function instead (and t presumably is what applies to all other commands not specified in the alist's value). Attempting to set swiper-isearch to ivy-format-function-line, even with the setcdr assq method I posted earlier (like so: (setcdr (assq 'swiper-isearch ivy-format-functions-alist) #'ivy-format-function-line)), breaks swiper-isearch unfortunately. I thus took a look at the swiper-isearch-format-function and it seems to use ivy-format-function-default under the hood (see here). I attempted then to create a custom function modelled after this but replacing default with line, and setting swiper-isearch to that instead, but that didn't work either. Most probably the choice to not use format-function-line for swiper-isearch on the part of the author is because swiper-isearch detects and shows when more than one matches exist on the same line and using format-function-line would obscure their highlighting.

@abo-abo abo-abo closed this in 98127be Jul 15, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 15, 2019

The built-in help for that variable tells me it can be customized, but when I try to customize it there is an error, and the value cannot be customized.

Thanks, this is fixed now.

Most probably the choice to not use format-function-line for swiper-isearch on the part of the author is because swiper-isearch detects and shows when more than one matches exist on the same line and using format-function-line would obscure their highlighting.

You're right, that was my intention.

@Lenbok
Copy link
Author

@Lenbok Lenbok commented Jul 15, 2019

Thanks for the fix @abo-abo. The current swiper result formatting function gives little visual differentiation of the current line. For example, with swiper-isearch results look like this:

image

In contrast, counsel-describe-variable (using ivy-format-function-line) has the visual background extending the full window width:

image

I could make ivy-highlight-face itself stand out more, but how can I make the swiper-isearch background color apply to the full window width?

@Lenbok
Copy link
Author

@Lenbok Lenbok commented Nov 5, 2019

@abo-abo any suggestions for how to get the desired swiper-isearch effect above?

I'm not sure I see how the earlier comment about not allowing a formatting function due to multiple matches on one line is relevant, as counsel-ag highlights multiple matches on one line just fine:
image

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Nov 5, 2019

@Lenbok Please open a new issue with a fresh description of the problem.

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
* ivy.el (ivy-completing-read-handlers-alist):
(ivy-display-functions-alist): Fix type.

Fixes abo-abo#2130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants