Function: indent-rigidly
indent-rigidly is an interactive and byte-compiled function defined in
indent.el.gz.
Signature
(indent-rigidly START END ARG &optional INTERACTIVE)
Documentation
Indent all lines starting in the region.
If called interactively with no prefix argument, activate a
transient mode in which the indentation can be adjusted interactively
by typing <left> (indent-rigidly-left), <right> (indent-rigidly-right), S-<left> (indent-rigidly-left-to-tab-stop), or S-<right> (indent-rigidly-right-to-tab-stop).
In addition, \TAB is also bound (and calls indent-rigidly-right).
Typing any other key exits this mode, and this key is then
acted upon as normally. If transient-mark-mode(var)/transient-mark-mode(fun) is enabled,
exiting also deactivates the mark.
If called from a program, or interactively with prefix ARG, indent all lines starting in the region forward by ARG columns. If called from a program, START and END specify the beginning and end of the text to act on, in place of the region.
Negative values of ARG indent backward, so you can remove all indentation by specifying a large negative ARG.
Probably introduced at or before Emacs version 24.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/indent.el.gz
(defun indent-rigidly (start end arg &optional interactive)
"Indent all lines starting in the region.
If called interactively with no prefix argument, activate a
transient mode in which the indentation can be adjusted interactively
by typing \\<indent-rigidly-map>\\[indent-rigidly-left], \\[indent-rigidly-right], \\[indent-rigidly-left-to-tab-stop], or \\[indent-rigidly-right-to-tab-stop].
In addition, \\`TAB' is also bound (and calls `indent-rigidly-right').
Typing any other key exits this mode, and this key is then
acted upon as normally. If `transient-mark-mode' is enabled,
exiting also deactivates the mark.
If called from a program, or interactively with prefix ARG,
indent all lines starting in the region forward by ARG columns.
If called from a program, START and END specify the beginning and
end of the text to act on, in place of the region.
Negative values of ARG indent backward, so you can remove all
indentation by specifying a large negative ARG."
(interactive "r\nP\np")
(if (and (not arg) interactive)
(set-transient-map indent-rigidly-map t #'deactivate-mark
"Type %k to indent region interactively")
(save-excursion
(goto-char end)
(setq end (point-marker))
(goto-char start)
(or (bolp) (forward-line 1))
(while (< (point) end)
(let ((indent (current-indentation))
eol-flag)
(save-excursion
(skip-chars-forward " \t")
(setq eol-flag (eolp)))
(or eol-flag
(indent-to (max 0 (+ indent (prefix-numeric-value arg))) 0))
(delete-region (point) (progn (skip-chars-forward " \t") (point))))
(forward-line 1))
(move-marker end nil)
;; Keep the active region in transient mode.
(when (eq (cadr overriding-terminal-local-map) indent-rigidly-map)
(setq deactivate-mark nil)))))