summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpkotta <jpkotta@gmail.com>2016-07-28 12:33:39 -0500
committerClaudiu Popa <pcmanticore@gmail.com>2016-07-28 20:33:39 +0300
commit97718ad7640e47dd7b5b065f4418bc0c19b36814 (patch)
tree207c2854992c141078351147848cef4c845eab2e
parentdccc605d24331b578fddc35c0a08f408b3fd0b23 (diff)
downloadpylint-git-97718ad7640e47dd7b5b065f4418bc0c19b36814.tar.gz
elisp: allow guessed indent string to be passed to pylint (#1051)
Emacs tries to guess what the indent string is on a per-file basis. Now pylint.el can get this as --indent-string, so if you have different indent policies on different files, pylint will not complain about the non-PEP8 ones.
-rw-r--r--elisp/pylint.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/elisp/pylint.el b/elisp/pylint.el
index dd623470d..2a447e38a 100644
--- a/elisp/pylint.el
+++ b/elisp/pylint.el
@@ -64,6 +64,11 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
:type '(repeat string)
:group 'pylint)
+(defcustom pylint-use-python-indent-offset nil
+ "If non-nil, use `python-indent-offset' to set indent-string."
+ :type 'boolean
+ :group 'pylint)
+
(defcustom pylint-command "pylint"
"PYLINT command."
:type '(file)
@@ -179,6 +184,11 @@ appending to an existing list)."
"Keymap for PYLINT buffers.
`compilation-minor-mode-map' is a cdr of this.")
+(defun pylint--make-indent-string ()
+ "Make a string for the `--indent-string' option."
+ (format "--indent-string='%s'"
+ (make-string python-indent-offset ?\ )))
+
;;;###autoload
(defun pylint (&optional arg)
"Run PYLINT, and collect output in a buffer, much like `compile'.
@@ -199,6 +209,10 @@ output buffer, to go to the lines where pylint found matches.
(pylint-command (if arg
pylint-alternate-pylint-command
pylint-command))
+ (pylint-options (if (not pylint-use-python-indent-offset)
+ pylint-options
+ (append pylint-options
+ (list (pylint--make-indent-string)))))
(command (mapconcat
'identity
(append `(,pylint-command) pylint-options `(,filename))