From: Thien-Thi Nguyen Date: Sat, 3 Nov 2007 21:02:35 +0000 (+0000) Subject: (append-to-register, prepend-to-register): X-Git-Tag: emacs-pretest-23.0.90~9874 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c81f72cebe9b5af6e27a65a15974292fde7ecfec;p=emacs.git (append-to-register, prepend-to-register): Don't signal error on empty register; use the text, instead. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e9e6d75b911..dcd4733eb32 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-11-03 Sean O'Rourke + + * register.el (append-to-register, prepend-to-register): + Don't signal error on empty register; use the text, instead. + 2007-11-03 Michael Olson * textmodes/remember.el (remember-buffer): Use diff --git a/lisp/register.el b/lisp/register.el index 1f0811561c2..5648ca385a8 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -287,10 +287,12 @@ With prefix arg, delete as well. 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 @@ With prefix arg, delete as well. 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)