HideIfDef mode bug fixes and enhancements. This is #2 of 3 patches based
[bpt/emacs.git] / lisp / indent.el
index 4b51cf0..2082070 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1985, 1995, 2001-2014 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Package: emacs
 
 ;; This file is part of GNU Emacs.
@@ -249,7 +249,7 @@ indentation by specifying a large negative ARG."
   (indent-rigidly--pop-undo)
   (let* ((current (indent-rigidly--current-indentation beg end))
         (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
-        (next (indent--next-tab-stop current (if rtl nil 'prev))))
+        (next (indent-next-tab-stop current (if rtl nil 'prev))))
     (indent-rigidly beg end (- next current))))
 
 (defun indent-rigidly-right-to-tab-stop (beg end)
@@ -258,14 +258,14 @@ indentation by specifying a large negative ARG."
   (indent-rigidly--pop-undo)
   (let* ((current (indent-rigidly--current-indentation beg end))
         (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
-        (next (indent--next-tab-stop current (if rtl 'prev))))
+        (next (indent-next-tab-stop current (if rtl 'prev))))
     (indent-rigidly beg end (- next current))))
 
 (defun indent-line-to (column)
   "Indent current line to COLUMN.
 This function removes or adds spaces and tabs at beginning of line
 only if necessary.  It leaves point at end of indentation."
-  (back-to-indentation)
+  (backward-to-indentation 0)
   (let ((cur-col (current-column)))
     (cond ((< cur-col column)
           (if (>= (- column (* (/ cur-col tab-width) tab-width)) tab-width)
@@ -274,7 +274,7 @@ only if necessary.  It leaves point at end of indentation."
           (indent-to column))
          ((> cur-col column) ; too far right (after tab?)
           (delete-region (progn (move-to-column column t) (point))
-                         (progn (back-to-indentation) (point)))))))
+                         (progn (backward-to-indentation 0) (point)))))))
 
 (defun current-left-margin ()
   "Return the left margin to use for this line.
@@ -586,16 +586,17 @@ See also `indent-relative-maybe'."
          (move-marker opoint nil))
       (tab-to-tab-stop))))
 
-(defcustom tab-stop-list
-  nil
+(defcustom tab-stop-list nil
   "List of tab stop positions used by `tab-to-tab-stop'.
-This should be a list of integers, ordered from smallest to largest.
-It implicitly extends to infinity by repeating the last step (e.g. '(1 2 5)
-is equivalent to '(1 2 5 8 11)).
-If the list has less than 2 elements, `tab-width' is used as the \"last step\"."
+This should be nil, or a list of integers, ordered from smallest to largest.
+It implicitly extends to infinity through repetition of the last step.
+For example, '(1 2 5) is equivalent to '(1 2 5 8 11 ...).  If the list has
+fewer than 2 elements, `tab-width' is used as the \"last step\".
+A value of nil means a tab stop every `tab-width' columns."
   :group 'indent
+  :version "24.4"                       ; from explicit list to nil
+  :safe 'listp
   :type '(repeat integer))
-(put 'tab-stop-list 'safe-local-variable 'listp)
 
 (defvar edit-tab-stops-map
   (let ((map (make-sparse-keymap)))
@@ -653,7 +654,7 @@ You can add or remove colons and then do \\<edit-tab-stops-map>\\[edit-tab-stops
       (setq tab-stop-list tabs))
   (message "Tab stops installed"))
 
-(defun indent--next-tab-stop (column &optional prev)
+(defun indent-next-tab-stop (column &optional prev)
   "Return the next tab stop after COLUMN.
 If PREV is non-nil, return the previous one instead."
   (let ((tabs tab-stop-list))
@@ -676,6 +677,13 @@ If PREV is non-nil, return the previous one instead."
                             (if (<= column last) -1 (/ (- column last 1) step))
                           (1+ (/ (- column last) step)))))))))
 
+(defun indent-accumulate-tab-stops (limit)
+  "Get a list of tab stops before LIMIT (inclusive)."
+  (let ((tab 0) (tab-stops))
+    (while (<= (setq tab (indent-next-tab-stop tab)) limit)
+      (push tab tab-stops))
+    (nreverse tab-stops)))
+
 (defun tab-to-tab-stop ()
   "Insert spaces or tabs to next defined tab-stop column.
 The variable `tab-stop-list' is a list of columns at which there are tab stops.
@@ -683,7 +691,7 @@ Use \\[edit-tab-stops] to edit them interactively."
   (interactive)
   (and abbrev-mode (= (char-syntax (preceding-char)) ?w)
        (expand-abbrev))
-  (let ((nexttab (indent--next-tab-stop (current-column))))
+  (let ((nexttab (indent-next-tab-stop (current-column))))
     (delete-horizontal-space t)
     (indent-to nexttab)))
 
@@ -692,7 +700,7 @@ Use \\[edit-tab-stops] to edit them interactively."
 The variable `tab-stop-list' is a list of columns at which there are tab stops.
 Use \\[edit-tab-stops] to edit them interactively."
   (interactive)
-  (let ((nexttab (indent--next-tab-stop (current-column))))
+  (let ((nexttab (indent-next-tab-stop (current-column))))
     (let ((before (point)))
       (move-to-column nexttab t)
       (save-excursion