+ "Indent current line to the column given by `current-left-margin'."
+ (indent-line-to (current-left-margin)))
+
+(defun delete-to-left-margin (&optional from to)
+ "Remove left margin indentation from a region.
+This deletes to the column given by `current-left-margin'.
+In no case will it delete non-whitespace.
+Args FROM and TO are optional; default is the whole buffer."
+ (save-excursion
+ (goto-char (or to (point-max)))
+ (setq to (point-marker))
+ (goto-char (or from (point-min)))
+ (or (bolp) (forward-line 1))
+ (while (< (point) to)
+ (delete-region (point) (progn (move-to-left-margin nil t) (point)))
+ (forward-line 1))
+ (move-marker to nil)))
+
+(defun set-left-margin (from to width)
+ "Set the left margin of the region to WIDTH.
+If `auto-fill-mode' is active, re-fill the region to fit the new margin.
+
+Interactively, WIDTH is the prefix argument, if specified.
+Without prefix argument, the command prompts for WIDTH."
+ (interactive "r\nNSet left margin to column: ")
+ (save-excursion
+ ;; If inside indentation, start from BOL.
+ (goto-char from)
+ (skip-chars-backward " \t")
+ (if (bolp) (setq from (point)))
+ ;; Place end after whitespace
+ (goto-char to)
+ (skip-chars-forward " \t")
+ (setq to (point-marker)))
+ ;; Delete margin indentation first, but keep paragraph indentation.
+ (delete-to-left-margin from to)
+ (put-text-property from to 'left-margin width)
+ (indent-rigidly from to width)
+ (if auto-fill-function (save-excursion (fill-region from to nil t t)))
+ (move-marker to nil))
+
+(defun set-right-margin (from to width)
+ "Set the right margin of the region to WIDTH.
+If `auto-fill-mode' is active, re-fill the region to fit the new margin.
+
+Interactively, WIDTH is the prefix argument, if specified.
+Without prefix argument, the command prompts for WIDTH."
+ (interactive "r\nNSet right margin to width: ")
+ (save-excursion
+ (goto-char from)
+ (skip-chars-backward " \t")
+ (if (bolp) (setq from (point))))
+ (put-text-property from to 'right-margin width)
+ (if auto-fill-function (save-excursion (fill-region from to nil t t))))
+
+(defun alter-text-property (from to prop func &optional object)
+ "Programmatically change value of a text-property.
+For each region between FROM and TO that has a single value for PROPERTY,
+apply FUNCTION to that value and sets the property to the function's result.
+Optional fifth argument OBJECT specifies the string or buffer to operate on."
+ (let ((begin from)
+ end val)
+ (while (setq val (get-text-property begin prop object)
+ end (text-property-not-all begin to prop val object))
+ (put-text-property begin end prop (funcall func val) object)
+ (setq begin end))
+ (if (< begin to)
+ (put-text-property begin to prop (funcall func val) object))))
+
+(defun increase-left-margin (from to inc)
+ "Increase or decrease the left-margin of the region.
+With no prefix argument, this adds `standard-indent' of indentation.
+A prefix arg (optional third arg INC noninteractively) specifies the amount
+to change the margin by, in characters.
+If `auto-fill-mode' is active, re-fill the region to fit the new margin."
+ (interactive "*r\nP")
+ (setq inc (if inc (prefix-numeric-value inc) standard-indent))
+ (save-excursion
+ (goto-char from)
+ (skip-chars-backward " \t")
+ (if (bolp) (setq from (point)))
+ (goto-char to)
+ (setq to (point-marker)))
+ (alter-text-property from to 'left-margin
+ (lambda (v) (max (- left-margin) (+ inc (or v 0)))))
+ (indent-rigidly from to inc)
+ (if auto-fill-function (save-excursion (fill-region from to nil t t)))
+ (move-marker to nil))
+
+(defun decrease-left-margin (from to inc)
+ "Make the left margin of the region smaller.
+With no prefix argument, decrease the indentation by `standard-indent'.
+A prefix arg (optional third arg INC noninteractively) specifies the amount
+to change the margin by, in characters.
+If `auto-fill-mode' is active, re-fill the region to fit the new margin."
+ (interactive "*r\nP")
+ (setq inc (if inc (prefix-numeric-value inc) standard-indent))
+ (increase-left-margin from to (- inc)))
+
+(defun increase-right-margin (from to inc)
+ "Increase the right-margin of the region.
+With no prefix argument, increase the right margin by `standard-indent'.
+A prefix arg (optional third arg INC noninteractively) specifies the amount
+to change the margin by, in characters. A negative argument decreases
+the right margin width.
+If `auto-fill-mode' is active, re-fill the region to fit the new margin."
+ (interactive "r\nP")
+ (setq inc (if inc (prefix-numeric-value inc) standard-indent))
+ (save-excursion
+ (alter-text-property from to 'right-margin
+ (lambda (v) (+ inc (or v 0))))
+ (if auto-fill-function
+ (fill-region from to nil t t))))
+
+(defun decrease-right-margin (from to inc)
+ "Make the right margin of the region smaller.
+With no prefix argument, decrease the right margin by `standard-indent'.
+A prefix arg (optional third arg INC noninteractively) specifies the amount
+of width to remove, in characters. A negative argument increases
+the right margin width.
+If `auto-fill-mode' is active, re-fills region to fit in new margin."
+ (interactive "*r\nP")
+ (setq inc (if inc (prefix-numeric-value inc) standard-indent))
+ (increase-right-margin from to (- inc)))
+
+(defun beginning-of-line-text (&optional n)
+ "Move to the beginning of the text on this line.
+With optional argument, move forward N-1 lines first.
+From the beginning of the line, moves past the left-margin indentation, the
+fill-prefix, and any indentation used for centering or right-justifying the
+line, but does not move past any whitespace that was explicitly inserted
+\(such as a tab used to indent the first line of a paragraph)."
+ (interactive "p")
+ (beginning-of-line n)
+ (skip-chars-forward " \t")
+ ;; Skip over fill-prefix.
+ (if (and fill-prefix
+ (not (string-equal fill-prefix "")))
+ (if (equal fill-prefix
+ (buffer-substring
+ (point) (min (point-max) (+ (length fill-prefix) (point)))))
+ (forward-char (length fill-prefix)))
+ (if (and adaptive-fill-mode adaptive-fill-regexp
+ (looking-at adaptive-fill-regexp))
+ (goto-char (match-end 0))))
+ ;; Skip centering or flushright indentation
+ (if (memq (current-justification) '(center right))
+ (skip-chars-forward " \t")))