diff options
| author | Fabián Ezequiel Gallina | 2012-07-17 17:27:49 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-07-17 17:27:49 -0300 |
| commit | 0a60bc107123321438fc1320ab34fcf588ec7128 (patch) | |
| tree | ccb0762019c5fe2ad43bc786aef6a7907948039f /lisp/progmodes/python.el | |
| parent | 6dafa0d5352ada03f9a6db6ba8d3eec8f7884642 (diff) | |
| download | emacs-0a60bc107123321438fc1320ab34fcf588ec7128.tar.gz emacs-0a60bc107123321438fc1320ab34fcf588ec7128.zip | |
New utility functions + python-info-ppss-context fix.
* progmodes/python.el (python-info-beginning-of-block-statement-p)
(python-info-ppss-comment-or-string-p): New functions.
(python-info-ppss-context): Small fix for string check.
Fixes: debbugs:11910
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e9b5770dc87..54486ba5a52 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2584,6 +2584,12 @@ not inside a defun." | |||
| 2584 | (when names | 2584 | (when names |
| 2585 | (mapconcat (lambda (string) string) names ".")))) | 2585 | (mapconcat (lambda (string) string) names ".")))) |
| 2586 | 2586 | ||
| 2587 | (defsubst python-info-beginning-of-block-statement-p () | ||
| 2588 | "Return non-nil if current statement opens a block." | ||
| 2589 | (save-excursion | ||
| 2590 | (python-nav-beginning-of-statement) | ||
| 2591 | (looking-at (python-rx block-start)))) | ||
| 2592 | |||
| 2587 | (defun python-info-closing-block () | 2593 | (defun python-info-closing-block () |
| 2588 | "Return the point of the block the current line closes." | 2594 | "Return the point of the block the current line closes." |
| 2589 | (let ((closing-word (save-excursion | 2595 | (let ((closing-word (save-excursion |
| @@ -2736,7 +2742,8 @@ character address of the specified TYPE." | |||
| 2736 | (and (nth 4 ppss) | 2742 | (and (nth 4 ppss) |
| 2737 | (nth 8 ppss))) | 2743 | (nth 8 ppss))) |
| 2738 | ('string | 2744 | ('string |
| 2739 | (nth 8 ppss)) | 2745 | (and (not (nth 4 ppss)) |
| 2746 | (nth 8 ppss))) | ||
| 2740 | ('paren | 2747 | ('paren |
| 2741 | (nth 1 ppss)) | 2748 | (nth 1 ppss)) |
| 2742 | (t nil)))) | 2749 | (t nil)))) |
| @@ -2755,6 +2762,10 @@ The type returned can be 'comment, 'string or 'paren." | |||
| 2755 | 'paren) | 2762 | 'paren) |
| 2756 | (t nil)))) | 2763 | (t nil)))) |
| 2757 | 2764 | ||
| 2765 | (defsubst python-info-ppss-comment-or-string-p () | ||
| 2766 | "Return non-nil if point is inside 'comment or 'string." | ||
| 2767 | (car (member (python-info-ppss-context-type) '(string comment)))) | ||
| 2768 | |||
| 2758 | (defun python-info-looking-at-beginning-of-defun (&optional syntax-ppss) | 2769 | (defun python-info-looking-at-beginning-of-defun (&optional syntax-ppss) |
| 2759 | "Check if point is at `beginning-of-defun' using SYNTAX-PPSS." | 2770 | "Check if point is at `beginning-of-defun' using SYNTAX-PPSS." |
| 2760 | (and (not (python-info-ppss-context-type (or syntax-ppss (syntax-ppss)))) | 2771 | (and (not (python-info-ppss-context-type (or syntax-ppss (syntax-ppss)))) |