Instead of the position (region-beginning) use the position of the beginning of the same line:
(save-excursion (goto-char (region-beginning)) (line-beginning-position)) For example:
(defun shift-region (distance) (let ((mark (mark)) (beg (save-excursion (goto-char (region-beginning)) (line-beginning-position))) (end (region-end))) (indent-rigidly beg end distance) (push-mark mark t t) (setq deactivate-mark nil)))