- ;; Those functions are meant specifically for tabbing and not for
- ;; indenting, so we can't pass them to indent-according-to-mode.
- ((memq indent-line-function '(indent-relative indent-relative-maybe))
- (funcall indent-line-function))
- (t ;; The normal case.
- (indent-according-to-mode))))
+ (t
+ (let ((end-marker
+ (and arg
+ (save-excursion
+ (forward-line 0) (forward-sexp) (point-marker))))
+ (old-indent
+ (current-indentation)))
+
+ ;; Indent the line.
+ (funcall indent-line-function)
+
+ ;; If a prefix argument was given, rigidly indent the following
+ ;; sexp to match the change in the current line's indentation.
+ ;;
+ (when arg
+ (let ((indentation-change (- (current-indentation) old-indent)))
+ (unless (zerop indentation-change)
+ (save-excursion
+ (forward-line 1)
+ (when (< (point) end-marker)
+ (indent-rigidly (point) end-marker indentation-change))))))))))