diff --git a/lisp/simple.el b/lisp/simple.el index f609755..a6232d7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3970,6 +3970,36 @@ for it.") (goto-char position) (switch-to-buffer buffer))) +(defun mark-line (&optional arg allow-extend) + "Put point at beginning of this line, mark at end. +The line marked is the one that contains point or follows point. + +With argument ARG, puts mark at end of a following line, so that +the number of lines marked equals ARG. + +If ARG is negative, point is put at end of this line, mark is put +at beginning of this or a previous line. + +Interactively, if this command is repeated or (in Transient Mark +mode) if the mark is active, it marks the next ARG lines after +the ones already marked." + (interactive "p\np") + (unless arg (setq arg 1)) + (when (zerop arg) + (error "Cannot mark zero lines")) + (cond ((and allow-extend + (or (and (eq last-command this-command) (mark t)) + (and transient-mark-mode mark-active))) + (set-mark + (save-excursion + (goto-char (mark)) + (forward-line arg) + (point)))) + (t + (forward-line arg) + (push-mark nil t t) + (previous-line arg)))) + (defcustom next-line-add-newlines nil "If non-nil, `next-line' inserts newline to avoid `end of buffer' error." :type 'boolean