summaryrefslogtreecommitdiffstats
path: root/packages/app-editors/emacs/files/emacs-python-docstrings.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/app-editors/emacs/files/emacs-python-docstrings.patch')
-rw-r--r--packages/app-editors/emacs/files/emacs-python-docstrings.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/app-editors/emacs/files/emacs-python-docstrings.patch b/packages/app-editors/emacs/files/emacs-python-docstrings.patch
new file mode 100644
index 0000000..0baa5f6
--- /dev/null
+++ b/packages/app-editors/emacs/files/emacs-python-docstrings.patch
@@ -0,0 +1,40 @@
+diff --git a/python.el b/python.el
+index 54a657a..f01360c 100644
+--- a/lisp/progmodes/python.el
++++ b/lisp/progmodes/python.el
+@@ -405,6 +405,23 @@ The type returned can be `comment', `string' or `paren'."
+ 'python-info-ppss-comment-or-string-p
+ #'python-syntax-comment-or-string-p "24.3")
+
++(defun python-doc-string-at-p (pos)
++ "Check to see if there is a docstring at POS."
++ (save-excursion
++ (goto-char pos)
++ (if (looking-at-p "'''\\|\"\"\"")
++ (progn
++ (python-nav-backward-statement)
++ (looking-at "\\`\\|class \\|def "))
++ nil)))
++
++(defun python-font-lock-syntactic-face-function (state)
++ (if (nth 3 state)
++ (if (python-doc-string-at-p (nth 8 state))
++ font-lock-doc-face
++ font-lock-string-face)
++ font-lock-comment-face))
++
+ (defvar python-font-lock-keywords
+ ;; Keywords
+ `(,(rx symbol-start
+@@ -3226,7 +3243,10 @@ if that value is non-nil."
+ 'python-nav-forward-sexp)
+
+ (set (make-local-variable 'font-lock-defaults)
+- '(python-font-lock-keywords nil nil nil nil))
++ '(python-font-lock-keywords
++ nil nil nil nil
++ (font-lock-syntactic-face-function
++ . python-font-lock-syntactic-face-function)))
+
+ (set (make-local-variable 'syntax-propertize-function)
+ python-syntax-propertize-function)