From 00c1dbbf729b1180963abb6743116ec4c8c6b5ad Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 25 Dec 2024 21:26:05 +0000 Subject: [PATCH] Comment for indent-for-tab-command as a first step to refactoring. --- lisp/indent.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/indent.el b/lisp/indent.el index 74ef9183d95..613454918b8 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -160,6 +160,7 @@ prefix argument is ignored." ;; The region is active, indent it. ((use-region-p) (indent-region (region-beginning) (region-end))) + ;; *1.* inserts a tab character for special indentation cases. ((or ;; indent-to-left-margin is only meant for indenting, ;; so we force it to always insert a tab here. (eq indent-line-function 'indent-to-left-margin) @@ -172,15 +173,17 @@ prefix argument is ignored." (old-point (point)) (old-indent (current-indentation))) - ;; Indent the line. + ;; *2.* Indent the line with specified function (or (not (eq (indent--funcall-widened indent-line-function) 'noindent)) + ;; *3.* Indent comment (indent--default-inside-comment) + ;; *4.* Fallback to default indent function (when (or (<= (current-column) (current-indentation)) (not (eq tab-always-indent 'complete))) (indent--funcall-widened (default-value 'indent-line-function)))) (cond - ;; If the text was already indented right, try completion. + ;; *5.* If the text was already indented right, try completion. ((and (eq tab-always-indent 'complete) (eql old-point (point)) (eql old-tick (buffer-chars-modified-tick)) @@ -193,9 +196,9 @@ prefix argument is ignored." ('word-or-paren (not (memq syn '(2 4 5)))) ('word-or-paren-or-punct (not (memq syn '(2 4 5 1)))))))) (completion-at-point)) - - ;; If a prefix argument was given, rigidly indent the following - ;; sexp to match the change in the current line's indentation. + ;; *6* If a prefix argument was given, rigidly indent the + ;; following sexp to match the change in the current line's + ;; indentation. (arg (let ((end-marker (save-excursion -- 2.45.2