# HG changeset patch # User Stefan Monnier # Date 970891978 0 # Node ID 6da78b4b7be255e699b09bca70f2df8ddeae907c # Parent b608b3042a8d1addcbe2241559198088e508a9b2 (tab-always-indent): New var. (indent-for-tab-command): Use it. diff -r b608b3042a8d -r 6da78b4b7be2 lisp/indent.el --- a/lisp/indent.el Sat Oct 07 03:05:14 2000 +0000 +++ b/lisp/indent.el Sat Oct 07 04:12:58 2000 +0000 @@ -40,19 +40,30 @@ (defvar indent-line-function 'indent-to-left-margin "Function to indent current line.") +(defcustom tab-always-indent t + "*Controls the operation of the TAB key. +If t, hitting TAB always just indents the current line. +If nil, hitting TAB indents the current line if point is at the left margin + or in the line's indentation, otherwise it insert a `real' tab character." + :group 'indent + :type 'boolean) + (defun indent-according-to-mode () "Indent line in proper way for current major mode." (interactive) (funcall indent-line-function)) (defun indent-for-tab-command (&optional prefix-arg) - "Indent line in proper way for current major mode. + "Indent line 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. -The function actually called is determined by the value of +The function actually called to indent is determined by the value of `indent-line-function'." (interactive "P") - (if (eq indent-line-function 'indent-to-left-margin) + (if (or (eq indent-line-function 'indent-to-left-margin) + (and (not tab-always-indent) + (> (current-column) (current-indentation)))) (insert-tab prefix-arg) (if prefix-arg (funcall indent-line-function prefix-arg)