From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Proposal: references from code to text. Date: Mon, 14 May 2018 08:05:08 -0700 Message-ID: References: <800808596.465327.1526131788117.ref@mail.yahoo.com> <800808596.465327.1526131788117@mail.yahoo.com> <871seebxdt.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cd4c32056c2bcf29" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIF2G-0000ag-KR for emacs-orgmode@gnu.org; Mon, 14 May 2018 11:05:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIF2F-0007dy-4Y for emacs-orgmode@gnu.org; Mon, 14 May 2018 11:05:12 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:47013) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIF2E-0007bM-Mc for emacs-orgmode@gnu.org; Mon, 14 May 2018 11:05:11 -0400 Received: by mail-wr0-x232.google.com with SMTP id a12-v6so12701189wrn.13 for ; Mon, 14 May 2018 08:05:10 -0700 (PDT) In-Reply-To: <871seebxdt.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" To: "ZHUO QL (KDr2)" , org-mode-email --000000000000cd4c32056c2bcf29 Content-Type: text/plain; charset="UTF-8" It seems like this is nearly all possible already (see below). It is a little wonky that you have to put text in a src txt block to achieve it, but otherwise what is missing? * Main document See [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA35F][There is a reason we only support two args]] (text to text) for notes about this function. The addition is done in line [[(add)]] (text to code). #+NAME: DOC-OF-ADD #+BEGIN_SRC txt "We use the function add to calculate the sum of two numbers." #+END_SRC #+NAME: ADD #+BEGIN_SRC emacs-lisp -n -r :noweb yes :tangle test.el (defun add (x y) <> ;; code to code ;; [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA35F][There is a reason we only support two args]] code to text (+ x y) (ref:add) ) #+END_SRC #+RESULTS: ADD : add ** Notes *** There is a reason we only support two args :PROPERTIES: :ID: BAD97113-3561-4A4A-BA07-0CD5BF6BA35F :END: John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Sun, May 13, 2018 at 10:48 PM, Eric S Fraga wrote: > On Saturday, 12 May 2018 at 13:29, ZHUO QL (KDr2) wrote: > > Hi all, I just post a proposal for orgmode on my website(generated by > orgmode): > > http://kdr2.com/tech/emacs/1805-proposal-org-ref-code-to-text.html . > > Here is the source of the proposal: > > # -*- mode: org; mode: auto-fill; -*- > > > > #+TITLE: Proposal for Orgmode: references from code to text. > > #+AUTHOR: KDr2 > > [...] > > > - Beside the ~NAME~, we could also support reference via the > > ~CUSTOM_ID~ property or anything else that can locate a text chunk. > > - In the tangling process, we should do some kind of transformation of > > the target text, for example, escape the quote mark. A hook may be > > needed to let the user customize the transformation too. > > > > What do you think? > > I like the symmetry of having src reference text. I guess, in what you > propose above, that the text that would be incorporated would be a > single element (in org parsing parlance) or else we would have to > specify an extent in the link information. > > Are you able to implement something? I would definitely help test it. > > -- > Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-591-gee336b > --000000000000cd4c32056c2bcf29 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It seems like this is nearly all possible already (see bel= ow). It is a little wonky that you have to put text in a src txt block to a= chieve it, but otherwise what is missing?

* Main do= cument

See [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA3= 5F][There is a reason we only support two args]] (text to text) for notes a= bout this function. The addition is done in line [[(add)]] (text to code).<= /div>

#+NAME: DOC-OF-ADD
#+BEGIN_SRC txt
=
"We use the function add to calculate the sum of two numbers.&quo= t;
#+END_SRC

#+NAME: ADD
#+BEG= IN_SRC emacs-lisp -n -r :noweb yes :tangle test.el
(defun add (x = y)
=C2=A0 <<DOC-OF-ADD>> ;; code to code
= =C2=A0 ;; [[id:BAD97113-3561-4A4A-BA07-0CD5BF6BA35F][There is a reason we o= nly support two args]] code to text
=C2=A0 (+ x y) (ref:add)
=C2=A0 )
#+END_SRC

#+RESULTS: ADD<= /div>
: add


** Notes
=
*** There is a reason we only support two args
=C2= =A0 =C2=A0 :PROPERTIES:
=C2=A0 =C2=A0 :ID:=C2=A0 =C2=A0 =C2=A0 = =C2=A0BAD97113-3561-4A4A-BA07-0CD5BF6BA35F
=C2=A0 =C2=A0 :END:


=
John

----------------------------= -------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Department= of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15= 213
412-268-7803

On Sun, May 13, 2018 at 10:48 PM, Eric S Fra= ga <esflists@gmail.com> wrote:
On Saturday, 12 May 2018 at 13:29, ZHUO QL (KDr2) wrote:
> Hi all, I just post a proposal for orgmode on my website(generated by = orgmode):
> http://kdr2.com/tech/emacs/1805-proposal-org-ref-code-to-text.html=C2=A0.
> Here is the source of the proposal:
> # -*- mode: org; mode: auto-fill; -*-
>
> #+TITLE: Proposal for Orgmode: references from code to text.
> #+AUTHOR: KDr2

[...]

> - Beside the ~NAME~, we could also support reference via the
>=C2=A0 =C2=A0~CUSTOM_ID~ property or anything else that can locate a te= xt chunk.
> - In the tangling process, we should do some kind of transformation of=
>=C2=A0 =C2=A0the target text, for example, escape the quote mark. A hoo= k may be
>=C2=A0 =C2=A0needed to let the user customize the transformation too. >
> What do you think?

I like the symmetry of having src reference text.=C2=A0 I guess, in what yo= u
propose above, that the text that would be incorporated would be a
single element (in org parsing parlance) or else we would have to
specify an extent in the link information.

Are you able to implement something?=C2=A0 I would definitely help test it.=

--
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-591-gee336b

--000000000000cd4c32056c2bcf29--