Skip to content

Commit eca5bbd

Browse files
olymk2proofit404
authored andcommitted
Add ability to set default container via dir-locals. (#11)
1 parent 6a5a2a3 commit eca5bbd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@ Activate python virtual environment. Tramp paths are supported.
120120
### pythonic-deactivate
121121

122122
Deactivate python virtual environment.
123+
124+
125+
## Project overrides with .dir-locals
126+
You can change the default docker file and set a default
127+
container to run the pythonic commands in with these dir-locals.
128+
129+
```lisp
130+
((python . ((pythonic-docker-compose-filename . "local.yml")
131+
(pythonic-docker-compose-container-name . "footprint"))))
132+
```

pythonic.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ format."
154154
;;; Docker Compose.
155155

156156
(defvar pythonic-docker-compose-filename "docker-compose.yml")
157+
(defvar pythonic-docker-compose-container-name nil)
157158

158159
(defvar pythonic-read-docker-compose-file-code "
159160
from __future__ import print_function
@@ -208,6 +209,7 @@ print(json.dumps(yaml.safe_load(open(sys.argv[-1], 'r'))))
208209

209210
(defun pythonic-set-docker-compose-alias ()
210211
"Build alias string for current docker-compose project."
212+
(hack-dir-local-variables-non-file-buffer)
211213
(unless
212214
(or (tramp-tramp-file-p default-directory)
213215
(pythonic-has-alias-p default-directory))
@@ -220,7 +222,9 @@ print(json.dumps(yaml.safe_load(open(sys.argv[-1], 'r'))))
220222
;; should appears once in the selection and all volumes
221223
;; should be added to the alias list.
222224
(volume (if (< 1 (length volumes))
223-
(assoc (completing-read "Service: " (mapcar 'car volumes) nil t) volumes)
225+
(if pythonic-docker-compose-container-name
226+
pythonic-docker-compose-container-name
227+
(assoc (completing-read "Service: " (mapcar 'car volumes) nil t) volumes))
224228
(car volumes)))
225229
(service (car volume))
226230
(sub-project (f-join project (cadr volume)))

0 commit comments

Comments
 (0)