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

emacs tramp mode does not respect .clang-format in the remote directory #5

concretevitamin opened this issue Feb 8, 2018 · 5 comments


Copy link

@concretevitamin concretevitamin commented Feb 8, 2018

(This is a cross-post from I couldn't find any maintainer information on elpa so I only traced it here; apologies if this is not the right place.)

I have a git repo with a .clang-format and a simple.c source code. In local mode, namely editing off local disk, it respects the style file. However if I edit using tramp mode the same repo, then clang-format will format the source code using some default style file (I don't know where it's picked up), and will NOT honor the style file existing in the same remote directory.

Q1: How do I fix this?

Q2: (Maybe it's easier) Where does clang-format in tramp-mode pick up the style file by default?


This comment has been minimized.

Copy link

@kljohann kljohann commented Mar 5, 2018

clang-format.el just passes buffer-file-name (which is something like "/ssh:host:/path/to/file") to clang-format via the -assume-filename flag. As clang-format can not make sense of this file name it (presumably) uses its default style. I see two options:

  • translate tramp path to equivalent local path (does not always exist)
  • run clang-format on remote host

This comment has been minimized.

Copy link

@concretevitamin concretevitamin commented Mar 5, 2018

@kljohann Thanks! Both options work for me and will be tremendously helpful. For Option 2, most remote machines I work with have clang-format installed either in /usr/bin or /usr/local/bin, with the former being the more popular.

Looking forward to any updates on this!


This comment has been minimized.

Copy link

@kljohann kljohann commented Apr 14, 2018

Just to clarify: I was only trying to come up with possible ways to implement this. As I do not use clang-format via tramp I do not plan to work on this feature. :) If you come up with a patch the best way forward would be via the mailing list or phabricator.


This comment has been minimized.

Copy link

@aaron-michaux aaron-michaux commented Nov 6, 2018

Being a elisp naif, would love a hint on how to run clang-format on tramp.


This comment has been minimized.

Copy link

@laudrup laudrup commented Jan 11, 2020

I would really like this package to support remote connections with tramp as well.

I've tried to look a bit into it, but my knowledge of elisp is very limited to say the least.

As far as I can tell, the issue is, that clang-format.el calls call-process-region to actually execute the clang-format process which does not respect/support remote connections.

Instead something like process-file should be used instead which does some magic to support remote connections based on the value of the default-directory variable. It seems like other emacs packages which do support remote connections does something like that so it works transparently.

I've found a file in the tramp package called tramp-util.el:

which seems to wrap the standard emacs process handling functions, but I haven't been able to figure out how to use that or copy the relevant parts, again because of my limited elisp knowledge.

I assume this should be fairly simple to implement for someone more experienced in elisp, but unfortunately that's not me (although I'm willing to try and look a bit more into it).

Anything else I can do to get this supported?

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.