[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-k and scolding
From: |
Bruce Kroeze |
Subject: |
Re: C-k and scolding |
Date: |
Mon, 14 Apr 2003 14:04:30 -0700 |
User-agent: |
KMail/1.5.1 |
On Thursday 03 April 2003 12:04 pm, Dan Jacobson wrote:
> Take the case of a single C-k. To do this the proper way in a
> read-only buffer etc. one needs to set a mark, go the end of line, and
> hit M-w. Much more trouble than just a C-k while accepting the
> sadomasochistic beep.
>
> So there should be a way, just as easy as one or more C-k's, to do
> what C-k does (as far as adding to the kill ring), without getting
> beeped, nor without changing the file.
Here you go, a couple small functions I wrote for this very purpose:
(defun copy-line (&optional where)
"Copy the line containing point."
(interactive "d")
(save-excursion
(beginning-of-line)
(let ((beg (point)))
(end-of-line)
(copy-region-as-kill beg (point)))
(end-of-line))
(message "copied line"))
(defun copy-to-eol (&optional where)
"Copy to the end of the line containing point."
(interactive "d")
(save-excursion
(let ((beg (point)))
(end-of-line)
(copy-region-as-kill beg (point)))
(end-of-line))
(message "copied to eol"))
;; I bind 'em to "one-step" keys, your tastes are likely different.
(define-key global-map [(alt ?c)] 'copy-line)
(define-key global-map [(alt ?k)] 'copy-to-eol)