From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sean O'Rourke" Newsgroups: gmane.emacs.devel Subject: patch: {append,prepend}-to-register on empty register Date: Fri, 02 Nov 2007 12:18:55 -0700 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1194031159 6703 80.91.229.12 (2 Nov 2007 19:19:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Nov 2007 19:19:19 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 02 20:19:21 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Io234-0008U8-2n for ged-emacs-devel@m.gmane.org; Fri, 02 Nov 2007 20:19:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Io22t-0000a1-N5 for ged-emacs-devel@m.gmane.org; Fri, 02 Nov 2007 15:19:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Io22p-0000WE-6w for emacs-devel@gnu.org; Fri, 02 Nov 2007 15:19:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Io22n-0000RL-1N for emacs-devel@gnu.org; Fri, 02 Nov 2007 15:19:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Io22m-0000R8-Nq for emacs-devel@gnu.org; Fri, 02 Nov 2007 15:19:00 -0400 Original-Received: from ms-smtp-04.socal.rr.com ([66.75.162.136]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Io22m-0004Sa-BN for emacs-devel@gnu.org; Fri, 02 Nov 2007 15:19:00 -0400 Original-Received: from Macintosh.local (cpe-76-173-198-96.socal.res.rr.com [76.173.198.96]) by ms-smtp-04.socal.rr.com (8.13.6/8.13.6) with ESMTP id lA2JItml028527 for ; Fri, 2 Nov 2007 12:18:56 -0700 (PDT) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (darwin) X-Virus-Scanned: Symantec AntiVirus Scan Engine X-detected-kernel: by monty-python.gnu.org: NetCache Data OnTap 5.x X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82367 Archived-At: --=-=-= 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 * register.el (append-to-register): copy text to empty registers. (prepend-to-register): same. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment 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) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--