[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: whole-line-or-region

From: Kevin Rodgers
Subject: Re: whole-line-or-region
Date: Sat, 29 Nov 2008 09:32:13 -0700
User-agent: Thunderbird (Macintosh/20081105)

Joe Casadonte wrote:
;;  The primary use for this is to kill (cut) the current line if no
;;  region is defined, and kill-region is invoked.  It basically saves
;;  you the effort of going to the begining of the line, selecting the
;;  text up to the end of the line, and killing.

That seems to beg the question: Why isn't there a convenient command and
key binding to mark the current line?

;; Cribbed from mark-whole-buffer:
(defun mark-line ()
  "Put point at beginning and mark at end of line.
You probably should not use this function in Lisp programs;
it is usually a mistake for a Lisp function to use any subroutine
that uses or sets the mark."
  (push-mark (point))
  (let ((inhibit-field-text-motion t))
    (push-mark (point-at-eol) nil t)
    (goto-char (point-at-bol))))

Keybinding suggestions?  Here are the other mark commands:

C-x C-p         mark-page
C-x h           mark-whole-buffer
C-M-@           mark-sexp
C-M-h           mark-defun
M-@             mark-word
M-h             mark-paragraph
C-M-SPC         mark-sexp

Kevin Rodgers
Denver, Colorado, USA

reply via email to

[Prev in Thread] Current Thread [Next in Thread]