company-clang (optionally) adding a space after a function name #1348
Replies: 4 comments 2 replies
-
Hi! I think it's a pretty bizarre convention, rarely seen outside of GNU's codebases. But a new user option should be fine. Alternatively, I suppose we could query the current auto-detected CC-Mode's "style". Someone more familiar with it could give a more concrete advice. Also note that this is just one (built-in) backend. If you wanted to change how (for example) Eglot formats its function arguments, that would have to happen somewhere else. |
Beta Was this translation helpful? Give feedback.
-
Dmitry Gutov ***@***.***> writes:
Hi!
Hi Dmitry!
I think it's a pretty bizarre convention, rarely seen outside of GNU's
codebases. But a new user option should be fine.
I agree wrt to the bizarreness, I especially love the {} compound
statements. But changing that is probably even harder than getting
C++ into Emacs, or getting CL packages in ;-).
Alternatively, I suppose we could query the current auto-detected
CC-Mode's "style". Someone more familiar with it could give a more
concrete advice.
Also note that this is just one (built-in) backend. If you wanted to
change how (for example) Eglot formats its function arguments, that
would have to happen somewhere else.
Yes, I know. I currently just want to get something working, and get on
with features/pkg, if you know what I mean :-)
|
Beta Was this translation helpful? Give feedback.
-
Dmitry Gutov ***@***.***> writes:
Do you want to create a PR with that new option? Or with detection
logic based on CC-Mode style.
I guess not.
I've merged master yesterday, tried out eglot, and found that it,
unsurprisingly, also doesn't add a space after the function name, and
that's not using cmapany-clang but company-capf.
So I think, alhough I've got something working for me, it wouldn't
be generally useful. Too bad.
Maybe one can do something on the clang side, I have to look at that at
some point. For example, I see this for clangd
…--fallback-style=<string> - clang-format style to apply by
default when no .clang-format file is found
but I don't know what it does.
Anyway, thanks for taking this into consideration.
|
Beta Was this translation helpful? Give feedback.
-
Dmitry Gutov ***@***.***> writes:
So I think, alhough I've got something working for me, it wouldn't
be generally useful. Too bad.
It could be useful for other people who use company-clang. I don't know how many there are, but they definitely exist.
But I suppose if Emacs devs are going to finally get out of the stone
age and use Eglot for development, doing it there will have the most
bang for the buck.
Stone age is well said. I don't understand it, and I'm almost 66
myself.
FWIW, I'm now using the quick hack below which works with company-clang
(lsp-mode) and eglot, AFAICT. Could be writte better, but I can't be
bothered, and maybe it's useful for someone:
(defun my-completion-hook (s)
(save-excursion
(when (and (search-backward s nil t)
(looking-at (concat s "(")))
(search-forward "(")
(backward-char 1)
(insert " "))))
(add-hook 'c-mode-common-hook
(lambda ()
(add-hook 'company-after-completion-hook
'my-completion-hook nil t)))
|
Beta Was this translation helpful? Give feedback.
-
The GNU coding convention requires a space after the function name in a function call in C.
I couldn't find how to configure company to do this. So, I modified the post-completion in company-clang like below.
Would that be good to have, or is it even already possible?
diff --git a/elpa/company-0.9.13/company-clang.el b/elpa/company-0.9.13/company-clang.el
index 1460e09..12fc619 100644
--- a/elpa/company-0.9.13/company-clang.el
+++ b/elpa/company-0.9.13/company-clang.el
@@ -379,6 +379,7 @@ passed via standard input."
(annotation (company-clang--annotation arg))
(post-completion (let ((anno (company-clang--annotation arg)))
(when (and company-clang-insert-arguments anno)
Beta Was this translation helpful? Give feedback.
All reactions