]> git.eshelyaron.com Git - emacs.git/commitdiff
(tab-always-indent): New var.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 7 Oct 2000 04:13:09 +0000 (04:13 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 7 Oct 2000 04:13:09 +0000 (04:13 +0000)
(indent-for-tab-command): Use it.

lisp/ChangeLog
lisp/indent.el

index 72e2fb27d1503db443293c2a1f7fe26fbd445011..753abd71091a8b18cdbde6087e3d4ddcdd2a675c 100644 (file)
@@ -1,4 +1,7 @@
-2000-10-06  Stefan Monnier  <monnier@cs.yale.edu>
+2000-10-07  Stefan Monnier  <monnier@cs.yale.edu>
+
+       * 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.
index 1a7193893c4af5dbbc13a87cc162ad2093f3cc49..648d928a1f3b0a46b581d775411b237d704d1585 100644 (file)
 (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)