Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; python-shell-send-defun (bugfix)
- (with-eval-after-load 'python
- (require 'rx)
- (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))
- (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 (forward-line -1)
- (looking-at (python-rx decorator))))
- (forward-line 1))
- (point-marker))
- (progn
- (forward-line) ;; fixes a bug when a function has a decorator
- (or (python-nav-end-of-defun)
- (end-of-line 1))
- (point-marker))
- nil ;; noop
- msg))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement