Advertisement
Guest User

python-flake8.el

a guest
Apr 4th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. ;;; python-flake8.el --- Thin wrapper around python-pylint to run flake8
  2.  
  3. ;; Copyright (C) 2011 Andi Albrecht
  4.  
  5. ;; Author: Andi Albrecht <[email protected]>
  6. ;; Keywords: languages
  7.  
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12.  
  13. ;; This program is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. ;;; Commentary:
  22.  
  23. ;; This is a thin wrapper around python-pylint
  24. ;; (https://gist.github.com/302848) to run flake8.
  25.  
  26. ;; Sometimes I want to run pylint and sometimes flake8. This simple
  27. ;; wrapper just re-uses python-pylint's compilation mode and
  28. ;; configures it to use flake8 and parses it's output.
  29.  
  30. ;;; Code:
  31.  
  32.  
  33. (defgroup python-flake8 nil
  34. "Wrapper around python-pylint for running flake8"
  35. :prefix "python-flake8-"
  36. :group 'tools)
  37.  
  38. (defconst python-flake8-regexp-alist
  39. (let* ((basepre "^\\(.*\\):\\([0-9]+\\):\\([0-9]+\\):\s+")
  40. (base (concat basepre "\\(%s.*\\)$")))
  41. (list
  42. (list (format base "[FE]") 1 2 3)
  43. (list (format base "[RWC]") 1 2 3 1)
  44. (list (concat basepre ".* is too complex ([0-9]+)$") 1 2)))
  45. "Regexp used to match PYLINT hits. See `compilation-error-regexp-alist'.")
  46.  
  47. (defcustom python-flake8-options '()
  48. "Options to pass to flake8."
  49. :type '(repeat string)
  50. :group 'python-flake8)
  51.  
  52. (defcustom python-flake8-command "flake8"
  53. "flake8 command."
  54. :type '(file)
  55. :group 'python-flake8)
  56.  
  57. (defun python-flake8 ()
  58. "Utilize python-pylint to run flake8 instead."
  59. (interactive)
  60. (let* ((python-pylint-command python-flake8-command)
  61. (python-pylint-options python-flake8-options)
  62. (python-pylint-regexp-alist python-flake8-regexp-alist))
  63. (python-pylint-all)))
  64.  
  65.  
  66. (defalias 'flake8 'python-flake8)
  67.  
  68. (provide 'python-flake8)
  69. ;;; python-flake8.el ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement