helm-company icon indicating copy to clipboard operation
helm-company copied to clipboard

Company: An error occurred in post-command

Open atreyasha opened this issue 4 years ago • 2 comments

Hi, thank you for developing this awesome package. Just have a quick question in regards to an error message I receive when executing helm-company.

When I execute helm-company via a keybinding, I am able to view completion candidates. After selecting a candidate (successfully), I receive the following error message: Wrong type argument: number-or-marker-p, nil.

In my *Messages* buffer, I see the following error messages:

Company: An error occurred in post-command
Wrong type argument: number-or-marker-p, nil

I noticed the following segment which seems to address this issue:

https://github.com/Sodel-the-Vociferous/helm-company/blob/6eb5c2d730a60e394e005b47c1db018697094dde/helm-company.el#L127-L137

However, I am unsure as to why I still receive this error message. Any insights or suggestions?

Below are my (relevant) emacs specifications:

emacs: 27.1 (spacemacs develop branch: https://github.com/syl20bnr/spacemacs/commit/c629534013f7fb7690a68e47356e19adcc5fc079) company: company-20201120.1115 helm-company: helm-company-20190812.1429

atreyasha avatar Nov 29 '20 21:11 atreyasha

Unsure why this was closed. Did you solve the issue?

Personally I'm still experiencing this.

AndreaOrru avatar Mar 01 '22 02:03 AndreaOrru

It may have been my lack of a reply. I apologize for that.

I will try to reproduce this issue in the coming days.

Sodel-the-Vociferous avatar Mar 01 '22 03:03 Sodel-the-Vociferous

I cannot reproduce this, unfortunately. I have the latest packages that I can get on emacs-29.1.

Any idea of how I can reproduce this issue so I can solve it? Or, can anyone give me a backtrace after running `toggle-debug-on-error'?

Sodel-the-Vociferous avatar Nov 07 '23 23:11 Sodel-the-Vociferous

Updated to Emacs 29.1 along with latest package versions as of today. Can still reproduce the error.

MWE

  1. Copy the emacs configuration below, eg. to ~/test/init.el.

    ;;------------------------------------------------------------------------------
    ;; use-package and quelpa
    ;;------------------------------------------------------------------------------
    
    ;; setup archives
    (require 'package)
    (setq package-user-dir (file-name-directory (or load-file-name (buffer-file-name))))
    (add-to-list 'package-archives '("gnu"   . "https://elpa.gnu.org/packages/"))
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
    (package-initialize)
    
    ;; setup use-package
    (unless (package-installed-p 'use-package)
      (package-refresh-contents)
      (package-install 'use-package))
    (eval-and-compile
      (setq use-package-always-ensure t
            use-package-expand-minimally t))
    
    ;; setup quelpa
    (unless (package-installed-p 'quelpa)
      (with-temp-buffer
        (url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
        (eval-buffer)
        (quelpa-self-upgrade)))
    (quelpa '(helm-company :fetcher git
                             :url "https://github.com/Sodel-the-Vociferous/helm-company"
                             :branch "main"))
    
    ;;------------------------------------------------------------------------------
    ;; company and helm-company
    ;;------------------------------------------------------------------------------
    
    ;; install and enable helm-company
    (use-package company
      :config
      (setq company-idle-delay nil))
    (global-company-mode t)
    (use-package helm-company)
    
  2. Start Emacs with emacs -q --load ~/test/init.el

  3. Open ~/test/init.el and complete a string (eg. "set") using helm-company

  4. When the helm window opens, select any suggestion and observe the error message in the panel below

Backtrace

As requested:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  company--continue()
  company--perform()
  company-post-command()

atreyasha avatar Nov 12 '23 07:11 atreyasha

Thank you, @atreyasha. I can reproduce this issue now.

It looks like this happens when `company-idle-delay' is nil. I have this delay set to 0.1, which is why I never saw this error.

You could set your `company-idle-delay' to 0.1 as a temporary workaround, but I will need to figure out why a non-nil idle delay has any effect on this at all.

Sodel-the-Vociferous avatar Nov 12 '23 23:11 Sodel-the-Vociferous

That was a challenging gremlin to track down. I hope this works for you now! :)

Sodel-the-Vociferous avatar Nov 13 '23 07:11 Sodel-the-Vociferous

Works for me now, thanks! :)

atreyasha avatar Nov 14 '23 06:11 atreyasha