0

Many interactive functions generate lisp errors depending on the function name when using ivy and lsp and debugging it is difficult (in part because of the bytecode compile-function references). This appears due to some interaction with ivy and/or lsp and so is complicated. I'd just like to figure out, for interactive functions I write, how to avoid this. 1) Is there a way to turn off ivy in an interactive function so this doesn't happen? 2) Is there a way to determine what function names cause problems?

The following code is an example. (It also happens for functions named bi and bib. It appears to me the problem is related to the execute-extended-command--shorter which is a native-comp-function in simple.el). The first, when called by name M-x function-name, executes, the second generates an error.

(defun ai ()
  (interactive)
  (message "Command: %S" this-command))
;; This generates a lisp error
(defun aii ()
  (interactive)
  (message "Command %S" this-command))

With the error:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  completion--nth-completion(1 nil (lsp-uninstall-servers blink-cursor-mode lsp-inline-completion-mode vc-bzr-shelve-apply delete-selection-repeat-replace-region slime-inspector-pop network-connection-to-service Buffer-menu-view gnus-treat-newsgroups-picon ess-indent-command Rd-submit-bug-report package-reinstall find-function-on-key-other-window slime-macroexpansion-minor-mode org-id-get-create info make-frame-on-current-monitor iedit-mode-from-isearch kmacro-bind-to-key mml-secure-sign-pgpauto hydra-ivy/ivy-unmark prog-fill-reindent-defun slime-M-.-presentation-at-mouse pp-28 calendar-coptic-print-date cwarn-mode bs-mark-current slime-next-location lsp-treemacs-references eldoc-print-current-symbol-info ess-rutils-mode-menu conf-space-mode tab-new-to slime-previous-presentation magit-gitignore-in-subdir makefile-makepp-mode facemenu-remove-face-props morse-region ess-insert-assign bs-mode ffap-read-only-other-window nerd-icons-install-fonts strokes-describe-stroke set-rectangular-region-anchor calendar-goto-info-node archive-unmark-all-files kmacro-end-and-call-macro org-tbl-menu orgtbl-hijacker-command-14 quoted-insert ...) nil 4 nil)
  completion-try-completion(nil (lsp-uninstall-servers blink-cursor-mode lsp-inline-completion-mode vc-bzr-shelve-apply delete-selection-repeat-replace-region slime-inspector-pop network-connection-to-service Buffer-menu-view gnus-treat-newsgroups-picon ess-indent-command Rd-submit-bug-report package-reinstall find-function-on-key-other-window slime-macroexpansion-minor-mode org-id-get-create info make-frame-on-current-monitor iedit-mode-from-isearch kmacro-bind-to-key mml-secure-sign-pgpauto hydra-ivy/ivy-unmark prog-fill-reindent-defun slime-M-.-presentation-at-mouse pp-28 calendar-coptic-print-date cwarn-mode bs-mark-current slime-next-location lsp-treemacs-references eldoc-print-current-symbol-info ess-rutils-mode-menu conf-space-mode tab-new-to slime-previous-presentation magit-gitignore-in-subdir makefile-makepp-mode facemenu-remove-face-props morse-region ess-insert-assign bs-mode ffap-read-only-other-window nerd-icons-install-fonts strokes-describe-stroke set-rectangular-region-anchor calendar-goto-info-node archive-unmark-all-files kmacro-end-and-call-macro org-tbl-menu orgtbl-hijacker-command-14 quoted-insert ...) nil 4)
  execute-extended-command--shorter("bii" #("bii\ndescribe-bindings (C-h b)\norg-babel-describe-bindings\norg-mobile-push\ntabify\nbi\nbiblio-crossref-lookup\nisearch-describe-bindings\nbinhex-decode-region\norg-toggle-custom-properties-visibility" 4 13 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 13 15 (face ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 15 21 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 21 29 (face completions-annotations) 30 49 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 49 51 (face ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 51 57 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 58 64 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 64 66 (face ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 66 73 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 74 76 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 76 78 (face ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 78 80 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 81 83 (face ((:foreground "black") (background-color . "#6a3888a1a246") . ivy-minibuffer-match-face-2) mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 84 86 (face ivy-minibuffer-match-face-2 mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) 86 106 (mouse-face ivy-minibuffer-match-highlight help-echo ivy--help-echo) ...))
  #f(compiled-function () #<bytecode 0x10d8faac5e79605c>)()
  apply(#f(compiled-function () #<bytecode 0x10d8faac5e79605c>) nil)
  timer-event-handler([t 26762 56464 109620 nil #f(compiled-function () #<bytecode 0x10d8faac5e79605c>) nil nil 0 nil])
1
  • 1
    I suspect that string is nil in that last stack frame. Strings are arrays, so something like (substring nil) produces (wrong-type-argument arrayp nil). There are several function calls in completion--nth-completion passing string as an argument, but you're probably more interested in where it comes from in the first place which, as you've already figured, seems to be execute-extended-command--shorter. I suggest you instrument that function for edebug and step through the execution to find out what's happening. See C-h i g (elisp)Edebug Commented Jul 31 at 5:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.