Skip to content

Commit

Permalink
Using require is better
Browse files Browse the repository at this point in the history
  • Loading branch information
masasam committed Aug 21, 2018
1 parent 3f5ae75 commit 9c8e6d2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions counsel-tramp.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Masashı Mıyaura
;; URL: https://github.com/masasam/emacs-counsel-tramp
;; Version: 0.4.1
;; Version: 0.4.2
;; Package-Requires: ((emacs "24.3") (counsel "0.10"))

;; This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -101,7 +101,7 @@ Kill all remote buffers."
(push
(concat "/ssh:" host "|sudo:root@" host ":/")
hosts)))))
(when (package-installed-p 'docker-tramp)
(when (require 'docker-tramp nil t)
(cl-loop for line in (cdr (ignore-errors (apply #'process-lines "docker" (list "ps"))))
for info = (reverse (split-string line "[[:space:]]+" t))
collect (progn (push
Expand All @@ -118,11 +118,11 @@ Kill all remote buffers."
(push
(concat "/docker:" counsel-tramp-docker-user "@" (car info) ":/")
hosts))))))
(when (package-installed-p 'vagrant-tramp)
(when (require 'vagrant-tramp nil t)
(cl-loop for box-name in (map 'list 'cadr (vagrant-tramp--completions))
do (progn
(push (concat "/vagrant:" box-name ":/") hosts)
(push (concat "/vagrant:" box-name "|sudo:root@" box-name ":/") hosts))))
do (progn
(push (concat "/vagrant:" box-name ":/") hosts)
(push (concat "/vagrant:" box-name "|sudo:root@" box-name ":/") hosts))))
(push (concat "/sudo:root@localhost:" counsel-tramp-localhost-directory) hosts)
(reverse hosts)))

Expand All @@ -133,10 +133,10 @@ You can connect your server with tramp"
(interactive)
(unless (file-exists-p "~/.ssh/config")
(error "There is no ~/.ssh/config"))
(when (package-installed-p 'docker-tramp)
(when (require 'docker-tramp nil t)
(unless (executable-find "docker")
(error "'docker' is not installed")))
(when (package-installed-p 'vagrant-tramp)
(when (require 'vagrant-tramp nil t)
(unless (executable-find "vagrant")
(error "'vagrant' is not installed")))
(run-hooks 'counsel-tramp-pre-command-hook)
Expand Down

0 comments on commit 9c8e6d2

Please sign in to comment.