From: "Sean O'Rourke" <seano@cs.ucla.edu>
To: emacs-devel@gnu.org
Subject: patch: {append,prepend}-to-register on empty register
Date: Fri, 02 Nov 2007 12:18:55 -0700 [thread overview]
Message-ID: <m2640kbgm8.fsf@cs.ucsd.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 361 bytes --]
The following patch makes {append,prepend}-to-register act like
copy-to-register when the register is empty, rather than just
throwing an error. Both still throw an error when the register
contains non-text.
/s
2007-11-02 Sean O'Rourke <seano@cs.ucla.edu>
* register.el (append-to-register): copy text to empty
registers.
(prepend-to-register): same.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2032 bytes --]
Index: register.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/register.el,v
retrieving revision 1.56
diff -p -u -w -r1.56 register.el
--- register.el 26 Jul 2007 05:26:32 -0000 1.56
+++ register.el 2 Nov 2007 19:00:03 -0000
@@ -287,10 +287,14 @@ 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)))
+ (cond
+ ((not reg) (set-register register (filter-buffer-substring start end)))
+ ((stringp reg)
+ (set-register register
+ (concat reg (filter-buffer-substring start end))))
+ (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 +303,14 @@ 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)))
+ (cond
+ ((not reg) (set-register register (filter-buffer-substring start end)))
+ ((stringp reg)
+ (set-register register
+ (concat (filter-buffer-substring start end) 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)
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next reply other threads:[~2007-11-02 19:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-02 19:18 Sean O'Rourke [this message]
2007-11-03 17:19 ` patch: {append,prepend}-to-register on empty register Thien-Thi Nguyen
2007-11-05 6:54 ` Miles Bader
2007-11-05 8:30 ` Thien-Thi Nguyen
2007-11-03 20:48 ` Richard Stallman
2007-11-03 21:02 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2640kbgm8.fsf@cs.ucsd.edu \
--to=seano@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.