aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/indent.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/lisp/indent.el b/lisp/indent.el
index 18c1fd48db7..cba8f755f8f 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -86,6 +86,22 @@ that case, indent by aligning to the previous non-blank line."
86 ;; The normal case. 86 ;; The normal case.
87 (funcall indent-line-function))) 87 (funcall indent-line-function)))
88 88
89(defun indent--default-inside-comment ()
90 (unless (or (> (current-column) (current-indentation))
91 (eq this-command last-command))
92 (let ((ppss (syntax-ppss)))
93 (when (nth 4 ppss)
94 (indent-line-to
95 (save-excursion
96 (forward-line -1)
97 (skip-chars-forward " \t")
98 (when (< (1- (point)) (nth 8 ppss) (line-end-position))
99 (goto-char (nth 8 ppss))
100 (when (looking-at comment-start-skip)
101 (goto-char (match-end 0))))
102 (current-column)))
103 t))))
104
89(defun indent-for-tab-command (&optional arg) 105(defun indent-for-tab-command (&optional arg)
90 "Indent the current line or region, or insert a tab, as appropriate. 106 "Indent the current line or region, or insert a tab, as appropriate.
91This function either inserts a tab, or indents the current line, 107This function either inserts a tab, or indents the current line,
@@ -124,7 +140,11 @@ prefix argument is ignored."
124 (old-indent (current-indentation))) 140 (old-indent (current-indentation)))
125 141
126 ;; Indent the line. 142 ;; Indent the line.
127 (funcall indent-line-function) 143 (or (not (eq (funcall indent-line-function) 'noindent))
144 (indent--default-inside-comment)
145 (when (or (<= (current-column) (current-indentation))
146 (not (eq tab-always-indent 'complete)))
147 (funcall (default-value 'indent-line-function))))
128 148
129 (cond 149 (cond
130 ;; If the text was already indented right, try completion. 150 ;; If the text was already indented right, try completion.