Skip to content
Permalink
Browse files

Use the correct YAPF from Emacs.

Things are a bit tricky here, because yapfify doesn't have a hook to
configure the YAPF executable. Furthermore, it pipes the buffer contents
through it, so we have to look at the first line of the buffer to guess if
it is Python 2 or 3.

Change-Id: Id40662c392d2afc73b1f241d73bb2a9773a6a75c
  • Loading branch information
svenpanne committed Dec 30, 2019
1 parent f2fc9c8 commit be8d45d2764d6c438e3ec84bc209cd2693ff790e
Showing with 15 additions and 1 deletion.
  1. +15 −1 .dir-locals.el
@@ -4,7 +4,21 @@
"scripts/run-mypy"))
(eval setq flycheck-python-pylint-executable
(concat (projectile-locate-dominating-file default-directory dir-locals-file)
"scripts/run-pylint"))))
"scripts/run-pylint"))
(eval eval-after-load "yapfify"
'(defun yapfify-call-bin (input-buffer output-buffer start-line end-line)
"Call process yapf on INPUT-BUFFER saving the output to OUTPUT-BUFFER.
Return the exit code. START-LINE and END-LINE specify region to
format."
(with-current-buffer input-buffer
(call-process-region (point-min) (point-max)
(concat (projectile-locate-dominating-file default-directory dir-locals-file)
"scripts/run-pipenv")
nil output-buffer nil
(if (string-suffix-p "python3\n" (save-excursion (goto-char (point-min)) (thing-at-point 'line t))) "3" "2")
"run" "yapf"
"-l" (concat (number-to-string start-line) "-" (number-to-string end-line))))))))
(scss-mode . ((eval setq flycheck-sass/scss-sass-lint-executable
(concat (projectile-locate-dominating-file default-directory dir-locals-file)
"node_modules/.bin/sass-lint"))))

0 comments on commit be8d45d

Please sign in to comment.
You can’t perform that action at this time.