Commit 85655287 authored by Fabián Ezequiel Gallina's avatar Fabián Ezequiel Gallina Committed by Fabián Ezequiel Gallina
Browse files

Make python-info-continuation-line-p to check context type matches

In order for a line to be continuation of another, they must be on the
same context.

New Function:
    * python-info-ppss-context-type
parent 64348c32
......@@ -2302,6 +2302,13 @@ not inside a defun."
(defun python-info-continuation-line-p ()
"Return non-nil if current line is continuation of another."
(let ((current-ppss-context-type (python-info-ppss-context-type)))
(and
(equal (save-excursion
(goto-char (line-end-position))
(forward-comment 9999)
(python-info-ppss-context-type))
current-ppss-context-type)
(or (python-info-line-ends-backslash-p)
(string-match ",[[:space:]]*$" (buffer-substring
(line-beginning-position)
......@@ -2317,7 +2324,7 @@ not inside a defun."
(looking-at (python-rx open-paren (* space) line-end)))))
(save-excursion
(back-to-indentation)
(python-info-ppss-context 'paren))))
(python-info-ppss-context 'paren))))))
(defun python-info-block-continuation-line-p ()
"Return non-nil if current line is a continuation of a block."
......@@ -2351,7 +2358,7 @@ not inside a defun."
(defun python-info-ppss-context (type &optional syntax-ppss)
"Return non-nil if point is on TYPE using SYNTAX-PPSS.
TYPE can be 'comment, 'string or 'parent. It returns the start
TYPE can be 'comment, 'string or 'paren. It returns the start
character address of the specified TYPE."
(let ((ppss (or syntax-ppss (syntax-ppss))))
(case type
......@@ -2364,6 +2371,20 @@ character address of the specified TYPE."
(nth 1 ppss))
(t nil))))
(defun python-info-ppss-context-type (&optional syntax-ppss)
"Return the context type using SYNTAX-PPSS.
The type returned can be 'comment, 'string or 'paren."
(let ((ppss (or syntax-ppss (syntax-ppss))))
(cond
((and (nth 4 ppss)
(nth 8 ppss))
'comment)
((nth 8 ppss)
'string)
((nth 1 ppss)
'paren)
(t nil))))
;;; Utility functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment