From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: renumbering numeric comments Date: Tue, 28 Oct 2014 10:53:35 +0700 Message-ID: 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: quoted-printable X-Trace: ger.gmane.org 1414468437 26067 80.91.229.3 (28 Oct 2014 03:53:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2014 03:53:57 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Steven Arntson Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 28 04:53:50 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 1Xixqv-0004au-Lj for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2014 04:53:49 +0100 Original-Received: from localhost ([::1]:37110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xixqv-0000iF-Ao for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Oct 2014 23:53:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xixqk-0000iA-2G for help-gnu-emacs@gnu.org; Mon, 27 Oct 2014 23:53:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xixqi-0007lq-VE for help-gnu-emacs@gnu.org; Mon, 27 Oct 2014 23:53:37 -0400 Original-Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:40885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xixqi-0007lb-Q4 for help-gnu-emacs@gnu.org; Mon, 27 Oct 2014 23:53:36 -0400 Original-Received: by mail-ie0-f182.google.com with SMTP id rd18so5323109iec.13 for ; Mon, 27 Oct 2014 20:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=/i/RHsPkmd+LiXuQHKVfzzb+TxPQ4+R9G3n9CB9MJ04=; b=LFnlapxbTLSrrL4PGcs5q4zYaoENIcmNDglevRpKQL5SKpW28iLbqRRyUA6wqcm0Lp 8lx529szocuk0mYJ8M2QvwyqA0iaQz1DMTNe+ZQkThaoj9YK3Ake4RDCWVepZCva5tIy ajvwQWqJfchqfnGMKErhRjCpJ0oLK4bF2cJKtLXnrWSWcZ7hOqe3SZIkPJjn6upslRfI j+sYOi2BWRyUfj26Gb/JTnuRph1IY2B8CFMWeZhqc9G6WQ5MUjnyP2i9VMLgohLv8Z5S dmX6cAFP+7o5l1HWZ2sdz1mKPcJA7h0ivBFlH/k40JX+7Dmb07Rqn5n1CQ0hGChutq01 LEjw== X-Received: by 10.107.156.17 with SMTP id f17mr724001ioe.15.1414468415537; Mon, 27 Oct 2014 20:53:35 -0700 (PDT) Original-Received: by 10.107.40.136 with HTTP; Mon, 27 Oct 2014 20:53:35 -0700 (PDT) In-Reply-To: <878uk17y4k.fsf@stevenarntson.com> X-Google-Sender-Auth: gpAPFKCg5m60FSDjIjikGaZf7C4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::236 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:100631 Archived-At: On Tue, Oct 28, 2014 at 7:59 AM, Steven Arntson wrote: > In Lilypond, measure numbers are usually (so far in my experience) > entered as comments at the end of a line in the form `%m__': > > These "%m_" numbers are very useful in debugging when the "code" is > compiled. However, in the above case I later inserted two new measures: > > \tempo 4=3D100 > e4 d e8 f | %m1 > \tempo 4=3D130 > -----> g8 f e d e f | > -----> e d c b c d | > 2. | %m2 > 2 ~ 8 e | %m3 > ... > > Renumbering everything by hand is a lot of work, because the piece is > many measures long. 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 =E2=80=9Cquery-replace-regexp=E2=80=9D). 3. Compose a regular expression that matches the parts of text you want to replace, with some context. I don=E2=80=99t know Lilypond and assum= e that measures end with a vertical bar and by convention it=E2=80=99s the la= st 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: =E2=80=9C|\( %m[0-9]+\)?$=E2=80=9D. Enter this as the replace regexp. 4. In the replacement string, use the \# marker where you want a sequential number inserted: =E2=80=9C| %m\#=E2=80=9D This is almost what you want but numbers starting with 0. If you want 1-based numbering, you=E2=80=99ll need to surround the \# marker with an expression that adds 1: =E2=80=9C| %m\,(+ 1 \#)=E2=80=9D The part after =E2=80=9C\,=E2=80=9D can be any Emacs Lisp expression. The o= ne above just happens to add (+) one (1) to the number of replacements done (\#) and can be abbreviated as =E2=80=9C(1+ \#)=E2=80=9D. (If you wanted to= renumber starting with 200, you would write =E2=80=9C(+ 200 \#)=E2=80=9D, and for nu= mbering starting with 301 and using only odd numbers, =E2=80=9C(+ 301 (* 2 \#))=E2= =80=9D.) Final recipe: query-replace-regexp |\( %m[0-9]+\)?$ | %m\,(1+ \#)