🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99572

Re: *compilation* buffer should be read-only

#99572
From: Lars Henrik Mathiesen
Date: Sat, 14 Jul 1990 13:25
40 lines
2453 bytes
danj1@ihlpa.att.com (Daniel Jacobson) writes:
>The only reason against this (and making the manual pages buffer, *Shell
>Command Output*, etc. buffers read-only too) seems to be that you can't
>just "snarf and barf" (cut and paste) with C-k as easy anymore... so
>there should be a 1-key analog to control-k (like M-w is to C-w) that
>puts stuff in the kill ring (and perhaps moves the cursor to the end of
>the virtually killed line?), without attempting to modify the buffer.

Since kill-line is defined in simple.el, and uses kill-region, it is
very simple to make a version which just copies to the kill-ring. Put
this in your .emacs and bind it to some key (I used M-C-w, because I
don't think I've ever used append-next-kill).

(defun copy-line-as-kill (&optional arg)
  "Save the rest of the current line as if killed, but don't kill it;
if the rest of the line is blank, kill thru newline.
With prefix argument, kill that many lines from point.
Negative arguments kill lines backward.

When calling from a program, nil means \"no arg\",
a number counts as a prefix arg."
  (interactive "*P")
  (copy-region-as-kill (point)
		       (progn
			 (if arg
			     (forward-line (prefix-numeric-value arg))
			   (if (eobp)
			       (signal 'end-of-buffer nil))
			   (if (looking-at "[ \t]*$")
			       (forward-line 1)
			     (end-of-line)))
			 (point))))
(define-key esc-map "\C-w" 'copy-line-as-kill)

This works for me, but you might want to make it include the newline
unconditionally --- a question of taste.

--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark      [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers.      thorinn@diku.dk
Technical Details
Message-ID: <1990Jul14.132501.22540@diku.dk>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!dkuug!freja.diku.dk!skinfaxe.diku.dk!thorinn
References: <9007111420.AA03222@asylum.gsfc.nasa.gov> <9007121706.AA26565@life.ai.mit.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,b0cafb0dd90ced89
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-07-14 17:20:34 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!dkuug!freja.diku.dk!skinfaxe.diku.dk!thorinn
From: thorinn@skinfaxe.diku.dk (Lars Henrik Mathiesen)
Newsgroups: gnu.emacs.bug
Subject: Re: *compilation* buffer should be read-only
Message-ID: <1990Jul14.132501.22540@diku.dk>
Date: 14 Jul 90 13:25:01 GMT
References: <9007111420.AA03222@asylum.gsfc.nasa.gov> <9007121706.AA26565@life.ai.mit.edu>
Sender: news@diku.dk (The Netnews System)
Distribution: gnu
Organization: Department Of Computer Science, University Of Copenhagen
Lines: 40
Posted: Sat Jul 14 14:25:01 1990