Last active
          December 17, 2018 06:23 
        
      - 
      
- 
        Save svetlyak40wt/8369522a4e32b1af5f82d3ba960c675e to your computer and use it in GitHub Desktop. 
    An Emacs config I use to make SLY's tramp contrib work with Ultralisp docker containers.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (require 'sly) | |
| (defun sly-ultralisp-init () | |
| (defun sly-make-tramp-file-name (username remote-host lisp-filename) | |
| "Old (with multi-hops) tramp compatability function" | |
| (message "Makining tramp filename for %s %s and %s" username remote-host lisp-filename) | |
| (tramp-make-tramp-file-name "docker" | |
| username | |
| nil | |
| remote-host | |
| nil | |
| lisp-filename)) | |
| (defun sly-docker-on-connection () | |
| (add-to-list 'sly-filename-translations | |
| (sly-create-filename-translator | |
| :machine-instance "ultralisp_app" | |
| :username "root")) | |
| (add-to-list 'sly-filename-translations | |
| (sly-create-filename-translator | |
| :machine-instance "ultralisp_worker" | |
| :username "root")) | |
| (let* ((host (sly-machine-instance)) | |
| (docker-output (shell-command-to-string "docker ps --format '{{.ID}} {{.Names}}'")) | |
| (containers (split-string docker-output)) | |
| (pos (position host containers :test 'string=))) | |
| (when pos | |
| ;; If we found a real container's name, then we'll | |
| ;; replace sly-machine-instance to it to have | |
| ;; nice hosts for tramp. | |
| (let ((container-name (nth (1+ pos) containers))) | |
| (setf (sly-machine-instance) | |
| container-name))))) | |
| (add-hook 'sly-connected-hook 'sly-docker-on-connection)) | |
| (add-hook 'sly-mode-hook | |
| 'sly-ultralisp-init) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment