diff options
| author | Stefan Monnier | 2015-10-06 22:56:24 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-10-06 22:56:24 -0400 |
| commit | f54e5ccfdbe2f1aa4e6e072657659017d2cbaf86 (patch) | |
| tree | 00082eab657816257f3f866a528fa0f8e5b6f58e | |
| parent | 3b4d119c40817a528be5ad2bb994521a947dc443 (diff) | |
| download | emacs-f54e5ccfdbe2f1aa4e6e072657659017d2cbaf86.tar.gz emacs-f54e5ccfdbe2f1aa4e6e072657659017d2cbaf86.zip | |
* lisp/indent.el (indent--default-inside-comment): New function
(indent-for-tab-command): Use it for `noindent' indentation.
| -rw-r--r-- | lisp/indent.el | 22 |
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. |
| 91 | This function either inserts a tab, or indents the current line, | 107 | This 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. |