[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master f54e5cc: * lisp/indent.el (indent--default-inside-c
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master f54e5cc: * lisp/indent.el (indent--default-inside-comment): New function |
Date: |
Wed, 07 Oct 2015 02:56:37 +0000 |
branch: master
commit f54e5ccfdbe2f1aa4e6e072657659017d2cbaf86
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/indent.el (indent--default-inside-comment): New function
(indent-for-tab-command): Use it for `noindent' indentation.
---
lisp/indent.el | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/lisp/indent.el b/lisp/indent.el
index 18c1fd4..cba8f75 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master f54e5cc: * lisp/indent.el (indent--default-inside-comment): New function,
Stefan Monnier <=