From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: map function definitions to org src blocks? Date: Fri, 9 Nov 2018 09:40:37 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000713196057a3c5648" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL7xt-0002SX-RP for emacs-orgmode@gnu.org; Fri, 09 Nov 2018 09:40:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL7xs-0005hM-6x for emacs-orgmode@gnu.org; Fri, 09 Nov 2018 09:40:53 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:46648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gL7xr-0005gR-PA for emacs-orgmode@gnu.org; Fri, 09 Nov 2018 09:40:52 -0500 Received: by mail-wr1-x435.google.com with SMTP id 74-v6so2124837wrb.13 for ; Fri, 09 Nov 2018 06:40:51 -0800 (PST) In-Reply-To: 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: Matt Price Cc: org-mode-email --000000000000713196057a3c5648 Content-Type: text/plain; charset="UTF-8" It looks like it is possible to get describe-func to point to an org-file. Suppose I have a file /Users/jkitchin/vc/journal/2018/11/09/2018-11-09.org that has src blocks that tangle to /Users/jkitchin/vc/journal/2018/11/09/test.el. When test.el is loaded, it adds a bunch of stuff to the variable load-history that describe-function can use to get information. For example: #+BEGIN_SRC emacs-lisp (assoc "/Users/jkitchin/vc/journal/2018/11/09/test.el" load-history) #+END_SRC #+RESULTS: : (/Users/jkitchin/vc/journal/2018/11/09/test.el (defun . some-func)) One solution is to just change the file name in load-history like this. #+BEGIN_SRC emacs-lisp (setf (car (assoc "/Users/jkitchin/vc/journal/2018/11/09/test.el" load-history)) "/Users/jkitchin/vc/journal/2018/11/09/2018-11-09.org") #+END_SRC John Something like this could be handled in an :after advice for example. This is only lightly tested... I don't know if it has other implications. ----------------------------------- 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 Thu, Nov 8, 2018 at 10:22 PM Matt Price wrote: > THanks John. I guess I should always just start my search for "something > cool I saw" in scimax... > > Yes, thisis pretty great. I havebeen using ~helpful~ which hasa nice > interface for some extra functions, but these functions do most of what I > felt was missing. > > On Thu, Nov 8, 2018 at 6:02 PM John Kitchin > wrote: > >> I wrote something kind of like this at >> >> https://github.com/jkitchin/scimax/blob/master/scimax-literate-programming.el >> >> >> It might solve a different problem related to navigating code embedded in >> org files. >> >> I don't think it works on describe-function. That would be an interesting >> addition perhaps. I guess though that describe-function would go to the >> elisp code. I never figured out how to get links in the tangled code to >> jump back to the org file though. >> >> On Thu, Nov 8, 2018 at 5:39 PM Matt Price wrote: >> >>> I feel like I saw someone do this but can't find it in my notes. When >>> tangling code to elisp, is it possible to point ~describe-function~ to the >>> original org-mode source (or at least the src block) as the "source code" >>> for the function, rather than the resultant .e file produced by >>> org-babel-tangle? Seems like this would make a whole lot of things >>> significantly easier when writing emacs inits, for instnace. >>> >> -- >> 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 >> >> --000000000000713196057a3c5648 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It looks like it is poss= ible to get describe-func to point to an org-file.=C2=A0 Suppose I have a f= ile /Users/jkitchin/vc/journal/2018/11/09/2018-11-09.org that has src blocks that tangle to /Users/jkitchin/vc/j= ournal/2018/11/09/test.el. When test.el is loaded, it adds a bunch of stuff= to the variable load-history that describe-function can use to get informa= tion. For example:

#+BEGIN_SRC emacs-lisp
(assoc "/Users/= jkitchin/vc/journal/2018/11/09/test.el" load-history)
#+END_SRC

#+RESULTS:=
: (/Users/jkitchin/vc/journal/2018/11/09/test.el (de= fun . some-func))

One solution is to just change t= he file name in load-history like this.

#+BEG= IN_SRC emacs-lisp
(setf (car (assoc "/Users/jkitchin/vc/jour= nal/2018/11/09/test.el" load-history)) "/Users/jkitchin/vc/journa= l/2018/11/09/2018-11-09.org")
#+END_SRC
John

Something like this could be= handled in an :after advice for example.

<= div dir=3D"ltr">This is only lightly tested... I don't know if it has o= ther implications.

------------------------------= -----
Professor John Kitchin=C2=A0
Doherty Hall A207F
Department o= f Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 1521= 3
412-268-7803


=
I wrote something kin= d of like this at=C2=A0
https://github= .com/jkitchin/scimax/blob/master/scimax-literate-programming.el=C2=A0

It might solve a differen= t problem related to navigating code embedded in org files.

I don't think it w= orks on describe-function. That would be an interesting addition perhaps. I= guess though that describe-function would go to the elisp code. I never fi= gured out how to get links in the tangled code to jump back to the org file= though.=C2=A0

On Thu,= Nov 8, 2018 at 5:39 PM Matt Price <moptop99@gmail.com> wrote:
I feel like I saw someone do this but c= an't find it in my notes. When tangling code to elisp, is it possible t= o point ~describe-function~ to the original org-mode source (or at least th= e src block) as the "source code" for the function, rather than t= he resultant .e file produced by org-babel-tangle? Seems like this would ma= ke a whole lot of things significantly easier when writing emacs inits, for= instnace. =C2=A0
--
John

---------------------= --------------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Dep= artment of Chemical Engineering
Carnegie Mellon University
Pittsburgh= , PA 15213
412-268-7803
--000000000000713196057a3c5648--