From 20b1d07968d9e99693ea14efb32cd65bbb176bfe Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 7 Oct 2000 04:13:09 +0000 Subject: [PATCH] (tab-always-indent): New var. (indent-for-tab-command): Use it. --- lisp/ChangeLog | 5 ++++- lisp/indent.el | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 72e2fb27d15..753abd71091 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,4 +1,7 @@ -2000-10-06 Stefan Monnier +2000-10-07 Stefan Monnier + + * indent.el (tab-always-indent): New var. + (indent-for-tab-command): Use it. * files.el (set-auto-mode): Ignore unknown -*- mode -*- rather than raise an error. This way it can still defaults to a sane value. diff --git a/lisp/indent.el b/lisp/indent.el index 1a7193893c4..648d928a1f3 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -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) -- 2.39.2