radian-software / prescient.el

☄️ Simple but effective sorting and filtering for Emacs.
MIT License
614 stars 25 forks source link

Fix 'wrong-type-argument' error with ivy-prescient #119

Closed Hirozy closed 2 years ago

Hirozy commented 2 years ago

ivy doesn't convert all variables to string when sorting or calling prescient-remember, so it need to preprocess when work with ivy-prescient.el. if not, a wrong-type-argument error may occur.

Hirozy commented 2 years ago

With format-all, if more than one formatter is available for a major-mode, such as c++-mode, which has two formatters, clang-format and astyle, the following error will occur when calling the format-all-buffer command.

Debugger entered--Lisp error: (wrong-type-argument sequencep astyle)
  prescient-sort-compare(astyle clang-format)
  ivy-prescient-sort-function((astyle) (clang-format))
  sort(((clang-format)) ivy-prescient-sort-function)
  ivy--reset-state(#s(ivy-state :prompt "Formatter for C++: " :collection ((clang-format) (astyle)) :predicate nil :require-match t :initial-input nil :history nil :preselect nil :keymap nil :update-fn nil :sort t :frame #<frame  *Minibuf-1* 0x154b8ba30> :window #<window 3 on test_lsp.cc> :buffer #<buffer test_lsp.cc> :text nil :action (1 ("o" identity "default") ("i" ivy--action-insert "insert") ("w" ivy--action-copy "copy")) :unwind nil :re-builder orderless-ivy-re-builder :matcher nil :dynamic-collection nil :display-transformer-fn nil :directory "lsp/src/" :caller format-all-buffer :current nil :def nil :ignore t :multi-action nil :extra-props (:caller ivy-completing-read)))
  #<subr ivy-read>("Formatter for C++: " ((clang-format) (astyle)) :predicate nil :require-match t :initial-input nil :preselect nil :def nil :history nil :keymap nil :dynamic-collection nil :extra-props (:caller ivy-completing-read) :caller format-all-buffer :sort t)
  apply(#<subr ivy-read> ("Formatter for C++: " ((clang-format) (astyle)) :predicate nil :require-match t :initial-input nil :preselect nil :def nil :history nil :keymap nil :dynamic-collection nil :extra-props (:caller ivy-completing-read) :caller format-all-buffer :sort t))
  ivy-read("Formatter for C++: " ((clang-format) (astyle)) :predicate nil :require-match t :initial-input nil :preselect nil :def nil :history nil :keymap nil :dynamic-collection nil :extra-props (:caller ivy-completing-read) :caller format-all-buffer)
  ivy-completing-read("Formatter for C++: " ((clang-format) (astyle)) nil t nil nil nil nil)
  format-all--prompt-for-formatter("C++")
  format-all--buffer-or-region(t nil)
  format-all-buffer(t)
  funcall-interactively(format-all-buffer t)
  command-execute(format-all-buffer record)
  counsel-M-x-action("format-all-buffer")
  #f(compiled-function (x) #<bytecode -0x184d58c4805416c0>)("format-all-buffer")
  ivy-call()
  #<subr ivy-read>("M-x " [company-box--max lsp-make-signature-help-options vc-src-responsible-p lsp:omnisharp-run-tests-in-class-request-column tramp-sudoedit-file-name-handler lsp-pwsh-help-completion evil-want-Y-yank-to-eol lsp-watch-kind? python-nav-beginning-of-defun-regexp access-label :maxLength c-electric-lt-gt semantic-c-debug-mode-init-last-mode yas-x-prompt lib-target dired-unmark-all-marks flycheck-mode-line-prefix cl-struct-flycheck-syntax-check-tags haskell-font-lock--put-face-on-type-or-constructor f-ancestor-of? files--splice-dirname-file lsp-perlnavigator eshell-return-exits-minibuffer :EndLineNumber awesome-tab-mode-hook c-make-ml-string-opener-re-function traversed company-box--handle-scroll kmacro-pop-ring1 which-key--stop-timer c-list-found-types flycheck-pug-executable lsp-elixir-suggest-specs xref--push-markers vc-bzr-shelve-menu WatchKind lsp:set-rename-params-uri? lsp-pyls-plugins-flake8-hang-closing lsp-pylsp-plugins-rope-completion-enabled lsp--virtual-buffer lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets lsp-lua-hint-enable dash-expand:&JSONResponse? TeX-command-default zoo calcFunc-erfc xref-group angle-bracket-arglist-escape tramp-handle-make-auto-save-file-name puny-encode-digit ...] :predicate #f(compiled-function (sym) #<bytecode -0xd814029039faa09>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x :sort t)
  apply(#<subr ivy-read> ("M-x " [company-box--max lsp-make-signature-help-options vc-src-responsible-p lsp:omnisharp-run-tests-in-class-request-column tramp-sudoedit-file-name-handler lsp-pwsh-help-completion evil-want-Y-yank-to-eol lsp-watch-kind? python-nav-beginning-of-defun-regexp access-label :maxLength c-electric-lt-gt semantic-c-debug-mode-init-last-mode yas-x-prompt lib-target dired-unmark-all-marks flycheck-mode-line-prefix cl-struct-flycheck-syntax-check-tags haskell-font-lock--put-face-on-type-or-constructor f-ancestor-of? files--splice-dirname-file lsp-perlnavigator eshell-return-exits-minibuffer :EndLineNumber awesome-tab-mode-hook c-make-ml-string-opener-re-function traversed company-box--handle-scroll kmacro-pop-ring1 which-key--stop-timer c-list-found-types flycheck-pug-executable lsp-elixir-suggest-specs xref--push-markers vc-bzr-shelve-menu WatchKind lsp:set-rename-params-uri? lsp-pyls-plugins-flake8-hang-closing lsp-pylsp-plugins-rope-completion-enabled lsp--virtual-buffer lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets lsp-lua-hint-enable dash-expand:&JSONResponse? TeX-command-default zoo calcFunc-erfc xref-group angle-bracket-arglist-escape tramp-handle-make-auto-save-file-name puny-encode-digit ...] :predicate #f(compiled-function (sym) #<bytecode -0xd814029039faa09>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x :sort t))
  ivy-read("M-x " [company-box--max lsp-make-signature-help-options vc-src-responsible-p lsp:omnisharp-run-tests-in-class-request-column tramp-sudoedit-file-name-handler lsp-pwsh-help-completion evil-want-Y-yank-to-eol lsp-watch-kind? python-nav-beginning-of-defun-regexp access-label :maxLength c-electric-lt-gt semantic-c-debug-mode-init-last-mode yas-x-prompt lib-target dired-unmark-all-marks flycheck-mode-line-prefix cl-struct-flycheck-syntax-check-tags haskell-font-lock--put-face-on-type-or-constructor f-ancestor-of? files--splice-dirname-file lsp-perlnavigator eshell-return-exits-minibuffer :EndLineNumber awesome-tab-mode-hook c-make-ml-string-opener-re-function traversed company-box--handle-scroll kmacro-pop-ring1 which-key--stop-timer c-list-found-types flycheck-pug-executable lsp-elixir-suggest-specs xref--push-markers vc-bzr-shelve-menu WatchKind lsp:set-rename-params-uri? lsp-pyls-plugins-flake8-hang-closing lsp-pylsp-plugins-rope-completion-enabled lsp--virtual-buffer lsp-typescript-format-insert-space-after-opening-and-before-closing-nonempty-brackets lsp-lua-hint-enable dash-expand:&JSONResponse? TeX-command-default zoo calcFunc-erfc xref-group angle-bracket-arglist-escape tramp-handle-make-auto-save-file-name puny-encode-digit ...] :predicate #f(compiled-function (sym) #<bytecode -0xd814029039faa09>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  command-execute(counsel-M-x)

This PR can fix such problems.