systemd-mode icon indicating copy to clipboard operation
systemd-mode copied to clipboard

Maybe regression bug: Error happens when systemd mode is active.

Open yang-ling opened this issue 4 years ago • 2 comments

Hi. I think it's a regression bug related to #4 . I open a new issue because #4 is closed.

Now I still get the same error messages while systemd-mode is active.

Company backend ’t’ could not be initialized:
Symbol’s function definition is void: t

My system info:

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4)
 of 2021-03-27 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Manjaro Linux

I checked source code, and found this line L410

Should it be changed to (add-hook 'completion-at-point-functions #'systemd-complete-at-point nil 'local) ?

I am not familiar with emacs lisp. It's just my guess, because L409 is (add-hook 'company-backends #'systemd-company-backend nil 'local), I think L410 and L409 are very similar, then maybe L410 should also use 'local as the last parameter of add-hook function.

yang-ling avatar May 07 '21 11:05 yang-ling

This error is gone when I change L409 to

(push #'systemd-company-backend company-backends)

I am not an lisp expert so I don't know whether the line above is equivalent of L409, but it solves my issue.

I can send a PR if you think this change is OK.

yang-ling avatar May 08 '21 08:05 yang-ling

FYI, I observe the same error when loading systemd mode.

dschrempf avatar Sep 30 '21 13:09 dschrempf

Using add-hook to modify company-backend is an anti-pattern in Emacs Lisp. add-hook is for modifying hooks variables. Making it local removes any previously set backends.

Furthermore, company-backends should now use completion-at-point-functions. It's a more appropriate way.^1

notetiene avatar Jan 25 '23 00:01 notetiene

Do you want to create a PR, @notetiene?

On the other hand: Is this repo still maintained? I do not see any activity.

dschrempf avatar Jan 25 '23 08:01 dschrempf

@stardiviner I could, but if it never gets merged, I would have wasted much time. I do use systemd, but occasionally. I would much prefer if this mode could be included in GNU Emacs. People can come and go, but big projects as such won't be impacted by lack of interest from the maintainer.

I'm not sure if the maintainer is still active in this project.

notetiene avatar Jan 25 '23 15:01 notetiene

In my opinion, any situation is better than the current one.

dschrempf avatar Jan 26 '23 08:01 dschrempf

Since it seems like modifying `company-backends' is something a major mode shouldn't be doing, I just nixed the line in 87426071. Keeping the company backend around since it's a TINY quality of life improvement.

holomorph avatar Feb 01 '23 03:02 holomorph