Function: tcl-indent-command
tcl-indent-command is an interactive and byte-compiled function
defined in tcl.el.gz.
Signature
(tcl-indent-command &optional ARG)
Documentation
Indent current line as Tcl code, or in some cases insert a tab character.
If tcl-tab-always-indent is t (the default), always indent current line.
If tcl-tab-always-indent is nil and point is not in the indentation
area at the beginning of the line, a TAB is inserted.
Other values of tcl-tab-always-indent cause the first possible action
from the following list to take place:
1. Move from beginning of line to correct indentation.
2. Delete an empty comment.
3. Move forward to start of comment, indenting if necessary.
4. Move forward to end of line, indenting if necessary.
5. Create an empty comment.
6. Move backward to start of comment, indenting if necessary.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/tcl.el.gz
(defun tcl-indent-command (&optional _arg)
"Indent current line as Tcl code, or in some cases insert a tab character.
If `tcl-tab-always-indent' is t (the default), always indent current line.
If `tcl-tab-always-indent' is nil and point is not in the indentation
area at the beginning of the line, a TAB is inserted.
Other values of `tcl-tab-always-indent' cause the first possible action
from the following list to take place:
1. Move from beginning of line to correct indentation.
2. Delete an empty comment.
3. Move forward to start of comment, indenting if necessary.
4. Move forward to end of line, indenting if necessary.
5. Create an empty comment.
6. Move backward to start of comment, indenting if necessary."
(interactive "p")
(if (memq tcl-tab-always-indent '(nil t))
(let ((tab-always-indent tcl-tab-always-indent))
(call-interactively 'indent-for-tab-command))
;; "Perl-mode" style TAB command.
(let* ((ipoint (point))
(eolpoint (progn
(end-of-line)
(point)))
(comment-p (tcl-in-comment)))
(cond
((= ipoint (line-beginning-position))
(beginning-of-line)
(tcl-indent-line)
;; If indenting didn't leave us in column 0, go to the
;; indentation. Otherwise leave point at end of line. This
;; is a hack.
(if (= (point) (line-beginning-position))
(end-of-line)
(back-to-indentation)))
((and comment-p (looking-at "[ \t]*$"))
;; Empty comment, so delete it. We also delete any ";"
;; characters at the end of the line. I think this is
;; friendlier, but I don't know how other people will feel.
(backward-char)
(skip-chars-backward " \t;")
(delete-region (point) eolpoint))
((and comment-p (< ipoint (point)))
;; Before comment, so skip to it.
(tcl-indent-line)
(indent-for-comment))
((/= ipoint eolpoint)
;; Go to end of line (since we're not there yet).
(goto-char eolpoint)
(tcl-indent-line))
((not comment-p)
(tcl-indent-line)
(comment-indent))
(t
;; Go to start of comment. We don't leave point where it is
;; because we want to skip comment-start-skip.
(tcl-indent-line)
(indent-for-comment))))))