From 2f71a4ede164a92b58f02f5d64d3d12a17cae8ae Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Thu, 3 Oct 2019 13:21:04 -0500 Subject: [PATCH] rlbr/setup-python-venv-dirlocals is good to go --- python-conf.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python-conf.el b/python-conf.el index b6f330d..d134c13 100644 --- a/python-conf.el +++ b/python-conf.el @@ -70,7 +70,20 @@ (venv-name (rlbr/get-venv-name library-root))) (rlbr/save-buffer-func-to-file dir-locals-path 'add-dir-local-variable - `(python-mode pyvenv-workon ,venv-name)))) + `(python-mode pyvenv-workon ,venv-name)) + (let* ((vc-root (vc-find-root dir-locals-path ".git")) + (vc-ignore-file (vc-call-backend 'Git 'find-ignore-file vc-root))) + (if (apply 'string-equal (mapcar 'directory-file-name (mapcar 'file-truename (list vc-root library-root)))) + (progn + (unless (file-exists-p vc-ignore-file) + (with-temp-buffer + (write-file vc-ignore-file))) + (vc-ignore ".dir-locals.el")) + (when (y-or-n-p (format "Ignore .dir-locals.el in repo '%s' ?" vc-root)) + (unless (file-exists-p vc-ignore-file) + (with-temp-buffer + (write-file vc-ignore-file))) + (vc-ignore ".dir-locals.el")))))) (defun rlbr/init-python-venv-in-library-root (&optional library-root) "If no venv is specified in the library root .dir-locals file, prompt to either create one or use default"