From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Patch for numbering continuation in source blocks. Date: Fri, 7 Oct 2011 18:19:35 +0200 Message-ID: References: <87k48nisms.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCD9A-0003nM-RA for emacs-orgmode@gnu.org; Fri, 07 Oct 2011 12:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RCD99-0006rq-EI for emacs-orgmode@gnu.org; Fri, 07 Oct 2011 12:19:40 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:61425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RCD99-0006rX-5c for emacs-orgmode@gnu.org; Fri, 07 Oct 2011 12:19:39 -0400 Received: by eyb7 with SMTP id 7so220842eyb.0 for ; Fri, 07 Oct 2011 09:19:38 -0700 (PDT) In-Reply-To: <87k48nisms.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Niels Giesen Cc: Orgmode Hi Niels, is the purpose of this patch to be able to insert an unnumbered code = block between two numbered ones and to continue the numbering from the first = in the third? - Carsten On 2.10.2011, at 12:40, Niels Giesen wrote: > NOTE: I have tried earlier to send this patch with git send-email, > but apparently failed; here's a new, inlined attempt. >=20 > The documentation for numbering source code blocks says: >=20 > #+begin_quote > If you use a `+n' switch, the numbering from the previous > numbered snippet will be continued in the current one. > #+end_quote >=20 > But that is not exactly what happens; what happens is that the > numbering from the previous snippet will be continued in the current > one. That is, when the previous snippet is numbered its numbering will > continue, but if there is a previous numbered snippet A with, say, 14 > lines followed by an unnumbered snippet B followed by a numbered > snippet C, then the numbers for C will start at 1, regardless of the + > in the +n switch, whereas my reading of the documentation leads me to > think it ought to continue at 15, disregarding the presence any > unnumbered sections in between. >=20 > Reason for me for the +n switch to comply with (my reading of) the > documentation is that I would like to document a long, line-numbered, > function but intersperse it with short code samples without line > numbering that explain parts of the long function. >=20 > This patch of course may break existing org files where +n was > specified but -n intended. >=20 > #+begin_src diff > =46rom 4d34d5f2fe10a956d3359dfd40f19de25202df5f Mon Sep 17 00:00:00 = 2001 > From: Niels Giesen > Date: Fri, 16 Sep 2011 17:22:47 +0200 > Subject: [PATCH] Continue numbering from any previous numbered = snippet with +n, even when previous numbered snippet does not = immediately precede it. >=20 > ,* org-mode/lisp/org-exp.el (org-export-number-lines): >=20 > Check whether number parameter (this is a numbered block!) is > non-nil as well as whether cont is nil (this numbered block should > *not* continue numbering where we left off before!) before = resetting > the count to zero. >=20 > =46rom the docs: >=20 > If you use a `+n' switch, the numbering from the previous > numbered snippet will be continued in the current one. >=20 > With this change I believe the code complies with the docs. > --- > lisp/org-exp.el | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) >=20 > diff --git a/lisp/org-exp.el b/lisp/org-exp.el > index 9884a31..12590e1 100644 > --- a/lisp/org-exp.el > +++ b/lisp/org-exp.el > @@ -2731,7 +2731,7 @@ INDENT was the original indentation of the = block." > (defun org-export-number-lines (text &optional skip1 skip2 number = cont > replace-labels label-format) > (setq skip1 (or skip1 0) skip2 (or skip2 0)) > - (if (not cont) (setq org-export-last-code-line-counter-value 0)) > + (if (and number (not cont)) (setq = org-export-last-code-line-counter-value 0)) > (with-temp-buffer > (insert text) > (goto-char (point-max)) > --=20 > 1.7.4.1 >=20 >=20 > #+end_src >=20 > Regards, > niels > -- > http://pft.github.com >=20