Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-d option clashes when setting other language #48

Open
PillFall opened this issue Dec 26, 2019 · 1 comment
Open

-d option clashes when setting other language #48

PillFall opened this issue Dec 26, 2019 · 1 comment

Comments

@PillFall
Copy link

PillFall commented Dec 26, 2019

When I check any buffer without setting the language, the output is correct (says that I have errors if any).

But when I set any language. it always returns that the buffer is correct (I know is not).

Checking langtool debugging tool in Emacs I notice that when I delete the -d when it has no options (in log the command is langtool.jar -c ascii -d -l en-GB file.txt) that error is fixed. Is the only flag that clashes.

I propose to change the code in the langtool-command--invoke-process to avoid the -d flag is there is no options to pass.

(defun langtool-command--invoke-process (file begin finish &optional lang)
  (let ((version (langtool--jar-version)))
    (cl-destructuring-bind (command args)
        (langtool--basic-command&args)
      ;; Construct arguments pass to jar file.
      ;; http://wiki.languagetool.org/command-line-options
      (setq args (append
                  args
                  (list "-c" (langtool--java-coding-system
                              buffer-file-coding-system))
                  ;;-----------------------------
                  ;; Avoid using -d flag if not needed.
                  (if (string= (langtool--disabled-rules) "")
                      (list "")
                    (list "-d" (langtool--disabled-rules)))))
      (cond
       ((stringp (or lang langtool-default-language))
        (setq args (append args (list "-l" (or lang langtool-default-language)))))
       (t
        (setq args (append args (list "--autoDetect")))))
      (when langtool-mother-tongue
        (setq args (append args (list "-m" langtool-mother-tongue))))
      (setq args (append args (langtool--custom-arguments 'langtool-user-arguments)))
      (setq args (append args (list (langtool--process-file-name file))))
      (langtool--debug "Command" "%s: %s" command args)
      (let* ((buffer (langtool--process-create-client-buffer))
             (proc (langtool--with-java-environ
                    (apply 'start-process "LanguageTool" buffer command args))))
        (set-process-filter proc 'langtool-command--process-filter)
        (set-process-sentinel proc 'langtool-command--process-sentinel)
        (process-put proc 'langtool-source-buffer (current-buffer))
        (process-put proc 'langtool-region-begin begin)
        (process-put proc 'langtool-region-finish finish)
        (process-put proc 'langtool-jar-version version)
        proc))))
@PillFall
Copy link
Author

Sorry for putting the code in the issue, I'm still pretty new and doesn't know how don't mess up a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant