swiper icon indicating copy to clipboard operation
swiper copied to clipboard

counsel-ag error message

Open netjune opened this issue 7 years ago • 8 comments

Everytime I run the command counsel-ag, emacs reports the following error message:

Error in post-command-hook (icomplete-post-command-hook): (wrong-number-of-arguments (((ag-prompt) (extra-ag-args) (initial-directory) (initial-input) smex-ido-cache info-lookup-mode t) (string) (counsel-ag-function string counsel-ag-base-command extra-ag-args)) 3)

netjune avatar Nov 16 '17 10:11 netjune

This is a bug with your config, seems you added icomplete-post-command-hook to the post-command-hook list. It's probably via icomplete-mode. Disable icomplete-mode and the bug should disappear.

abo-abo avatar Nov 16 '17 11:11 abo-abo

Yes. When icomplete-mode is disabled, the error message disappears. But there is no completion when I run commands like discribe-function.

netjune avatar Nov 18 '17 10:11 netjune

Put simply, Emacs can use only one global mode for completion: you have to choose between icomplete-mode, ido-mode, ivy-mode, helm-mode etc. So a quick fix is to use ivy-mode instead of icomplete-mode.

If you want to keep icomplete-mode on, but still use counsel-ag, use advice-add:

(defun ivy-icomplete (f &rest r)
  (icomplete-mode -1)
  (unwind-protect
       (apply f r)
    (icomplete-mode 1)))

(advice-add 'ivy-read :around #'ivy-icomplete)

abo-abo avatar Nov 18 '17 11:11 abo-abo

But I'm using ido commands with no error messages while the icomplete-mode is on. Does ido internally run like in your code snippet?

netjune avatar Nov 18 '17 14:11 netjune

Ido and icomplete are in the same code base (core Emacs). Likely, the compatibility issues were taken care of.

abo-abo avatar Nov 18 '17 15:11 abo-abo

Then what about helm-mode? I'm also using helm commands(helm-buffers-list, helm-imenu ...) together with ido and icomplete.

netjune avatar Nov 23 '17 15:11 netjune

Perhaps helm isn't affected by icomplete modifying post-command-hook in the minibuffer.

abo-abo avatar Nov 23 '17 17:11 abo-abo

The advice-add seems to break a few things on emacs 29, but https://github.com/emacsorphanage/helm-ag works beautifully alongside fido.

runekaagaard avatar Dec 02 '23 08:12 runekaagaard