Function: python-nav--beginning-of-block

python-nav--beginning-of-block is a byte-compiled function defined in python.el.gz.

Signature

(python-nav--beginning-of-block)

Documentation

Move to start of current block.

This is an internal implementation of python-nav-beginning-of-block without the navigation cache.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-nav--beginning-of-block ()
  "Move to start of current block.
This is an internal implementation of `python-nav-beginning-of-block'
without the navigation cache."
  (let ((starting-pos (point)))
    ;; Go to first line beginning a statement
    (while (and (not (bobp))
                (or (and (python-nav-beginning-of-statement) nil)
                    (python-info-current-line-comment-p)
                    (python-info-current-line-empty-p)))
      (forward-line -1))
    (if (progn
          (python-nav-beginning-of-statement)
          (looking-at (python-rx block-start)))
        (point-marker)
      (let ((block-matching-indent
             (- (current-indentation) python-indent-offset)))
        (while
            (and (python-nav-backward-block)
                 (> (current-indentation) block-matching-indent)))
        (if (and (looking-at (python-rx block-start))
                 (= (current-indentation) block-matching-indent))
            (point-marker)
          (and (goto-char starting-pos) nil))))))