- (if (or delphi-tab-always-indents ; We are always indenting
- ;; Or we are before the first non-space character on the line.
- (save-excursion (skip-chars-backward delphi-space-chars) (bolp)))
- (delphi-indent-line)
- (insert "\t")))
+ (cond ((use-region-p)
+ ;; If Transient Mark mode is enabled and the region is active, indent
+ ;; the entire region.
+ (indent-region (region-beginning) (region-end)))
+ ((or delphi-tab-always-indents
+ (save-excursion (skip-chars-backward delphi-space-chars) (bolp)))
+ ;; Otherwise, if we are configured always to indent (regardless of the
+ ;; point's position in the line) or we are before the first non-space
+ ;; character on the line, indent the line.
+ (delphi-indent-line))
+ (t
+ ;; Otherwise, insert a tab character.
+ (insert "\t"))))