[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9dfa949: * lisp/progmodes/python.el: Recognize docs
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 9dfa949: * lisp/progmodes/python.el: Recognize docstrings. |
Date: |
Sun, 07 Dec 2014 16:24:47 +0000 |
branch: master
commit 9dfa949c0d24b8b74104e5cd1ac2fc0bdaa37341
Author: Tom Willemse <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/progmodes/python.el: Recognize docstrings.
(python-docstring-at-p, python-font-lock-syntactic-face-function):
New functions.
(python-mode): Use them.
---
lisp/ChangeLog | 14 ++++++++++----
lisp/progmodes/python.el | 22 +++++++++++++++++++++-
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f695e1c..50df1cd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,9 +1,16 @@
+2014-12-07 Tom Willemse <address@hidden> (tiny change)
+
+ * progmodes/python.el: Recognize docstrings.
+ (python-docstring-at-p, python-font-lock-syntactic-face-function):
+ New functions.
+ (python-mode): Use them.
+
2014-12-06 Ulf Jasper <address@hidden>
* net/newst-treeview.el (newsticker--treeview-list-add-item)
(newsticker--treeview-propertize-tag): Bind tree menu to mouse-3.
(newsticker--treeview-create-groups-menu)
- (newsticker--treeview-create-tree-menu): Removed.
+ (newsticker--treeview-create-tree-menu): Remove.
(newsticker--treeview-tree-open-menu): New.
(newsticker-treeview-tree-click): Pass event to
`newsticker-treeview-tree-do-click'.
@@ -20,8 +27,8 @@
2014-12-05 Juri Linkov <address@hidden>
- * minibuffer.el (minibuffer-completion-help): Compare
- selected-window with minibuffer-window to check whether
+ * minibuffer.el (minibuffer-completion-help):
+ Compare selected-window with minibuffer-window to check whether
completions should be displayed near the minibuffer. (Bug#17809)
http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg00311.html
@@ -52,7 +59,6 @@
both in terms of the column to which it moves and the return
value. (Bug#19211)
-2014-12-05 Stephen Berman <address@hidden>
2014-12-05 Stefan Monnier <address@hidden>
* vc/ediff-init.el (ediff-odd-p): Remove.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 9f9db6c..33c822a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -459,6 +459,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-docstring-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-docstring-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
@@ -4312,7 +4329,10 @@ Arguments START and END narrow the buffer region to work
on."
'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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9dfa949: * lisp/progmodes/python.el: Recognize docstrings.,
Stefan Monnier <=