X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/d29ee6b1a110cf5d170a10317a96acbbd4a1c68b..3a0f6aac0db3b1961c759a278d2bc67b501ddd0a:/lisp/indent.el diff --git a/lisp/indent.el b/lisp/indent.el index 225395dcc8..f942847ec6 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -1,16 +1,16 @@ ;;; indent.el --- indentation commands for Emacs ;; Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007 Free Software Foundation, Inc. +;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;; Maintainer: FSF ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,9 +18,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -42,7 +40,7 @@ "Function to indent the current line. This function will be called with no arguments. If it is called somewhere where auto-indentation cannot be done -\(f.ex. inside a string), the function should simply return `noindent'. +\(e.g. inside a string), the function should simply return `noindent'. Setting this function is all you need to make TAB indent appropriately. Don't rebind TAB unless you really need to.") @@ -82,14 +80,20 @@ special; we don't actually use them here." 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. -If `transient-mark-mode' is turned on the region is active, -indent the region. + +If a prefix argument is given, also rigidly indent the entire +balanced expression which starts at the beginning the current +line to reflect the current line's change in indentation. + +If `transient-mark-mode' is turned on and the region is active, +indent the region (in this case, any prefix argument is ignored). + The function actually called to indent the line is determined by the value of `indent-line-function'." - (interactive "p") + (interactive "P") (cond ;; The region is active, indent it. - ((and arg transient-mark-mode mark-active + ((and transient-mark-mode mark-active (not (eq (region-beginning) (region-end)))) (indent-region (region-beginning) (region-end))) ((or ;; indent-to-left-margin is only meant for indenting, @@ -99,13 +103,27 @@ The function actually called to indent the line is determined by the value of (or (> (current-column) (current-indentation)) (eq this-command last-command)))) (insert-tab arg)) - ;; Those functions are meant specifically for tabbing and not for - ;; indenting, so we can't pass them to indent-according-to-mode. - ((memq indent-line-function '(indent-relative indent-relative-maybe)) - (funcall indent-line-function)) - ;; Indent the line. (t - (indent-according-to-mode)))) + (let ((end-marker + (and arg + (save-excursion + (forward-line 0) (forward-sexp) (point-marker)))) + (old-indent + (current-indentation))) + + ;; Indent the line. + (funcall indent-line-function) + + ;; If a prefix argument was given, rigidly indent the following + ;; sexp to match the change in the current line's indentation. + ;; + (when arg + (let ((indentation-change (- (current-indentation) old-indent))) + (unless (zerop indentation-change) + (save-excursion + (forward-line 1) + (when (< (point) end-marker) + (indent-rigidly (point) end-marker indentation-change)))))))))) (defun insert-tab (&optional arg) (let ((count (prefix-numeric-value arg))) @@ -557,5 +575,5 @@ 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 +;; arch-tag: f402b2a7-e44f-492f-b5b8-38996020b7c3 ;;; indent.el ends here