🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98704

Killing an empty region in version 18.57

#98704
From: apikas
Date: Tue, 12 Mar 1991 10:14
31 lines
1798 bytes
Problem: When an empty region is killed with kill-region and then
yanked, an error occurs since (car kill-ring) is nil instead of "".
(Try set-mark-command, kill-region, yank).

Current definition in simple.el:
(defun kill-region (beg end)
  (interactive "*r")
  (if (and (not (eq buffer-undo-list t))
	   (not (eq last-command 'kill-region)))
      ;; Don't let the undo list be truncated before we can even access it.
      (let ((undo-high-threshold (+ (- (max beg end) (min beg end)) 100)))
	(delete-region beg end)
	;; Take the same string recorded for undo
	;; and put it in the kill-ring.
	(SETQ KILL-RING (CONS (CAR (CAR BUFFER-UNDO-LIST)) KILL-RING))
	(if (> (length kill-ring) kill-ring-max)
	    (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))
	(setq this-command 'kill-region)
	(setq kill-ring-yank-pointer kill-ring))
    (copy-region-as-kill beg end)
    (delete-region beg end)))

Suggested fix:
	;; Take the same string recorded for undo
	;; and put it in the kill-ring.
	(if (= beg end)		;; NAPI added special case: empty region 
	    (setq kill-ring (cons "" kill-ring))
	  (setq kill-ring (cons (car (car buffer-undo-list)) kill-ring)))

With best regards,
Anders Pikas
Technical Details
Message-ID: <9103121014.AAsunic03285@sunic.sunet.se>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,5a34cee9dec73e03,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-03-12 18:48:45 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage
From: apikas@NEXUS.SE
Newsgroups: gnu.emacs.bug
Subject: Killing an empty region in version 18.57
Message-ID: <9103121014.AAsunic03285@sunic.sunet.se>
Date: 12 Mar 91 10:14:44 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 31
Approved: bug-gnu-emacs@prep.ai.mit.edu