Function: combobulate-python-indent-for-tab-command
combobulate-python-indent-for-tab-command is an interactive and
natively compiled function defined in combobulate-python.el.
Signature
(combobulate-python-indent-for-tab-command &optional ARG)
Documentation
Wrapper for indent-for-tab-command that adds advanced indentation.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-python.el
(defun combobulate-python-indent-for-tab-command (&optional arg)
"Wrapper for `indent-for-tab-command' that adds advanced indentation."
(interactive "P")
(with-navigation-nodes
(:nodes (append
;; rules that trigger indentation
(combobulate-production-rules-get "_simple_statement")
(combobulate-production-rules-get "_compound_statement"))
;; do not skip prefix if we have a region active. the
;; reason for that is that skipping forward with a
;; marked region can bork the indentation mechanism as
;; we can only effectively indent with whole lines.
:skip-prefix (not (use-region-p))
:skip-newline nil)
(let ((node (combobulate--get-nearest-navigable-node)))
(cond
((use-region-p)
;; ensure point is at the beginning of the region
(when (> (point) (mark))
(exchange-point-and-mark))
(combobulate-proffer-indentation node)
;; toggle the region on and off so it doesn't get deactivated
(setq deactivate-mark nil)
(activate-mark))
;; we need to handle blank lines as tabbing on a blank line should
;; default to the regular python indentation mechanism.
((save-excursion
(beginning-of-line)
(looking-at-p "[[:space:]]*$"))
(indent-for-tab-command arg))
;; if we're at the beginning of a node, we want to indent it.
((and combobulate-python-indent-blocks-dwim (combobulate-point-at-beginning-of-node-p node))
(combobulate-proffer-indentation node))
;; for everything else, use the regular indentation mechanism.
(t (indent-for-tab-command arg))))))