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

Add remote support #1922

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Add remote support #1922

wants to merge 18 commits into from

Commits on Apr 28, 2024

  1. Fix running checkers on remote hosts via TRAMP.

    This patch does three things:
    
    * Update `flycheck-default-executable-find` to search remote hosts when
      `default-directory` is a remote directory. See also the documentation for
      [executable-find](https://www.gnu.org/software/emacs/manual/html_node/elisp/Locating-Files.html).
    
    * Change uses of `call-process` and `start-process` to `start-file-process`
      which is the same as these two functions, but starts the process on a remote
      host when `default-directory` is a remote directory. See also the
      documentation for
      [start-file-process](https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html).
    
    * Passes the local part of `buffer-file-name` to the compile command,
      e.g. strips `/ssh:10.0.0.42`, since the checker is run on the remote machine
      where the file name must be local. See also the documentation for
      [file-local-name](https://www.gnu.org/software/emacs/manual/html_node/elisp/Magic-File-Names.html).
    carrete authored and yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    fe53f87 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f5d026c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fdeaef3 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5f34c5b View commit details
    Browse the repository at this point in the history
  5. Make temp directory on remote

    Such checkers (including python-pycompile) use a temp directory.
    
    For executing flycheck on remote files, temp directories should be
    created on remote.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    b9ecc69 View commit details
    Browse the repository at this point in the history
  6. Make default error-parser return `flycheck-error' with local path

    Some checkers (including python-flake8 and python-pycompile) use
    flycheck-parse-error-with-patterns as their error-parser.
    
    This commit changes `flycheck-parse-error-with-patterns' behavior so
    that it always returns `flycheck-error' struct with its :filename slot
    in the form of local path on remote files (i.e., without
    "/method:user@host:" part).
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    cb3ac3d View commit details
    Browse the repository at this point in the history
  7. Convert filename in `flycheck-error' to local path

    Some checkers set remote path or filename (without directory path) to
    `flycheck-error' struct's :filename slot.
    
    For example, on remote files,
    python-pylint sets remote path (i.e., with "/method:user@host:" part).
    python-flake8 before the previous comiit also sets remote path.
    py-compile sets filename only.
    
    In all these cases, after processing with
    `flycheck-fill-and-expand-error-file-names', :filename slot of
    `flycheck-error' struct was remote path.
    
    This commit changes `flycheck-fill-and-expand-error-file-names'
    behavior so that it always returns `flycheck-error' struct with its
    :filename slot in the form of local path on remote files (i.e.,
    without "/method:user@host:" part).
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    9982caa View commit details
    Browse the repository at this point in the history
  8. Make flycheck temp file on remote and report its local path

    Some checkers (including python-pylint) use
    `flycheck-save-buffer-to-temp' to create temp file.
    
    For executing flycheck on remote files, their corresponding temp files
    should be created on remote (therefore, they should be specified as
    remote path, i.e., with "/method:user@host:" part).
    On the other hand, the return value of `flycheck-save-buffer-to-temp'
    should be local path (i.e., without "/method:user@host:" part) because
    the value is used as an argument to checker's executable.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    539b4df View commit details
    Browse the repository at this point in the history
  9. Enable flycheck to find remote config file

    Flycheck uses `flycheck-locate-config-file-functions' to locate config
    file. Its value is the list of functions below:
    - flycheck-locate-config-file-by-path
    - flycheck-locate-config-file-ancestor-directories
    - flycheck-locate-config-file-home
    
    Each locate function should use remote path (i.e., with
    "/method:user@host:" part) to locate a config file.
    
    When the return value is used as an argument to a checker's
    executable, the path should be converted to local path (i.e., without
    "/method:user@host:" part).
    
    Tested with python-flake8 and python-pylint.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    df4adab View commit details
    Browse the repository at this point in the history
  10. Enable *-stylelint to work on remote files by using temporary file

    The original version used stdin instead of a temporary file (as with
    javascript-eslint). However, behavior of eslint and stylelint is
    different in terms of stdin processing.
    
    Corresponding CLI commands for both tools are:
    eslint:
    eslint --format=json --stdin --stdin-filename FILENAME-TO-ASSIGN-TO-STDIN
    
    stylelint:
    stylelint --formatter json --stdin-filename FILENAME-TO-ASSIGN-TO-STDIN
    or
    stylelint --formatter json --stdin --stdin-filename FILENAME-TO-ASSIGN-TO-STDIN
    
    eslint waits for stdin EOF and keeps itself alive, while stylelint
    does not wait and may exit before input comes in.
    
    When stylelint does not receive stdin,
    it emits its usage message (when --stdin is not specified)
    or outputs "empty source" lint message (when --stdin is specified).
    
    For local files, the original version was able to pass input with
    `flycheck-process-send-buffer' before stylelint process exited.
    For remote files, stylelint process exited before
    `flycheck-process-send-buffer' called.
    
    This commit changes *-styelint commands so that they use a temporary
    file (instead of stdin) as their input to avoid the above situation on
    remote.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    5a9b765 View commit details
    Browse the repository at this point in the history
  11. Add a file-local-name wrapper function that accepts nil argument

    To add support for remote files, some occurrences of filenames had to
    be converted to local path on remote (i.e., without
    "/method:user@host:" part).
    However, these filenames could be nil, while file-local-name signals
    an error when its argument is nil.
    
    This led to test failure for scss-lint and others.
    (Test command: "make LANGUAGE=scss integ")
    
    This commit adds a wrapper function of file-local-name that accepts
    nil as its argument and return it as it is.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    8cabec3 View commit details
    Browse the repository at this point in the history
  12. Replace all file-local-name with file-local-name-pass-nil

    Replace all occurrences is excessive.
    For example, arguments to checker executables are not expected to be
    nil and thus file-local-name will suffice.
    However, here, all occurrences are replaced just in case.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    877697b View commit details
    Browse the repository at this point in the history
  13. Return local home when buffer-file-name returns nil

    In `flycheck-locate-config-file-home', file-remote-p is used to
    determine if the context is local or remote.
    Because file-remote-p does not accept nil,
    (file-remote-p (buffer-file-name))
    may cause an error.
    
    It led to unit test failure:
       FAILED  flycheck-locate-config-file/existing-file-in-home-directory
       FAILED  flycheck-locate-config-file/existing-file-in-parent-directory
       FAILED  flycheck-locate-config-file/not-existing-file
    
    This commit adds a nil-check for buffer-file-name.
    When buffer-file-name returns nil, the context is assumed to be local.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    f4d8d57 View commit details
    Browse the repository at this point in the history
  14. Add workaround for Emacs<=25.3

    integ test for Emacs25.3 failed due to undefined functions.
    
    Error: the following functions are not known to be defined:
    file-local-name, temporary-file-directory
    
    This commit fixes the problem by reverting to the original codes when
    the functions are not available.
    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    e65472b View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    960a0ab View commit details
    Browse the repository at this point in the history
  16. Fix typo

    yfyyfy committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    7c1efa7 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    75cac2d View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2024

  1. Suppress flake8's colored outputs

    The outputs of flake8 are parsed by flycheck-parse-with-patterns, which does
    not take ASCII escape sequences into account.
    Therefore, flake8 should return simple texts (without escape sequences).
    yfyyfy committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    d766cd5 View commit details
    Browse the repository at this point in the history