Matt McClure avatar Matt McClure committed 11658d4

Translate between paths on Lisp host and Python host, in case
Emacs is using Python via TRAMP.

Comments (0)

Files changed (1)

ropemacs/__init__.py

         else:
             result = lisp.read_file_name(prompt, location, location)
         if result == '' and location is not None:
-            return location
-        return result
+            return self.path_on_python_host(location)
+        return self.path_on_python_host(result)
+
+    def path_on_python_host(self, path_on_lisp_host):
+        path_on_python_host = None
+        if path_on_lisp_host:
+            path_on_python_host = lisp.file_remote_p(path_on_lisp_host, lisp.localname)
+        return path_on_python_host or path_on_lisp_host
 
     def message(self, msg):
         message(msg)
         return min(offset1, offset2), max(offset1, offset2)
 
     def filename(self):
-        import traceback
-        lisp.message(repr(traceback.format_stack()))
-        lisp.backtrace()
         filename = lisp.buffer_file_name()
-        host_relative_remote_filename = None
-        if filename:
-            host_relative_remote_filename = lisp.file_remote_p(filename, lisp.localname)
-        lisp.message("%s: %s" % (filename, repr(host_relative_remote_filename)))
-        return host_relative_remote_filename or filename
+        return self.path_on_python_host(filename)
 
     def is_modified(self):
         return lisp.buffer_modified_p()
         if initial is not None:
             lisp.set_buffer(initial)
 
+    def path_on_lisp_host(self, path_on_python_host):
+        return lisp.file_remote_p(lisp['default-directory'].value()) + path_on_python_host
+
     def find_file(self, filename, readonly=False, other=False):
+        filename = self.path_on_lisp_host(filename)
         if other:
             lisp.find_file_other_window(filename)
         elif readonly:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.