From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Writing .el files for org in org? Date: Tue, 29 Jul 2014 22:04:12 -0400 Message-ID: References: <87lhturac1.fsf@gmail.com> <87sio29op5.fsf@bzg.ath.cx> <87vbsy88lk.fsf@bzg.ath.cx> <8738g2krbk.fsf@bzg.ath.cx> <87d2cp75wd.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113633128fe6f904ff5f9228 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCJFZ-0005Kt-Oq for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 22:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCJFX-00040b-Fs for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 22:04:17 -0400 In-Reply-To: <87d2cp75wd.fsf@bzg.ath.cx> 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: Bastien Cc: Aaron Ecay , "emacs-orgmode@gnu.org" --001a113633128fe6f904ff5f9228 Content-Type: text/plain; charset=UTF-8 Ok, I am giving it a shot. Here is my setup: ;;;;;;; org path (defvar org-load-path (list (file-name-as-directory (expand-file-name "org" starter-kit-dir))) "List of directories to find org-files that `org-babel-load-file' can load code from") (defun org-require (feature) "Load a FEATURE from an org-file. FEATURE is a symbol, and it is loaded from an org-file by the name of FEATURE.org, that is in the `org-load-path'. The FEATURE is loaded from `org-babel-load-file'." (let ((org-file (concat (symbol-name feature) ".org")) (path)) ;; find the org-file (catch 'result (loop for dir in org-load-path do (when (file-exists-p (setq path (expand-file-name org-file dir))) (throw 'result path)))) (let ((default-directory (file-name-directory path))) (org-babel-load-file path)))) (org-require 'org-ref) (org-require 'doi-utils) (org-require 'org-show) In the only directory I define in org-load-path, I put org-show.org, org-ref.org, and doi-utils.org, and the code above is in an init file. When I load emacs, for these files, so far, it works great. They are simple files that only tangle to one .el file so far. John ----------------------------------- John Kitchin Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu On Sun, Jul 27, 2014 at 5:50 PM, Bastien wrote: > Hi John and Rainer, > > Rainer M Krug writes: > > >> What if we created a new directory in the repository called "org" which > >> contains these kinds of files? It would be analogous to the "lisp" > >> directory. I don't think we need to have both ob-R.org and ob-R.el in > the > >> repository. > > > > I think that would be a very good idea for certain modules like your > > org-ref and ob-R I am working on. > > Maybe you could use such a "load-flow" for a while, see if it is > robust enough, and if so, we could move on and have it in the repo? > > My gut feeling is that it will bring some issues, so experimenting > before would be nice. > > -- > Bastien > --001a113633128fe6f904ff5f9228 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ok, I am giving it a shot. Here is my setup:

;;;;;;; org path
(defvar org-load-path=C2=A0
=C2=A0 (list (file-name-as-directory
(expand-file-name "org" starter-kit-dir)= ))
=C2=A0 "List of directories to find org-files that
=C2= =A0 `org-babel-load-file' can load code from")

(defun org-require (feature)
=C2=A0 "Load a FEATURE fr= om an org-file.
FEATURE is a symbol, and it is loaded from an org-file by the name of = FEATURE.org, that is in the `org-load-path'. The FEATURE is loaded from= `org-babel-load-file'."
=C2=A0 (let ((org-file (concat = (symbol-name feature) ".org"))
(path))
<= br>
=C2=A0 =C2=A0 ;; find the org-file
=C2=A0 =C2=A0 (c= atch 'result
=C2=A0 =C2=A0 =C2=A0 (loop for dir in org-load-p= ath do
=C2=A0= =C2=A0(when (file-exists-p
=C2=A0 (setq path=
(expand-fi= le-name
=C2= =A0org-file
=C2=A0dir)))
=C2=A0 =C2=A0 =C2=A0(= throw 'result path))))
=C2=A0 =C2=A0 (let ((default-directory= (file-name-directory path)))
=C2=A0 =C2=A0 =C2=A0 (org-babel-load-file path))))

(org-require 'org-ref)
(org-require 'doi-utils)
(org-require 'org-show)


In the only directory I define in org-load-path, I put org-show.org, org-ref.= org, and doi-utils.org, and the co= de above is in an init file. When I load emacs, for these files, so far, it= works great. They are simple files that only tangle to one .el file so far= .



John

-----------------------------------=
John Kitchin
Professor
Doherty Hall A207F
Department of Chemic= al Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingr= oup.cheme.cmu.edu



On Sun, Jul 27, 2014 at 5:50 PM, Bastien= <bzg= @gnu.org> wrote:
Hi John and Rainer,

Rainer M Krug <Rainer@krugs.de>= ; writes:

>> What if we created a new directory in the re= pository called "org" which
>> contains these kinds of files? =C2=A0It would be analogous to the = "lisp"
>> directory. I don't think we need to have both ob-R.org and ob-= R.el in the
>> repository.
>
> I think that would be a very good idea for certain modules like your > org-ref and ob-R I am working on.

Maybe you could use such a "load-flow" for a while, see if = it is
robust enough, and if so, we could move on and have it in the repo?

My gut feeling is that it will bring some issues, so experimenting
before would be nice.

--
=C2=A0Bastien

--001a113633128fe6f904ff5f9228--