emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Starting source code export at non-zero (-n value)


From: Brian Carlson
Subject: [O] Starting source code export at non-zero (-n value)
Date: Mon, 16 May 2016 23:33:20 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2

Hello other org mode aficionados! (I apologize for the errant email I send a minute ago. )

I have created a (possible) patch to the export (ox.el and other ox-XXX.el) files that allow for "source code" and "example" blocks to have line numbers starting at an arbitrary number. Before the (wonderful) ox redesign I used to have advice around some functions. I hadn't needed this functionality for a while, but now that I did I thought I would share.


The code is written with the following design:

-n   is the same as -n 1 : The functionality is unchanged
+n   is the same as +n 1 :  The functionality is unchanged

-n X   will "reset" and start new code block starting at line X
+n X   will "add" X to the last line of the block before.


========
example:
* Heading 1

  * ~-n 10~
    #+BEGIN_SRC emacs-lisp -n 10
      (save-excursion             ;; This is line 10
         (goto-char (point-min))) ;; 11
    #+END_SRC
  * ~-n~
    #+BEGIN_SRC emacs-lisp -n
      (save-excursion           ;; line 1
         (goto-char (point-min))) ;; line 2
    #+END_SRC
  * ~+n 155~
    #+BEGIN_SRC emacs-lisp +n 155
      (save-excursion            ;; line 157
         (goto-char (point-min))) ;; line 158
    #+END_SRC

Gives the following "Text - ascii output"


1 Heading 1
===========

  * `-n 10'
    ,----
    | 10  (save-excursion             ;; This is line 10
    | 11     (goto-char (point-min))) ;; 11
    `----
  * `-n'
    ,----
    | 1  (save-excursion           ;; line 1
    | 2     (goto-char (point-min))) ;; line 2
    `----
  * `+n 155'
    ,----
    | 157  (save-excursion            ;; line 157
    | 158     (goto-char (point-min))) ;; line 158
    `----


I have tested the code (using make test) and generated (hand verified) the LaTeX and HTML output. ODT has an issue already with +n in that each code block starts at line 1. (I did not address that).


I have included the git format patch output.

This is a fairly small set of changes, but I do assign the Copyright to the Free Software Foundation.


Thanks,
;-b

Attachment: 0001-ox-provide-n-offset-functionality.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]