From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steven Arntson Newsgroups: gmane.emacs.help Subject: Re: renumbering numeric comments Date: Tue, 28 Oct 2014 10:11:43 -0700 Message-ID: <878uk03yr4.fsf@stevenarntson.com> References: <878uk17y4k.fsf@stevenarntson.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1414516362 9302 80.91.229.3 (28 Oct 2014 17:12:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2014 17:12:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 28 18:12:35 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XjAJu-0000yC-Va for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2014 18:12:35 +0100 Original-Received: from localhost ([::1]:40516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjAJu-0007wi-H3 for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2014 13:12:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjAJW-0007pA-Te for help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 13:12:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjAJM-0003SL-1m for help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 13:12:10 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjAJL-0003Rn-Rg for help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 13:11:59 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XjAJJ-0000Sx-H8 for help-gnu-emacs@gnu.org; Tue, 28 Oct 2014 18:11:57 +0100 Original-Received: from 75-172-121-226.tukw.qwest.net ([75.172.121.226]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Oct 2014 18:11:57 +0100 Original-Received: from steven by 75-172-121-226.tukw.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 28 Oct 2014 18:11:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 75-172-121-226.tukw.qwest.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:g7km/EhLpnsUOYD5//lN8PkZxNY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100635 Archived-At: Yuri Khan writes: > 1. Select the part of document you want to renumber in, or go the the > beginning of the buffer to renumber throughout the whole document. > 2. Hit C-M-% (for “query-replace-regexp”). > 3. Compose a regular expression that matches the parts of text you > want to replace, with some context. I don’t know Lilypond and assume > that measures end with a vertical bar and by convention it’s the last > significant character on the line, followed by a single space, > followed by a percent sign, then the letter m, then a sequence of > digits until the end of line. A new measure will end at the vertical > bar, with the space and comment omitted. So the regexp is: “|\( > %m[0-9]+\)?$”. Enter this as the replace regexp. > 4. In the replacement string, use the \# marker where you want a > sequential number inserted: “| %m\#” > > This is almost what you want but numbers starting with 0. If you want > 1-based numbering, you’ll need to surround the \# marker with an > expression that adds 1: “| %m\,(+ 1 \#)” > > The part after “\,” can be any Emacs Lisp expression. The one above > just happens to add (+) one (1) to the number of replacements done > (\#) and can be abbreviated as “(1+ \#)”. (If you wanted to renumber > starting with 200, you would write “(+ 200 \#)”, and for numbering > starting with 301 and using only odd numbers, “(+ 301 (* 2 \#))”.) > > Final recipe: > > query-replace-regexp > |\( %m[0-9]+\)?$ > | %m\,(1+ \#) Thank you so much for this. I have only the barest conception of how regexps work, but this seems like as excellent an introduction as I could have hoped for! -steven