From 8d43baefcf9a963802cb89860e9dea3965e69e0e Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.io> Date: Thu, 14 May 2015 12:26:19 -0700 Subject: [PATCH 1/3] Make name alleged in header match filename Thanks @purcell! --- python-docstring.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-docstring.el b/python-docstring.el index d73950e..d905c57 100644 --- a/python-docstring.el +++ b/python-docstring.el @@ -1,4 +1,4 @@ -;;; python-docstring-mode.el --- Smart Python docstring formatting +;;; python-docstring.el --- Smart Python docstring formatting ;; Copyright (c) 2014-2015 The Authors ;; From fe90173b7a2d2926dfb185c1b870c2961f053852 Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.io> Date: Thu, 14 May 2015 12:29:45 -0700 Subject: [PATCH 2/3] Use python-docstring- prefix consistently A namespace! A namespace! My kingdom for a namespace! Thanks @purcell! --- python-docstring.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python-docstring.el b/python-docstring.el index d905c57..abdb3f2 100644 --- a/python-docstring.el +++ b/python-docstring.el @@ -90,22 +90,22 @@ (if fill-it-anyway (call-interactively 'fill-paragraph)))) -(defvar docstring-field-with-arg-re +(defvar python-docstring-field-with-arg-re "^\\s-*[@:]\\(param\\|parameter\\|arg\\|argument\\|type\\|keyword\\|kwarg\\|kwparam\\|raise\\|raises\\|except\\|exception\\|ivar\\|ivariable\\|cvar\\|cvariable\\|var\\|variable\\|type\\|group\\|todo\\|newfield\\)\\s-+\\([a-zA-Z_][a-zA-Z0-9_. ]*?\\):") -(defvar docstring-field-no-arg-re +(defvar python-docstring-field-no-arg-re "^\\s-*[@:]\\(raise\\|raises\\|return\\|returns\\|rtype\\|returntype\\|type\\|sort\\|see\\|seealso\\|note\\|attention\\|bug\\|warning\\|warn\\|version\\|todo\\|deprecated\\|since\\|status\\|change\\|changed\\|permission\\|requires\\|require\\|requirement\\|precondition\\|precond\\|postcondition\\|postcod\\|invariant\\|author\\|organization\\|org\\|copyright\\|(c)\\|license\\|contact\\|summary\\|params\\|param\\):") -(defvar docstring-epytext-markup-link "[UL]{\\([^}]*?\\)\\(<.*?>\\|\\)?}") -(defvar docstring-epytext-markup-style-code "C{\\(.*?\\)}") -(defvar docstring-epytext-markup-style-italic "I{\\(.*?\\)}") -(defvar docstring-epytext-markup-style-bold "B{\\(.*?\\)}") +(defvar python-docstring-epytext-markup-link "[UL]{\\([^}]*?\\)\\(<.*?>\\|\\)?}") +(defvar python-docstring-epytext-markup-style-code "C{\\(.*?\\)}") +(defvar python-docstring-epytext-markup-style-italic "I{\\(.*?\\)}") +(defvar python-docstring-epytext-markup-style-bold "B{\\(.*?\\)}") ;; hack for sphinx -(defvar docstring-sphinx-markup-link "\\(:[^:]+?:\\)\\(`.+?`\\)") -(defvar docstring-sphinx-markup-code "``\\(.+?\\)``") +(defvar python-docstring-sphinx-markup-link "\\(:[^:]+?:\\)\\(`.+?`\\)") +(defvar python-docstring-sphinx-markup-code "``\\(.+?\\)``") -(defvar docstring-keywords +(defvar python-docstring-keywords `((,docstring-field-with-arg-re 1 font-lock-type-face t) (,docstring-field-with-arg-re 2 font-lock-function-name-face t) (,docstring-field-no-arg-re 1 font-lock-type-face t) @@ -151,8 +151,8 @@ Null prefix argument turns off the mode." `(([(meta q)] . python-docstring-fill)) ;; &rest BODY (if python-docstring-mode - (font-lock-add-keywords nil docstring-keywords) - (font-lock-remove-keywords nil docstring-keywords))) + (font-lock-add-keywords nil python-docstring-keywords) + (font-lock-remove-keywords nil python-docstring-keywords))) (defun python-docstring-install () "Add python-docstring-mode as a hook to python.mode." From 7ef78b84489f5c3df108edf41762bf0d422fbfee Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.io> Date: Thu, 14 May 2015 12:36:45 -0700 Subject: [PATCH 3/3] Quote path in case there's spaces or such Thanks, @purcell! --- python-docstring.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-docstring.el b/python-docstring.el index abdb3f2..c206e78 100644 --- a/python-docstring.el +++ b/python-docstring.el @@ -73,7 +73,7 @@ string-start string-end (format "python %s --offset %s --indent %s --width %s" - python-docstring-script + (shell-quote-argument python-docstring-script) orig-offset indent-count fill-column