🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99843

Stronger kill-line

#99843
From: Hallvard B Furuseth
Date: Thu, 19 Apr 1990 10:54
35 lines
1833 bytes
Some time ago, someone posted a kill-line modification which always
killed thru the newline (if kill-whole-line was non-nil).  I liked
that, but it was too strong for me.  Here is a more general version.
I prefer 2nd alternative of kill-whole-line-regexp:


(defvar kill-whole-line-regexp "[ \t]*$"
  "Regexp telling M-X kill-line when to kill thru newline.  Some possibilities:
\"[ \\t]*$\"	- when no nonblanks in rest of line (default).
\"^\\\\|[ \\t]*$\"	- as above, or when standing at beginning of line. 
\"\"		- always.")

(defun kill-line (&optional arg)
  "Kill the rest of the current line; if no nonblanks there, kill thru newline.
See also variable kill-whole-line-regexp.
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")
  (kill-region (point)
	       (progn
		 (if arg
		     (forward-line (prefix-numeric-value arg))
		   (if (eobp)
		       (signal 'end-of-buffer nil))
		   (if (looking-at kill-whole-line-regexp)
		       (forward-line 1)
		     (end-of-line)))
		 (point))))


Hallvard Furuseth
hallvard@ifi.uio.no
Technical Details
Message-ID: <9004191054.AAbivlinde01858@bivlinde.uio.no>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!dino!ceres!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!IFI.UIO.NO!hallvard

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,f79e16cf408032c3,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-04-20 01:59:28 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!dino!ceres!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!IFI.UIO.NO!hallvard
From: hallvard@IFI.UIO.NO (Hallvard B Furuseth)
Newsgroups: gnu.emacs.bug
Subject: Stronger kill-line
Message-ID: <9004191054.AAbivlinde01858@bivlinde.uio.no>
Date: 19 Apr 90 10:54:52 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 35
Posted: Thu Apr 19 11:54:52 1990