Function: python-info-dedenter-opening-block-position

python-info-dedenter-opening-block-position is a byte-compiled function defined in python.el.gz.

Signature

(python-info-dedenter-opening-block-position)

Documentation

Return the point of the closest block the current line closes.

Returns nil if point is not on a dedenter statement or no opening block can be detected. The latter case meaning current file is likely an invalid python file.

Aliases

python-info-closing-block (obsolete since 24.4)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-info-dedenter-opening-block-position ()
  "Return the point of the closest block the current line closes.
Returns nil if point is not on a dedenter statement or no opening
block can be detected.  The latter case meaning current file is
likely an invalid python file."
  (let ((positions (python-info-dedenter-opening-block-positions))
        (indentation (current-indentation))
        (position))
    (while (and (not position)
                positions)
      (save-excursion
        (goto-char (car positions))
        (if (<= (current-indentation) indentation)
            (setq position (car positions))
          (setq positions (cdr positions)))))
    position))