From: Stefan Monnier Date: Wed, 7 Oct 2015 02:56:24 +0000 (-0400) Subject: * lisp/indent.el (indent--default-inside-comment): New function X-Git-Tag: emacs-25.0.90~1212 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f54e5ccfdbe2f1aa4e6e072657659017d2cbaf86;p=emacs.git * lisp/indent.el (indent--default-inside-comment): New function (indent-for-tab-command): Use it for `noindent' indentation. --- 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." ;; The normal case. (funcall indent-line-function))) +(defun indent--default-inside-comment () + (unless (or (> (current-column) (current-indentation)) + (eq this-command last-command)) + (let ((ppss (syntax-ppss))) + (when (nth 4 ppss) + (indent-line-to + (save-excursion + (forward-line -1) + (skip-chars-forward " \t") + (when (< (1- (point)) (nth 8 ppss) (line-end-position)) + (goto-char (nth 8 ppss)) + (when (looking-at comment-start-skip) + (goto-char (match-end 0)))) + (current-column))) + t)))) + (defun indent-for-tab-command (&optional arg) "Indent the current line or region, or insert a tab, as appropriate. This function either inserts a tab, or indents the current line, @@ -124,7 +140,11 @@ prefix argument is ignored." (old-indent (current-indentation))) ;; Indent the line. - (funcall indent-line-function) + (or (not (eq (funcall indent-line-function) 'noindent)) + (indent--default-inside-comment) + (when (or (<= (current-column) (current-indentation)) + (not (eq tab-always-indent 'complete))) + (funcall (default-value 'indent-line-function)))) (cond ;; If the text was already indented right, try completion.