diff options
author | Thien-Thi Nguyen <ttn@gnuvola.org> | 2007-11-03 21:02:35 +0000 |
---|---|---|
committer | Thien-Thi Nguyen <ttn@gnuvola.org> | 2007-11-03 21:02:35 +0000 |
commit | c81f72cebe9b5af6e27a65a15974292fde7ecfec (patch) | |
tree | 4063804cea67330dc73236e309a2ab386a029fed /lisp/register.el | |
parent | 6159985a125d89084f7b7339982382ec263e8943 (diff) | |
download | emacs-c81f72cebe9b5af6e27a65a15974292fde7ecfec.tar.gz |
(append-to-register, prepend-to-register):
Don't signal error on empty register; use the text, instead.
Diffstat (limited to 'lisp/register.el')
-rw-r--r-- | lisp/register.el | 20 |
1 files changed, 12 insertions, 8 deletions
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) |