ericdanan/counsel-projectile

Use ivy-display-functions-alist?

gcv opened this issue · 2 comments

gcv commented

Maybe I'm missing something, but I can't make counsel-projectile-* functions work with ivy-display-functions-alist. For example, I have the following function which forces Ivy/Counsel to display in the current window rather than the minibuffer:

(defun /ivy-display-function-window (text)
  (let ((buffer (get-buffer-create "*ivy-candidates*"))
        (str (with-current-buffer (get-buffer-create " *Minibuf-1*")
               (let ((point (point))
                     (string (concat (buffer-string) "  " text)))
                 (ivy-add-face-text-property (- point 1) point 'ivy-cursor string t)
                 string))))
    (with-current-buffer buffer
      (let ((inhibit-read-only t))
        (erase-buffer)
        (insert str)
        (goto-char (point-min))
        (setq-local cursor-type nil)))
    (with-ivy-window
      (display-buffer
       buffer
       `((display-buffer-reuse-window
          display-buffer-below-selected)
         (window-height . ,(ivy--height (ivy-state-caller ivy-last))))))))

Then I tell Ivy to use this function:

(setq ivy-display-functions-alist
      '((ivy-completion-in-region . ivy-display-function-overlay)
        (counsel-M-x . /ivy-display-function-window)
        (counsel-yank-pop . /ivy-display-function-window)
        (t . nil)))

This works. But if I try to modify ivy-display-functions-alist to make counsel-projectile-ag use /ivy-display-function-window, it ignores the setting:

(setq ivy-display-functions-alist
      '((ivy-completion-in-region . ivy-display-function-overlay)
        (counsel-M-x . /ivy-display-function-window)
        (counsel-yank-pop . /ivy-display-function-window)
        (counsel-projectile-ag . /ivy-display-function-window)
        (t . nil)))

It'd be really nice to have this work. :)

That could be because counsel-projectile-ag does not call ivy-read directly but instead calls counsel-ag. Can you try replacing counsel-projectile-ag with counsel-ag in ivy-display-functions-alist?

gcv commented

Cool! That was it. Thank you.