holomorph / systemd-mode

Major mode for editing systemd units
GNU General Public License v3.0
54 stars 20 forks source link

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

Closed yang-ling closed 1 year ago

yang-ling commented 3 years ago

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 commented 3 years ago

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.

dschrempf commented 3 years ago

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

notetiene commented 1 year ago

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

dschrempf commented 1 year ago

Do you want to create a PR, @notetiene?

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

notetiene commented 1 year ago

@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.

dschrempf commented 1 year ago

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

holomorph commented 1 year ago

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.