From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: patch: {append,prepend}-to-register on empty register Date: Mon, 05 Nov 2007 09:30:29 +0100 Message-ID: <874pg1p00q.fsf@ambire.localdomain> References: <87ir4j5jrg.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1194251525 1109 80.91.229.12 (5 Nov 2007 08:32:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2007 08:32:05 +0000 (UTC) Cc: Sean O'Rourke , emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 05 09:32:08 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 1IoxNQ-0007d2-0l for ged-emacs-devel@m.gmane.org; Mon, 05 Nov 2007 09:32:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoxNF-000413-5O for ged-emacs-devel@m.gmane.org; Mon, 05 Nov 2007 03:31:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IoxNB-0003yg-Ac for emacs-devel@gnu.org; Mon, 05 Nov 2007 03:31:53 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IoxN8-0003wi-R6 for emacs-devel@gnu.org; Mon, 05 Nov 2007 03:31:51 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IoxN8-0003wc-IA for emacs-devel@gnu.org; Mon, 05 Nov 2007 03:31:50 -0500 Original-Received: from ppp-53-35.21-151.libero.it ([151.21.35.53] helo=ambire.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IoxN3-0000uG-EJ; Mon, 05 Nov 2007 03:31:46 -0500 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1IoxLp-0001zw-Kl; Mon, 05 Nov 2007 09:30:29 +0100 In-Reply-To: (Miles Bader's message of "Mon, 05 Nov 2007 15:54:52 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:82552 Archived-At: () Miles Bader () Mon, 05 Nov 2007 15:54:52 +0900 Thien-Thi Nguyen writes: > i would prefer `(set-register register (cond ...))'. > likewise for other hunk. (let ((reg (get-register register)) (text (filter-buffer-substring start end))) (cond ((stringp reg) (setq text (concat reg text))) (reg (error "Register does not contain text"))) (set-register register text)) i like this better than the original, but not as much as the (more) functional, approach, due to setq. fwiw, following is a *scratch* snapshot. i read it as "you win some, you lose some, ..." :-/ thi ______________________________________________________________ (defun ttn-a (register start end) (let ((reg (get-register register)) (text (filter-buffer-substring start end))) (cond ((stringp reg) (setq text (concat reg text))) (reg (error "Register does not contain text"))) (set-register register text))) (defun ttn-b (register 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")))))) (byte-compile 'ttn-a) (byte-compile 'ttn-b) (disassemble 'ttn-a) ; write output to file A (disassemble 'ttn-b) ; write output to file B (shell-command "echo ; diff -y A B -W 78" t) 783 byte code for ttn-a: | byte code for ttn-b: args: (register start end) args: (register start end) 0 constant get-register 0 constant get-register 1 varref register 1 varref register 2 call 1 2 call 1 3 constant filter-buffer-subst 3 constant filter-buffer-subst 4 varref start 4 varref start 5 varref end 5 varref end 6 call 2 6 call 2 7 varbind text 7 varbind text 8 dup | 8 varbind reg 9 varbind reg | 9 constant set-register 10 stringp | 10 varref register 11 goto-if-nil 1 | 11 varref reg 14 varref reg | 12 goto-if-not-nil 1 15 varref text 15 varref text 16 concat2 | 16 goto 3 17 varset text | 19:1 varref reg 18 goto 2 | 20 stringp 21:1 varref reg | 21 goto-if-nil 2 22 goto-if-nil 2 | 24 varref reg 25 constant error | 25 varref text 26 constant "Register does..." | 26 concat2 27 call 1 | 27 goto 3 28 discard | 30:2 constant error 29:2 constant set-register | 31 constant "Register does..." 30 varref register | 32 call 1 31 varref text | 33:3 call 2 32 call 2 | 34 unbind 2 33 unbind 2 | 35 return 34 return <