diff options
Diffstat (limited to 'lisp/indent.el')
-rw-r--r-- | lisp/indent.el | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/indent.el b/lisp/indent.el index 8a0f8378653..bf87d6af760 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -65,15 +65,17 @@ e.g., `c-tab-always-indent', and do not respect this variable." "Indent line in proper way for current major mode. Normally, this is done by calling the function specified by the variable `indent-line-function'. However, if the value of that -variable is `indent-relative' or `indent-relative-maybe', handle -it specially (since those functions are used for tabbing); in -that case, indent by aligning to the previous non-blank line." +variable is `indent-relative' or `indent-relative-first-indent-point', +handle it specially (since those functions are used for tabbing); +in that case, indent by aligning to the previous non-blank line." (interactive) (save-restriction (widen) (syntax-propertize (line-end-position)) (if (memq indent-line-function - '(indent-relative indent-relative-maybe)) + '(indent-relative + indent-relative-maybe + indent-relative-first-indent-point)) ;; These functions are used for tabbing, but can't be used for ;; indenting. Replace with something ad-hoc. (let ((column (save-excursion @@ -292,7 +294,8 @@ indentation by specifying a large negative ARG." "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) + (beginning-of-line 1) + (skip-chars-forward " \t") (let ((cur-col (current-column))) (cond ((< cur-col column) (if (>= (- column (* (/ cur-col tab-width) tab-width)) tab-width) @@ -300,8 +303,13 @@ only if necessary. It leaves point at end of indentation." (progn (skip-chars-backward " ") (point)))) (indent-to column)) ((> cur-col column) ; too far right (after tab?) - (delete-region (progn (move-to-column column t) (point)) - (progn (backward-to-indentation 0) (point))))))) + (delete-region (progn (move-to-column column t) (point)) + ;; The `move-to-column' call may replace + ;; tabs with spaces, so we can't reuse the + ;; previous start point. + (progn (beginning-of-line 1) + (skip-chars-forward " \t") + (point))))))) (defun current-left-margin () "Return the left margin to use for this line. |