changeset 85914:b51c8db87a41

(append-to-register, prepend-to-register): Don't signal error on empty register; use the text, instead.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Sat, 03 Nov 2007 21:01:09 +0000
parents 047b6a6087c2
children c1f2b82183a6
files lisp/register.el
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/register.el	Sat Nov 03 20:45:20 2007 +0000
+++ b/lisp/register.el	Sat Nov 03 21:01:09 2007 +0000
@@ -287,10 +287,12 @@
 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
 START and END are buffer positions indicating what to append."
   (interactive "cAppend to register: \nr\nP")
-  (or (stringp (get-register register))
-      (error "Register does not contain text"))
-  (set-register register (concat (get-register register)
-			    (filter-buffer-substring start end)))
+  (let ((reg (get-register register))
+        (text (filter-buffer-substring start end)))
+    (set-register
+     register (cond ((not reg) text)
+                    ((stringp reg) (concat reg text))
+                    (t (error "Register does not contain text")))))
   (if delete-flag (delete-region start end)))
 
 (defun prepend-to-register (register start end &optional delete-flag)
@@ -299,10 +301,12 @@
 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
 START and END are buffer positions indicating what to prepend."
   (interactive "cPrepend to register: \nr\nP")
-  (or (stringp (get-register register))
-      (error "Register does not contain text"))
-  (set-register register (concat (filter-buffer-substring start end)
-			    (get-register register)))
+  (let ((reg (get-register register))
+        (text (filter-buffer-substring start end)))
+    (set-register
+     register (cond ((not reg) text)
+                    ((stringp reg) (concat text reg))
+                    (t (error "Register does not contain text")))))
   (if delete-flag (delete-region start end)))
 
 (defun copy-rectangle-to-register (register start end &optional delete-flag)