]> git.eshelyaron.com Git - emacs.git/commitdiff
New utility functions + python-info-ppss-context fix.
authorFabián Ezequiel Gallina <fgallina@gnu.org>
Tue, 17 Jul 2012 20:27:49 +0000 (17:27 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Tue, 17 Jul 2012 20:27:49 +0000 (17:27 -0300)
* 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
lisp/ChangeLog
lisp/progmodes/python.el

index cbc233079a7e73ed83ae59713f596ea379e305b5..6a6093583ab1345053cf9d190a7868f7fb227e6d 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-17  Fabián Ezequiel Gallina  <fgallina@cuca>
+
+       New utility functions + python-info-ppss-context fix (Bug#11910).
+       * 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.
+
 2012-07-17  Juri Linkov  <juri@jurta.org>
 
        * dired-aux.el (dired-do-async-shell-command): Doc fix.
index e9b5770dc878315369f481bc703fe9d02cded999..54486ba5a52c00a29b1e2b85d3101b082b8b3831 100644 (file)
@@ -2584,6 +2584,12 @@ not inside a defun."
     (when names
       (mapconcat (lambda (string) string) names "."))))
 
+(defsubst python-info-beginning-of-block-statement-p ()
+  "Return non-nil if current statement opens a block."
+  (save-excursion
+    (python-nav-beginning-of-statement)
+    (looking-at (python-rx block-start))))
+
 (defun python-info-closing-block ()
   "Return the point of the block the current line closes."
   (let ((closing-word (save-excursion
@@ -2736,7 +2742,8 @@ character address of the specified TYPE."
        (and (nth 4 ppss)
             (nth 8 ppss)))
       ('string
-       (nth 8 ppss))
+       (and (not (nth 4 ppss))
+            (nth 8 ppss)))
       ('paren
        (nth 1 ppss))
       (t nil))))
@@ -2755,6 +2762,10 @@ The type returned can be 'comment, 'string or 'paren."
       'paren)
      (t nil))))
 
+(defsubst python-info-ppss-comment-or-string-p ()
+  "Return non-nil if point is inside 'comment or 'string."
+  (car (member (python-info-ppss-context-type) '(string comment))))
+
 (defun python-info-looking-at-beginning-of-defun (&optional syntax-ppss)
   "Check if point is at `beginning-of-defun' using SYNTAX-PPSS."
   (and (not (python-info-ppss-context-type (or syntax-ppss (syntax-ppss))))