In company-mode, when I apply company-complete-selection, it completes variable but sometimes adds () at the end of it. Would it be possible to prevent this in all cases?

Example: enter image description here

which completed as: self.logged_jobs_to_process()

my setup:

(add-hook 'after-init-hook 'global-company-mode)
(setq company-auto-commit t)
(setq company-auto-complete t)
(global-set-key (kbd "C-c C-k") 'company-complete)
(setq company-frontends

M-x company-diag returns:

Emacs 28.0.50 (x86_64-pc-linux-gnu) of 2021-09-01 on home
Company 0.9.13

company-backends: (company-bbdb company-semantic company-cmake company-capf company-clang company-files
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-dabbrev)

Used backend: company-capf
Value of c-a-p-f: (lsp-completion-at-point)
Major mode: python-mode
Prefix: "None"
  #("None" 0 4 (lsp-completion-item #s(hash-table size 7 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("label" #("None" 0 4 (match-data (0 4 0 1 1 2 2 3 3 4))) "kind" 14
"sortText" "aNone" "insertText" "None" "data" #s(hash-table size 1 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("doc_uri" "file:///home/alper/ebloc-broker/broker/Driver.py"))
"_emacsStartPoint" 3652)) lsp-sort-text "aNone" lsp-completion-start-point 3652 lsp-completion-markers (3652 #<marker (moves after insertion) at 3656 in Driver.py>) lsp-completion-prefix
"None" match-data (0 4 0 1 1 2 2 3 3 4) face (completions-common-part))) " (Keyword)"
  • Hey @alper. As a side note, you can safely remove company-auto-commit from your setup, because this is an obsolete name of company-auto-complete, which you also have enabled.
    – Y. E.
    Sep 21, 2021 at 6:56
  • Yikes, and there was no reason to double-post, I think?
    – Y. E.
    Sep 21, 2021 at 7:11
  • @Y.E. I know, sorry I was desperate to find an solution :( I think I cannot delete an opened issue, I closed the issue over there for clearity.
    – alper
    Sep 21, 2021 at 8:34
  • no problem, I understand that "was desperate" part :-) The Issue you had submitted was moved to the Discussions section there. [I'd do the same, but the maintainer was the first one around.] Overall, it's totally welcome to post/lookup Company questions at its Q&A section. Moreover, often you'd get a faster response there (f.i., as you'd noticed, the maintainer is very responsive).
    – Y. E.
    Sep 21, 2021 at 9:09

1 Answer 1



After the output of M-x company-diag was posted it became clear, according to the Value of c-a-p-f: (lsp-completion-at-point), that lsp-mode is responsible for the completion in this case.

Eventually, after contacting both lsp-mode and python-lsp-server maintainers, it was clarified that this lsp-mode setting has to be disabled to prevent completion with parentheses:

(setq lsp-enable-snippet nil)

[EARLIER ANSWER, suitable for the company-clang backend.]

I assume that the backend in action is company-clang.

(If not, add the output of M-x company-diag to your question.)

Then, the addition of the parentheses can be prevented by disabling this company-clang user option:

(setq company-clang-insert-arguments nil)

But note that it's going to disable insertion of arguments.

For example,

enter image description here

Completes to

enter image description here

only if company-clang-insert-arguments is enabled.

  • Output for M-x company-diag is added. I have tried (setq company-clang-insert-arguments nil) but still it adds () to the end for example for the Variables that are assigned to None, completed as variable_name()
    – alper
    Sep 21, 2021 at 8:32
  • I think used backend is company-capf but I am not sure how can I disabled in the it
    – alper
    Sep 21, 2021 at 8:53
  • 1
    I'd do so, yes. And, for reference, I see you already did. And if you find a solution it'd be nice if you post it in here and in Company's Q&A (for future generations so to speak :-)
    – Y. E.
    Sep 21, 2021 at 10:50
  • 1
    Please note that doing (setq lsp-enable-snippet nil) solved it
    – alper
    Sep 23, 2021 at 23:27
  • 1
    I updated the answer accordingly. Feel free to update as you see fit.
    – Y. E.
    Sep 24, 2021 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.