Function: indent-line-to
indent-line-to is a byte-compiled function defined in indent.el.gz.
Signature
(indent-line-to COLUMN)
Documentation
Indent current line to COLUMN.
This function removes or adds spaces and tabs at beginning of line only if necessary. It leaves point at end of indentation.
Probably introduced at or before Emacs version 19.29.
Aliases
org-indent-line-to (obsolete since 9.0)
Source Code
;; Defined in /usr/src/emacs/lisp/indent.el.gz
(defun indent-line-to (column)
"Indent current line to COLUMN.
This function removes or adds spaces and tabs at beginning of line
only if necessary. It leaves point at end of indentation."
(beginning-of-line 1)
(skip-chars-forward " \t")
(let ((cur-col (current-column)))
(cond ((< cur-col column)
(if (>= (- column (* (/ cur-col tab-width) tab-width)) tab-width)
(delete-region (point)
(progn (skip-chars-backward " ") (point))))
(indent-to column))
((> cur-col column) ; too far right (after tab?)
(delete-region (progn (move-to-column column t) (point))
;; The `move-to-column' call may replace
;; tabs with spaces, so we can't reuse the
;; previous start point.
(progn (beginning-of-line 1)
(skip-chars-forward " \t")
(point)))))))