X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2db38a6f98c2abb42b746064ce97417cccc27e68..ce1438d696bd670b5aba5690ce4f73b836b20194:/lisp/indent.el diff --git a/lisp/indent.el b/lisp/indent.el index 12cf9c9bb5..9321803270 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -1,9 +1,9 @@ ;;; indent.el --- indentation commands for Emacs -;; Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1985, 1995, 2001-2011 Free Software Foundation, Inc. ;; Maintainer: FSF +;; Package: emacs ;; This file is part of GNU Emacs. @@ -55,7 +55,11 @@ was already indented, then try to complete the thing at point. Some programming language modes have their own variable to control this, e.g., `c-tab-always-indent', and do not respect this variable." :group 'indent - :type '(choice (const nil) (const t) (const always))) + :type '(choice + (const :tag "Always indent" t) + (const :tag "Indent if inside indentation, else TAB" nil) + (const :tag "Indent, or if already indented complete" complete))) + (defun indent-according-to-mode () "Indent line in proper way for current major mode. @@ -63,6 +67,7 @@ The buffer-local variable `indent-line-function' determines how to do this, but the functions `indent-relative' and `indent-relative-maybe' are special; we don't actually use them here." (interactive) + (syntax-propertize (line-end-position)) (if (memq indent-line-function '(indent-relative indent-relative-maybe)) ;; These functions are used for tabbing, but can't be used for @@ -81,8 +86,10 @@ special; we don't actually use them here." (defun indent-for-tab-command (&optional arg) "Indent line or region in proper way for current major mode or insert a tab. Depending on `tab-always-indent', either insert a tab or indent. -If initial point was within line's indentation, position after -the indentation. Else stay at same point in text. + +In most major modes, if point was in the current line's indentation, +it is moved to the first non-whitespace character after indenting; +otherwise it stays at the same position in the text. If a prefix argument is given, also rigidly indent the entire balanced expression which starts at the beginning of the current @@ -411,7 +418,7 @@ column to indent to; if it is nil, use one of the three methods above." (goto-char start) (while (< (point) end) (or (and (bolp) (eolp)) - (funcall indent-line-function)) + (indent-according-to-mode)) (forward-line 1)) (move-marker end nil)))) (setq column (prefix-numeric-value column)) @@ -425,7 +432,11 @@ column to indent to; if it is nil, use one of the three methods above." (or (eolp) (indent-to column 0)) (forward-line 1)) - (move-marker end nil)))) + (move-marker end nil))) + ;; In most cases, reindenting modifies the buffer, but it may also + ;; leave it unmodified, in which case we have to deactivate the mark + ;; by hand. + (deactivate-mark)) (defun indent-relative-maybe () "Indent a new line like previous nonblank line. @@ -550,8 +561,8 @@ Use \\[edit-tab-stops] to edit them interactively." (while (and tabs (>= (current-column) (car tabs))) (setq tabs (cdr tabs))) (if tabs - (let ((opoint (point))) - (delete-horizontal-space t) + (progn + (delete-horizontal-space t) (indent-to (car tabs))) (insert ?\s)))) @@ -583,5 +594,4 @@ Use \\[edit-tab-stops] to edit them interactively." (define-key ctl-x-map "\t" 'indent-rigidly) (define-key esc-map "i" 'tab-to-tab-stop) -;; arch-tag: f402b2a7-e44f-492f-b5b8-38996020b7c3 ;;; indent.el ends here