From unknown Wed Jun 18 23:06:38 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#12217 <12217@debbugs.gnu.org> To: bug#12217 <12217@debbugs.gnu.org> Subject: Status: 24.2.50; append-to-register: Provide a convenient key binding Reply-To: bug#12217 <12217@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:06:38 +0000 retitle 12217 24.2.50; append-to-register: Provide a convenient key binding reassign 12217 emacs submitter 12217 Jambunathan K severity 12217 wishlist tag 12217 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 17 05:48:33 2012 Received: (at submit) by debbugs.gnu.org; 17 Aug 2012 09:48:33 +0000 Received: from localhost ([127.0.0.1]:34784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2JAO-0004Xv-NU for submit@debbugs.gnu.org; Fri, 17 Aug 2012 05:48:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58309) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2JAN-0004Xp-HA for submit@debbugs.gnu.org; Fri, 17 Aug 2012 05:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2J1k-0002VM-Mm for submit@debbugs.gnu.org; Fri, 17 Aug 2012 05:39:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_XBL,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:57742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2J1k-0002VI-K5 for submit@debbugs.gnu.org; Fri, 17 Aug 2012 05:39:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2J1j-0004gg-R9 for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2012 05:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2J1i-0002V8-Ve for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2012 05:39:35 -0400 Received: from mail-pb0-f41.google.com ([209.85.160.41]:62821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2J1i-0002PU-MI for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2012 05:39:34 -0400 Received: by mail-pb0-f41.google.com with SMTP id ro12so3394307pbb.0 for ; Fri, 17 Aug 2012 02:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=LFpcmlN/cVNHCeoVfE9OvRcQvueZGBwyOKcMoBro13k=; b=AmK+SIQ4164UoNf+KwKGakl+aMHE3LnN24wf18dsTBgtYZLu4zNrpWaU7Np8YadLGo k+MMDRevVO2V9QXpi0ltjk8qhSNgI7C3+QQCxD9fkmLxPGFWouKifwDbju8tEUjdCbRh o0uxmWgfcyfYi6Eu0AEinDltSOuGou51iriUcbfG0dKd7z37GzWbmE1/78QxMZQYA4oI HVANwBqJWA4AKUk4C5Wl6tZhJL6RmbzF76wZDQYa6WposzSk0B8XF24LTOVI81KYArDO 08FpNFts8txXY3WebufZQMbC5+mDUpeOpLGlxf9Lk6Gw4TMEVLmT/6qvUwyFvRJlzhmn OQMw== Received: by 10.68.130.65 with SMTP id oc1mr10165463pbb.29.1345196373601; Fri, 17 Aug 2012 02:39:33 -0700 (PDT) Received: from debian-6.05 ([101.63.249.41]) by mx.google.com with ESMTPS id vh7sm4596196pbc.22.2012.08.17.02.39.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 02:39:32 -0700 (PDT) From: Jambunathan K To: bug-gnu-emacs@gnu.org Subject: 24.2.50; append-to-register: Provide a convenient key binding Date: Fri, 17 Aug 2012 15:09:49 +0530 Message-ID: <87wr0x6emy.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Subject says it all. 24.2.50; append-to-register: Provide a convenient key binding From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 17 06:05:30 2012 Received: (at 12217) by debbugs.gnu.org; 17 Aug 2012 10:05:30 +0000 Received: from localhost ([127.0.0.1]:34799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2JQn-0004vI-Hp for submit@debbugs.gnu.org; Fri, 17 Aug 2012 06:05:29 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:35885) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2JQk-0004vA-LU for 12217@debbugs.gnu.org; Fri, 17 Aug 2012 06:05:27 -0400 Received: by pbbrr4 with SMTP id rr4so3742564pbb.3 for <12217@debbugs.gnu.org>; Fri, 17 Aug 2012 02:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=ERH/2urpvNLs+piDtS/NLOen4APYtU3M7ioo6HuI/UM=; b=AujG8NaPQwaxNHg4wb1O69psPvbKr+kOrUhsvWj9dfB3b7wIiDiDuhoom/o3zfnkxM gDwuBtIGHNiPgfxoYDAx9MTNqJ/41SdUX8oLfVZO4V2OXz89IJiYogcbftNlOfKbtXdU RErkgb1YrjDuYsGHQrTSSONK2+/tusSA91kBrcVYq0vd1Fs7fdhDrUD/8XvuhQJpbDCN 5yRkXmFzplS5vpDVwGxE8k0fDxXNVS4mqPGXrg6uFwBMmNinWWdKWsHy2IRwFR36yPqz BMjenTgZ+VWSg/NllvZzXwQF3MNir2hG6yOJvWpRs0hIB9jdRx8ErrrmEqDTsNbVVR8c g0mQ== Received: by 10.68.234.98 with SMTP id ud2mr10021898pbc.165.1345197390649; Fri, 17 Aug 2012 02:56:30 -0700 (PDT) Received: from debian-6.05 ([101.63.249.41]) by mx.google.com with ESMTPS id mr2sm4621642pbb.16.2012.08.17.02.56.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 02:56:29 -0700 (PDT) From: Jambunathan K To: 12217@debbugs.gnu.org Subject: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding References: <87wr0x6emy.fsf@gmail.com> Date: Fri, 17 Aug 2012 15:26:47 +0530 In-Reply-To: (GNU bug Tracking System's message of "Fri, 17 Aug 2012 09:49:02 +0000") Message-ID: <87sjbl6duo.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 12217 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain See attached patch. Once patch goes through, I will submit a second part which updates regs.texi. Some context: I usually to use M-x append-to-register (and with this patch `C-x r +') to collect sexps. I think it will be convenient to have the collected snippets separated by a suitable separator. Is it OK if a default "\n" be used? WDYT. Note that this will be a departure from current behaviour where the snippets are blindly concatenated. ps: Patch should apply cleanly to below bzr version. ,---- | kjambunathan@debian-6:~/src/emacs/trunk$ bzr version-info | revision-id: rgm@gnu.org-20120817072823-0zjgqf10g1d0vcf1 | date: 2012-08-17 00:28:23 -0700 | build-date: 2012-08-17 15:17:41 +0530 | revno: 109655 | branch-nick: trunk `---- --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug#12217-part-1.patch === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-08-17 06:01:17 +0000 +++ lisp/ChangeLog 2012-08-17 09:45:08 +0000 @@ -1,3 +1,9 @@ +2012-08-17 Jambunathan K + + * register.el (increment-register): If register contains a string, + call `append-to-register'. This way, `C-x r +' can be used to + invoke `append-to-register'. See (Bug#12217). + 2012-08-17 Martin Rudalics * window.el (delete-window): Fix last fix. === modified file 'lisp/register.el' --- lisp/register.el 2012-07-29 04:45:48 +0000 +++ lisp/register.el 2012-08-17 09:05:29 +0000 @@ -192,13 +192,25 @@ (string-to-number (match-string 0))) 0)))) -(defun increment-register (number register) - "Add NUMBER to the contents of register REGISTER. -Interactively, NUMBER is the prefix arg." - (interactive "p\ncIncrement register: ") - (or (numberp (get-register register)) - (error "Register does not contain a number")) - (set-register register (+ number (get-register register)))) +(defun increment-register (prefix register) + "Augment contents of REGISTER. +Interactively, PREFIX is in raw form. + +If REGISTER contains a number, add `prefix-numeric-value' of +PREFIX to it. + +If REGISTER is empty or if it contains a string, call +`append-to-register' with `delete-flag' set to PREFIX." + (interactive "P\ncIncrement register: ") + (let ((register-val (get-register register))) + (unless (or (not register-val) + (numberp register-val) + (stringp register-val)) + (error "Register does not contain a number or string")) + (if (numberp register-val) + (let ((number (prefix-numeric-value prefix))) + (set-register register (+ number register-val))) + (append-to-register register (region-beginning) (region-end) prefix)))) (defun view-register (register) "Display what is contained in register named REGISTER. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 21 21:20:01 2012 Received: (at 12217) by debbugs.gnu.org; 22 Aug 2012 01:20:01 +0000 Received: from localhost ([127.0.0.1]:42232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3zc0-00045i-QD for submit@debbugs.gnu.org; Tue, 21 Aug 2012 21:20:01 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:37412) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T3zby-00045b-Fn for 12217@debbugs.gnu.org; Tue, 21 Aug 2012 21:19:59 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q7M1JXZE009469; Tue, 21 Aug 2012 21:19:35 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 28FE3AE3BB; Tue, 21 Aug 2012 13:20:13 -0400 (EDT) From: Stefan Monnier To: Jambunathan K Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding Message-ID: References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> Date: Tue, 21 Aug 2012 13:20:13 -0400 In-Reply-To: <87sjbl6duo.fsf_-_@gmail.com> (Jambunathan K.'s message of "Fri, 17 Aug 2012 15:26:47 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4317=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4317> : streams <803545> : uri <1198787> X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 12217 Cc: 12217@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.2 (--) > Once patch goes through, I will submit a second part which updates > regs.texi. I think the change is OK. I would prefer a single `cond' form with the `error' in the last branch (instead of unless+if) so as to avoid a redundant `numberp' check (not as a matter of efficiency, of course, but maintenance). If you send such an updated patch with the corresponding regs.texi change, we'll install it. > I usually to use M-x append-to-register (and with this patch `C-x r +') > to collect sexps. I think it will be convenient to have the collected > snippets separated by a suitable separator. Is it OK if a default "\n" > be used? WDYT. I think I'd rather not add any separator by default. In many cases adding such a separator would render the command inconvenient, and in many others the user can easily make sure the text he appends includes an appropriate separator. I can see cases where adding a separator could be handy, but I'm not sure hardcoding "\n" would solve enough of those cases. Maybe you could prompt for a separator if the user provided a C-u prefix? Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 14:26:09 2012 Received: (at 12217) by debbugs.gnu.org; 8 Sep 2012 18:26:09 +0000 Received: from localhost ([127.0.0.1]:49006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAPjM-0001Fj-Ot for submit@debbugs.gnu.org; Sat, 08 Sep 2012 14:26:09 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:64383) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAPjJ-0001Fb-PG for 12217@debbugs.gnu.org; Sat, 08 Sep 2012 14:26:07 -0400 Received: by pbbrr4 with SMTP id rr4so1083076pbb.3 for <12217@debbugs.gnu.org>; Sat, 08 Sep 2012 11:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Aq1o2uX+FQbh7o7XDiMtYx2Nu+1a/SwpFmVRtk3eG9k=; b=trA9W9h3bXISLiaPHOphdYa5TjEIR3JNTGum6BdTbRwCPAR0HiM9La0x3XeuSfS880 kkpNn0bRYThBefTFK6OGmfCRT2nC9oRnQLjw93YsTQ/243xl9VVCBl2NLbvFAe5udWB6 Y5OSCuocfvENqdb4uISSnPfzIXdvOeGxrw8iI1J+6o3fcGGAhP8Fqb4DSvbH9xo7cLcf PqbjNnk9+disaVAOcOhnhUn8iK5UtV0cnn4QQ/kIgDokTya635RTa7oINZTHUXorGCGm 1sZegwS7uzwli7RrWGK5vatY0Kqo7YNNQpJRd9p4qK/UtutOWSGbbPJDtkcUQrAHQqq4 IGfA== Received: by 10.66.89.37 with SMTP id bl5mr14837923pab.55.1347128739930; Sat, 08 Sep 2012 11:25:39 -0700 (PDT) Received: from debian-6.05 ([115.184.86.164]) by mx.google.com with ESMTPS id sr4sm5707760pbc.24.2012.09.08.11.25.35 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 08 Sep 2012 11:25:39 -0700 (PDT) From: Jambunathan K To: Stefan Monnier Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> Date: Sat, 08 Sep 2012 23:56:20 +0530 In-Reply-To: (Stefan Monnier's message of "Tue, 21 Aug 2012 13:20:13 -0400") Message-ID: <87fw6sz7zn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 12217 Cc: 12217@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain Attaching modified patch. Patch is generated against revno: 109935. >> Once patch goes through, I will submit a second part which updates >> regs.texi. > > I think the change is OK. I would prefer a single `cond' form with the > `error' in the last branch (instead of unless+if) so as to avoid > a redundant `numberp' check (not as a matter of efficiency, of course, > but maintenance). > If you send such an updated patch with the corresponding regs.texi > change, we'll install it. Done. >> I usually to use M-x append-to-register (and with this patch `C-x r +') >> to collect sexps. I think it will be convenient to have the collected >> snippets separated by a suitable separator. Is it OK if a default "\n" >> be used? WDYT. > > I think I'd rather not add any separator by default. > In many cases adding such a separator would render the command > inconvenient, and in many others the user can easily make sure the > text he appends includes an appropriate separator. > I can see cases where adding a separator could be handy, but I'm not > sure hardcoding "\n" would solve enough of those cases. > Maybe you could prompt for a separator if the user provided a C-u > prefix? Prefix is used as a `delete-flag' already ... I have introduced an extra indirection via a `separator-register' (which is nil by default) Now what gets used as a separator - a newline, a double newline, a comma or a tab - is under user control. There is already one user - that is me - who will find this feature useful. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=bug-12217.patch === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2012-09-07 10:27:11 +0000 +++ doc/emacs/ChangeLog 2012-09-08 18:04:28 +0000 @@ -1,3 +1,9 @@ +2012-09-08 Jambunathan K + + * regs.texi (Text Registers): `C-x r +' can now be used instead of + M-x append-to-register. New option `separator-register'. + (Number Registers): Mention that `C-x r +' is polymorphic. + 2012-09-07 Chong Yidong * windows.texi (Window Choice): Don't mention obsolete === modified file 'doc/emacs/regs.texi' --- doc/emacs/regs.texi 2012-05-27 01:25:06 +0000 +++ doc/emacs/regs.texi 2012-09-08 17:14:13 +0000 @@ -92,6 +92,13 @@ Insert text from register @var{r} (@code{insert-register}). @item M-x append-to-register @key{RET} @var{r} Append region to text in register @var{r}. + +@kindex C-x r + +When register @var{r} contains text, you can use @kbd{C-x r +} +(@code{increment-register}) to append to that register. Note that +command @kbd{C-x r +} behaves differently if @var{r} contains a +number. @xref{Number Registers}. + @item M-x prepend-to-register @key{RET} @var{r} Prepend region to text in register @var{r}. @end table @@ -116,6 +123,19 @@ the region text to the text in the register instead of @emph{appending} it. +@vindex separator-register + When you are collecting text using @code{append-to-register} and +@code{prepend-to-register}, you may want to separate individual +collected pieces using a separator. In that case, configure a +@code{separator-register} and store the separator text in to that +register. For example, to get double newlines as text separator +during the collection process, you can use the following setting. + +@example +(setq separator-register ?+) +(set-register separator-register "\n\n") +@end example + @kindex C-x r i @findex insert-register @kbd{C-x r i @var{r}} inserts in the buffer the text from register @@ -191,8 +211,10 @@ @item C-u @var{number} C-x r + @var{r} @kindex C-x r + @findex increment-register -Increment the number in register @var{r} by @var{number} -(@code{increment-register}). +If @var{r} contains a number, increment the number in that register by +@var{number}. Note that command @kbd{C-x r +} +(@code{increment-register}) behaves differently if @var{r} contains +text. @xref{Text Registers}. @item C-x r i @var{r} Insert the number from register @var{r} into the buffer. @end table === modified file 'etc/NEWS' --- etc/NEWS 2012-09-07 10:27:11 +0000 +++ etc/NEWS 2012-09-08 17:31:09 +0000 @@ -182,6 +182,13 @@ delete-trailing-whitespace command should delete trailing lines at the end of the buffer. It defaults to t. ++++ +** `C-x r +' is now overloaded to invoke `append-to-register. ++++ +** New option `separator-register'. Separator register stores +separator text for use with M-x append-to-register and M-x +prepend-to-register. See manual for details. + ** Search changes *** Global `M-s _' starts a symbol (identifier) incremental search, === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-09-07 20:14:55 +0000 +++ lisp/ChangeLog 2012-09-08 17:39:03 +0000 @@ -1,3 +1,13 @@ +2012-09-08 Jambunathan K + + * register.el (register): New group. + (separator-register): New user option. + (increment-register): Route it to `append-to-register', if + register contains text. Implication is that `C-x r +' can now be + used for appending to a text register. + (append-to-register, prepend-to-register): Add separator based on + `separator-register. + 2012-09-07 Stefan Monnier * emacs-lisp/byte-run.el (defun): Tweak message. Simplify code. === modified file 'lisp/register.el' --- lisp/register.el 2012-07-29 04:45:48 +0000 +++ lisp/register.el 2012-09-08 14:12:42 +0000 @@ -76,6 +76,22 @@ A list of the form (FRAME-CONFIGURATION POSITION) represents a saved frame configuration plus a saved value of point.") +(defgroup register nil + "Register commands." + :group 'convenience + :version "24.2.50") + +(defcustom separator-register nil + "Use contents of this register to separate collected text. + +When collecting text with +`append-to-register' (resp. `prepend-to-register') contents of +this register is added to the beginning (resp. end) of the marked +text." + :group 'register + :type '(choice (const :tag "None" nil) + (character :tag "Use register" :value ?+))) + (defun get-register (register) "Return contents of Emacs register named REGISTER, or nil if none." (cdr (assq register register-alist))) @@ -192,13 +208,24 @@ (string-to-number (match-string 0))) 0)))) -(defun increment-register (number register) - "Add NUMBER to the contents of register REGISTER. -Interactively, NUMBER is the prefix arg." - (interactive "p\ncIncrement register: ") - (or (numberp (get-register register)) - (error "Register does not contain a number")) - (set-register register (+ number (get-register register)))) +(defun increment-register (prefix register) + "Augment contents of REGISTER. +Interactively, PREFIX is in raw form. + +If REGISTER contains a number, add `prefix-numeric-value' of +PREFIX to it. + +If REGISTER is empty or if it contains text, call +`append-to-register' with `delete-flag' set to PREFIX." + (interactive "P\ncIncrement register: ") + (let ((register-val (get-register register))) + (cond + ((numberp register-val) + (let ((number (prefix-numeric-value prefix))) + (set-register register (+ number register-val)))) + ((or (not register-val) (stringp register-val)) + (append-to-register register (region-beginning) (region-end) prefix)) + (t (error "Register does not contain a number or text"))))) (defun view-register (register) "Display what is contained in register named REGISTER. @@ -349,10 +376,11 @@ START and END are buffer positions indicating what to append." (interactive "cAppend to register: \nr\nP") (let ((reg (get-register register)) - (text (filter-buffer-substring start end))) + (text (filter-buffer-substring start end)) + (separator (and separator-register (get-register separator-register)))) (set-register register (cond ((not reg) text) - ((stringp reg) (concat reg text)) + ((stringp reg) (concat reg separator text)) (t (error "Register does not contain text"))))) (cond (delete-flag (delete-region start end)) @@ -366,10 +394,11 @@ START and END are buffer positions indicating what to prepend." (interactive "cPrepend to register: \nr\nP") (let ((reg (get-register register)) - (text (filter-buffer-substring start end))) + (text (filter-buffer-substring start end)) + (separator (and separator-register (get-register separator-register)))) (set-register register (cond ((not reg) text) - ((stringp reg) (concat text reg)) + ((stringp reg) (concat text separator reg)) (t (error "Register does not contain text"))))) (cond (delete-flag (delete-region start end)) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 16:10:22 2012 Received: (at 12217-done) by debbugs.gnu.org; 8 Sep 2012 20:10:22 +0000 Received: from localhost ([127.0.0.1]:49073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TARMD-0003dl-KN for submit@debbugs.gnu.org; Sat, 08 Sep 2012 16:10:22 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:29010) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TARMC-0003de-1Y for 12217-done@debbugs.gnu.org; Sat, 08 Sep 2012 16:10:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09Ld+Y//2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOjM4FYgwU X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="197861815" Received: from 75-119-230-63.dsl.teksavvy.com (HELO pastel.home) ([75.119.230.63]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 08 Sep 2012 16:09:53 -0400 Received: by pastel.home (Postfix, from userid 20848) id 625AC58FC1; Sat, 8 Sep 2012 16:09:53 -0400 (EDT) From: Stefan Monnier To: Jambunathan K Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding Message-ID: References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> <87fw6sz7zn.fsf@gmail.com> Date: Sat, 08 Sep 2012 16:09:53 -0400 In-Reply-To: <87fw6sz7zn.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 08 Sep 2012 23:56:20 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12217-done Cc: 12217-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) >> Maybe you could prompt for a separator if the user provided a C-u >> prefix? > Prefix is used as a `delete-flag' already ... The way I read the current binding of C-x r + (increment-register), it only uses the prefix to specify the number to add to the register, which in the case of string concatenation is of no use. So we can use the prefix of C-x + either the way you do in your current patch (i.e. to specify the delete-flag of append-to-register) or we can use it to specify the separator. I understand that deleting the text is a common need, but you can do that with C-x + C-w instead of C-u C-x +, so maybe it's OK to use C-u for the separator. > I have introduced an extra indirection via a `separator-register' (which > is nil by default) Now what gets used as a separator - a newline, a > double newline, a comma or a tab - is under user control. I've renamed it to register-separator, because I'd rather that register.el move (ever so slowly) to obey the "register-" prefix. Stefan "Installed, thank you!" From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 09 03:45:57 2012 Received: (at 12217) by debbugs.gnu.org; 9 Sep 2012 07:45:57 +0000 Received: from localhost ([127.0.0.1]:49502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAcDM-0004EF-CK for submit@debbugs.gnu.org; Sun, 09 Sep 2012 03:45:57 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:43849) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAcDK-0004E8-EL for 12217@debbugs.gnu.org; Sun, 09 Sep 2012 03:45:55 -0400 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3XF4Dj29xcz3hhcs; Sun, 9 Sep 2012 09:45:22 +0200 (CEST) X-Auth-Info: +ls4NtyII/CwCRSELWxiZpr45CO4DnMRcO4SXzNc0hs= Received: from igel.home (ppp-93-104-149-132.dynamic.mnet-online.de [93.104.149.132]) by mail.mnet-online.de (Postfix) with ESMTPA id 3XF4Df6hCJzbbfw; Sun, 9 Sep 2012 09:45:22 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id 9CD6ACA2A5; Sun, 9 Sep 2012 09:45:22 +0200 (CEST) From: Andreas Schwab To: Jambunathan K Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> <87fw6sz7zn.fsf@gmail.com> X-Yow: These PRESERVES should be FORCE-FED to PENTAGON OFFICIALS!! Date: Sun, 09 Sep 2012 09:45:22 +0200 In-Reply-To: <87fw6sz7zn.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 08 Sep 2012 23:56:20 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12217 Cc: Stefan Monnier , 12217@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jambunathan K writes: > I have introduced an extra indirection via a `separator-register' (which > is nil by default) Now what gets used as a separator - a newline, a > double newline, a comma or a tab - is under user control. Why the extra indirection? Why not just make it a string and use it directly? Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 09 04:45:23 2012 Received: (at 12217) by debbugs.gnu.org; 9 Sep 2012 08:45:23 +0000 Received: from localhost ([127.0.0.1]:49557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAd8s-0005bN-Tt for submit@debbugs.gnu.org; Sun, 09 Sep 2012 04:45:23 -0400 Received: from mail-ie0-f172.google.com ([209.85.223.172]:33625) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAd8n-0005bC-Mq for 12217@debbugs.gnu.org; Sun, 09 Sep 2012 04:45:19 -0400 Received: by ieak13 with SMTP id k13so1506495iea.3 for <12217@debbugs.gnu.org>; Sun, 09 Sep 2012 01:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=ENrAYywzAY/Rx1BMkQMDNdAPAE3oqoHeozgnRbdIu3s=; b=gqu5w+yr3vE6NiZejgzb0vPIaKCOstP1hNQ4ZwNam95BffRab98n5+RQ8BYKUZiN9E LSa61XwvC2IPFkff3S10R5l5k1mDUo1tGdjL1aCyr3knLYHnyQlFl8xbRUHwQCzTAM7R s7A+H6LxH8SNsnJA0daoE/tbmi70xqcCLGbhCzNUGIMozZmA8PyrJmEK3rAObz428xfV TEvRVprrXUo8tjkiAe4TTCeaOXCDPz0kr2XwMrCtLWhfFct/kU+dH1fWGeshe1lbtKt+ wHY9ZY64SmLseRpqLRw7k5eoqU5mLKC6eIh+KB27T4DzqYYwvNezX6BExwtnE6T53kMl WLBg== Received: by 10.50.100.165 with SMTP id ez5mr6003345igb.68.1347180288952; Sun, 09 Sep 2012 01:44:48 -0700 (PDT) Received: from debian-6.05 ([115.242.227.226]) by mx.google.com with ESMTPS id ua5sm6434214igb.10.2012.09.09.01.44.45 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 01:44:48 -0700 (PDT) From: Jambunathan K To: Andreas Schwab Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> <87fw6sz7zn.fsf@gmail.com> Date: Sun, 09 Sep 2012 14:15:32 +0530 In-Reply-To: (Andreas Schwab's message of "Sun, 09 Sep 2012 09:45:22 +0200") Message-ID: <877gs3oa8j.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.8 (-) X-Debbugs-Envelope-To: 12217 Cc: Stefan Monnier , 12217@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.8 (-) Andreas Schwab writes: > Jambunathan K writes: > >> I have introduced an extra indirection via a `separator-register' >> (which is nil by default) Now what gets used as a separator - a >> newline, a double newline, a comma or a tab - is under user control. > > Why the extra indirection? Why not just make it a string and use it > directly? In short, Function before form and it is also about some workflows being less intrusive than others. Let's look at some use-cases. Use-case-1 (A concrete one) I find myself collecting sexps. (This is going to happen more as I plan to explore more new codebases.) When I look at existing code - with an intention to prepare some patch - I find myself collecting recipes from 2 or 3 places. I then "insert" it in to target location and put them together. Since the recipes are collected from 2 or 3 places, they need to be visually separated. Going forward I will store "double newline" (read paragraph) as separator for these recipe blocks. Note: Org exporters are moving to new framework. Now when I am re-implementing some features in my (own) org-e-odt.el, I find myself collecting recipes from org-export.el, org-e-latex.el and felt sorry that the sexps are not visually separated. Use-case-2 (Contrived one) Now let's say I am a language learner and I am looking at a French article from within Emacs. As I read through the article, I see some words that need to be looked up. Instead of immediate lookup, I may store the word or a phrase in a register and later insert in to my language notes for further refinement. In this case, I may want to separate them with a newline or even better something like an Org-table. In that case, in my scratch buffer I will type something like this in scratch buffer, C-x r s + it and then collect away. I can then paste that in to my Notes buffer and then re-align it using Org. --8<---------------cut here---------------start------------->8--- | | --8<---------------cut here---------------end--------------->8--- This is how the collected table looks like ,---- | Now| | |looked| | |immediate| | |further `---- A string or a separator register ================================ It is easy for me to do "C-x r s" a separator rather to do a "M: (setq separator "")". There is lesser context switch. A separator register "guarantees" that the words are separated. This frees one from remembering to store the surrounding separator and just focus on collection process. > Andreas. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 09 04:52:02 2012 Received: (at 12217-done) by debbugs.gnu.org; 9 Sep 2012 08:52:02 +0000 Received: from localhost ([127.0.0.1]:49580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAdFJ-0005on-Hz for submit@debbugs.gnu.org; Sun, 09 Sep 2012 04:52:02 -0400 Received: from mail-ie0-f172.google.com ([209.85.223.172]:44606) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAdFG-0005oa-VL for 12217-done@debbugs.gnu.org; Sun, 09 Sep 2012 04:52:00 -0400 Received: by ieak13 with SMTP id k13so1511275iea.3 for <12217-done@debbugs.gnu.org>; Sun, 09 Sep 2012 01:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=yRXerW2u1OOTiBtoH8ifCIVcahhsoAsQJdRH6bA0o7s=; b=o5D2mBuv7LxR1mjY39Mlx4vUEHST5ODL4sdvqjv7JEKj+0rdFQrRAvnfr2uiNTIeMV WBEXePG9UnUGCXWVts+bL+Ak+KtWuTCGqbgqeZQgotzZlDce14mYdsTslOGIC6zKAr7y bWecyyCrCsTDR6tC7BpVbWjeoVa8MI+bNO4+V6eC40/v0+7Sc73PUGxBQQM2viJsOsDw RatsjqZnJEEhMFxONhvj2mzF5uCBymb2cfCYqIG50W7NRsFnR3FnRPTd9oYLb3Y2Vavs CF9FVkM3s7CNtD8LEdO9UurYnj4JngrONwpij5SGqpFRFMlkhrV8T+MRAgmUYQlnSqyS q59Q== Received: by 10.43.13.195 with SMTP id pn3mr13085573icb.47.1347180690480; Sun, 09 Sep 2012 01:51:30 -0700 (PDT) Received: from debian-6.05 ([115.242.227.226]) by mx.google.com with ESMTPS id q5sm5283105igl.17.2012.09.09.01.51.28 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 01:51:29 -0700 (PDT) From: Jambunathan K To: Stefan Monnier Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> <87fw6sz7zn.fsf@gmail.com> Date: Sun, 09 Sep 2012 14:22:15 +0530 In-Reply-To: (Stefan Monnier's message of "Sat, 08 Sep 2012 16:09:53 -0400") Message-ID: <87392ro9xc.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.8 (-) X-Debbugs-Envelope-To: 12217-done Cc: 12217-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.8 (-) > I've renamed it to register-separator, because I'd rather that > register.el move (ever so slowly) to obey the "register-" prefix. Looks like you failed to mark some files in work-area before the commmit. I still see references to separator-register in *.el file, NEWS and Changelog files. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 09 05:02:03 2012 Received: (at 12217) by debbugs.gnu.org; 9 Sep 2012 09:02:03 +0000 Received: from localhost ([127.0.0.1]:49585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAdP1-0006AH-2m for submit@debbugs.gnu.org; Sun, 09 Sep 2012 05:02:03 -0400 Received: from mail-iy0-f172.google.com ([209.85.210.172]:49266) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAdOz-00069r-36 for 12217@debbugs.gnu.org; Sun, 09 Sep 2012 05:02:02 -0400 Received: by iabz21 with SMTP id z21so965870iab.3 for <12217@debbugs.gnu.org>; Sun, 09 Sep 2012 02:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=9hWKwm7flZXdry6f6b5dv4u82H4e8+sX9Spep7NUvL0=; b=UWITDX33B2QvN/INA/V1bJc2yLUXS79gcwlheUQWWUjbABVt3T7cJm/noE2tFLrhWR wLfMevOibUpI4Xp49UcGivU90d2ugYcfii/Z1ZpUnydyd8GtUOUDpvlUzwmVGjuUnEwF /sQ+Nu9fqm0Gpcdw/6ftuagWnypUkbwQVgQRlxs7ww7edkoaVdobW0k6cDsahjscFzD8 246s3VT8Evxsygjl/f+rOTP6OpBmbz0USDz/SyifWxKi7/+vORGErmprACP6kHwUe//l DVT1NLF2f/im+SL9Ql2jt3EsIeD1jym540QuStFNly3RmlGM3s71RwL5jvBu4X4unadP rPNw== Received: by 10.50.158.169 with SMTP id wv9mr6136721igb.25.1347181292453; Sun, 09 Sep 2012 02:01:32 -0700 (PDT) Received: from debian-6.05 ([115.242.227.226]) by mx.google.com with ESMTPS id wg9sm6780890igb.0.2012.09.09.02.01.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 02:01:31 -0700 (PDT) From: Jambunathan K To: Andreas Schwab Subject: Re: bug#12217: [PATCH] Re: 24.2.50; append-to-register: Provide a convenient key binding In-Reply-To: (Andreas Schwab's message of "Sun, 09 Sep 2012 09:45:22 +0200") References: <87wr0x6emy.fsf@gmail.com> <87sjbl6duo.fsf_-_@gmail.com> <87fw6sz7zn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) Date: Sun, 09 Sep 2012 14:32:21 +0530 Message-ID: <87txv7muw2.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.8 (-) X-Debbugs-Envelope-To: 12217 Cc: Stefan Monnier , 12217@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.8 (-) Andreas Schwab writes: > Jambunathan K writes: > >> I have introduced an extra indirection via a `separator-register' (which >> is nil by default) Now what gets used as a separator - a newline, a >> double newline, a comma or a tab - is under user control. > > Why the extra indirection? Why not just make it a string and use it > directly? Why registers when there is a kill ring? A text register is but a kill ring. Register is a framework and hence abstract. The original authors needed it badly, took trouble to implement it, but unfortunately failed to document what new workflows they enable. (I see some references to number registers being used in conjunction with macros - just about it.) Now a user is left to his own device to contrive how a register should be used. It is like an incomplete sentence begging for .... Btw, no registers were killed in the preparation of the patch. > Andreas. From unknown Wed Jun 18 23:06:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 07 Oct 2012 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator