Function: python-shell-send-defun

python-shell-send-defun is an interactive and byte-compiled function defined in python.el.gz.

Signature

(python-shell-send-defun &optional ARG MSG)

Documentation

Send the current defun to inferior Python process.

When argument ARG is non-nil do not include decorators. When optional argument MSG is non-nil, forces display of a user-friendly message if there's no process running; defaults to t when called interactively.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-send-defun (&optional arg msg)
  "Send the current defun to inferior Python process.
When argument ARG is non-nil do not include decorators.  When
optional argument MSG is non-nil, forces display of a
user-friendly message if there's no process running; defaults to
t when called interactively."
  (interactive (list current-prefix-arg t))
  (let ((starting-pos (point)))
    (save-excursion
      (python-shell-send-region
       (progn
         (end-of-line 1)
         (while (and (or (python-nav-beginning-of-defun)
                         (beginning-of-line 1))
                     (> (current-indentation) 0)))
         (when (not arg)
           (while (and
                   (eq (forward-line -1) 0)
                   (if (looking-at (python-rx decorator))
                       t
                     (forward-line 1)
                     nil))))
         (point-marker))
       (progn
         (goto-char starting-pos)
         (or (python-nav-end-of-defun)
             (end-of-line 1))
         (point-marker))
       nil ;; noop
       msg))))