Skip to main content

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))) 
Drew
  • 80.9k
  • 10
  • 125
  • 265