Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 254 forks source link

Fix rtags completion over tramp with unsaved buffer for remote file #1441

Open pcooksey opened 3 days ago

pcooksey commented 3 days ago

Just wanted to say rtags is awesome and thanks for making my life easier.

To work with my remote project, I followed this PR https://github.com/Andersbakken/rtags/pull/546 which was pretty straight forward (it was very helpful so should we add the details to the wiki?). Next, I added company-rtags for completion as described in the wiki#code-completion-in-emacs. However, it would fail with a company async timeout. After quite a bit of digging (and learning :sweat_smile: ), I found that rtags elisp code was sending the unsaved buffer as a temp file but this temp file was being created locally. Just a few small changes and everything was working like a charm.

Fixes:

  1. Use the tramp aware function make-nearby-temp-file to create the temp file on the remote host (if default-directory is remote).
  2. Change the path prefix to a relative path as absolute forces it to always be a local file.
  3. Change the path prefix to be unique to rtags as suggested by the documentation for make-temp-file (See "To prevent conflicts...").
  4. Use rtags-untrampify on the temp file name so that we always pass the local file name to rc.

Let me know if there is anything else I can do to make this PR approved.