PillFall / languagetool.el

LanguageTool suggestions integrated within Emacs
GNU General Public License v3.0
98 stars 8 forks source link

languagetool-server-url ignored #23

Open laotse opened 7 months ago

laotse commented 7 months ago

What version of Emacs are you running?

28.2

What version of LanguageTool are you running?

6.3

What version of this package are you running?

1.3.0

What is the current behaviour?

Although I specify "languagetool-server-url" for my own server, in tcpdump I see emacs connecting to localhost:8081 as IPv6

What is you expect to happen?

emacs should connect to the server specified in languagetool-server-url

What do you do to get this bug?

The config in ~/.emacs:

;; languagetool
(use-package languagetool
  :ensure t
  :defer t
  :commands (languagetool-check
             languagetool-clear-suggestions
             languagetool-correct-at-point
             languagetool-correct-buffer
             languagetool-set-language
             languagetool-server-mode)
  :config
  (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8")
    languagetool-server-url "http://languagetool.example.com"
    languagetool-server-port 8081)
  :bind (("<f7>" . languagetool-server-mode)
     ("<f8>" . languagetool-correct-buffer)))

Then load any document and press <f7>.
laotse commented 7 months ago

If I change the default value in languagetool-server.el i.e., line 67: (defcustom languagetool-server-url "http://languagetool.example.com", then it works as expected. It's just the setting in .emacs, which is apparently ignored.

laotse commented 7 months ago

When I start-up emacs none of the languagetool- variables are known. After pressing <f7>, languagetool-server-url exists, but has its default value. Manually setting it after the system has been initialized by <f7>: M-: (setq languagetool-server-url "http://languagetool.example.com") pressing <f7> again it works as expected.

I have no clue about emacs lisp, but could it be that languagetool-server-url is not declared at the point where .emacs attempts to set it?

PillFall commented 7 months ago

Hello @laotse,

Is the first time I encounter a bug like this.

This part of the code is intended for the use of Emacs customize

https://github.com/PillFall/languagetool.el/blob/b136d531129eb488dc4134784e34c4afedcb0c2f/languagetool-server.el#L66-L69

I believe the the bug you are encountering have to deal with the usage of use-package, but as you set the defer flag to non-nil, it must load all the customize options after all the package is load. So we end up as the beginning.

It is weird that only the languagetool-server-url variable have this problem. Tell me if I'm wrong.

I will study the bug. And try to fix it asap.

PillFall commented 1 month ago

Maybe this could be related to #19?

laotse commented 1 month ago

Hello @PillFall,

the issue may affect other variables as well. It's just that I have only languagetool-server-url set to a non default value. All the rest are default. Concerning issue #19 it seems that the entire command is not set, which is not the case on my side. The commands are working fine.