From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Fantin Subject: org-babel-load-file can't use properties drawers ? Date: Sun, 28 Feb 2010 21:57:29 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1601318622==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NlqD5-0006Df-90 for emacs-orgmode@gnu.org; Sun, 28 Feb 2010 15:57:55 -0500 Received: from [140.186.70.92] (port=43099 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NlqD4-0006Cw-70 for emacs-orgmode@gnu.org; Sun, 28 Feb 2010 15:57:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NlqD1-0007uI-BZ for emacs-orgmode@gnu.org; Sun, 28 Feb 2010 15:57:54 -0500 Received: from ey-out-1920.google.com ([74.125.78.148]:36870) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NlqD1-0007u9-3m for emacs-orgmode@gnu.org; Sun, 28 Feb 2010 15:57:51 -0500 Received: by ey-out-1920.google.com with SMTP id 5so517374eyb.34 for ; Sun, 28 Feb 2010 12:57:49 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --===============1601318622== Content-Type: multipart/alternative; boundary=000e0ce0d82a9f7d340480af6296 --000e0ce0d82a9f7d340480af6296 Content-Type: text/plain; charset=UTF-8 I've been using this init file to load my org-mode-contained emacs configuration : ;;; init.el --- Where all the magic begins ;; ;; This file loads both ;; - Org-mode : http://orgmode.org/ and ;; - Org-babel: http://orgmode.org/worg/org-contrib/babel/org-babel.php#library-of-babel ;; ;; It then loads the rest of our Emacs initialization from Emacs lisp ;; embedded in literate Org-mode files. ;; Load up Org Mode and Org Babel for elisp embedded in Org Mode files (setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name))) (let* ((org-dir (expand-file-name "lisp" (expand-file-name "org-mode" (expand-file-name "elisp" dotfiles-dir)))) (org-contrib-dir (expand-file-name "lisp" (expand-file-name "contrib" (expand-file-name ".." org-dir)))) (load-path (append (list org-dir org-contrib-dir) (or load-path nil)))) ;; load up Org-mode and Org-babel (require 'org-install) (require 'org-babel-init) (require 'org-babel-emacs-lisp)) ;; load up all literate org-mode files in this directory (mapc 'org-babel-load-file (directory-files dotfiles-dir t "\\.org$")) ;;; init.el ends here It's been working nicely until I tried to clean things up by setting some commonly used variables in properties drawers, and access them from emacs-lisp src blocks. The following illustrates my intent, and will behave as expected with org-babel-execute-buffer, but fails when it is loaded by org-babel-load-file : * Configuration :PROPERTIES: :ELISP-DIR:~/emacs.d/elisp/ :END: ** Load Path #+begin_src emacs-lisp (add-to-list 'load-path (org-entry-get nil "ELISP-DIR" t)) #+end_src >From my understanding, orb-babel-load-file tangles then loads the file, losing the variables in the process. I've been using this function to get the expected behaviour, but the default somewhat breaks expectations, don't you think ? (defun ba/org-babel-load-file (file) (with-temp-buffer (insert-file-contents file) (org-mode) (org-babel-execute-buffer))) Or, is there a cleaner way to achieve this ? Regards, julien --000e0ce0d82a9f7d340480af6296 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I've been using this init file to load my org-mode-contained emacs conf= iguration =C2=A0:

;;; init.el --- Where all the mag= ic begins
;;
;; This file loads both
;; - Org= -mode : http://orgmode.org/ and
;;
;; It then loads th= e rest of our Emacs initialization from Emacs lisp
;; embedded in literate Org-mode files.
;; Load up Org Mode = and Org Babel for elisp embedded in Org Mode files
(setq dotfiles= -dir (file-name-directory (or (buffer-file-name) load-file-name)))

(let* ((org-dir (expand-file-name
=C2=A0=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "lisp" (expa= nd-file-name
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "org-mode" (expand-file-na= me
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"elisp" do= tfiles-dir))))
=C2=A0=C2=A0 =C2=A0 =C2=A0 (org-contrib-dir (expand-file-name
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 "lisp" (expand-file-name
=C2=A0=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "contrib" (expand-file-name
=
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0".." org-dir))))
=C2=A0=C2=A0 =C2=A0 =C2=A0 (load-path (append (list org-dir org-contri= b-dir)
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or load-path nil))))
=C2= =A0=C2=A0;; load up Org-mode and Org-babel
=C2=A0=C2=A0(require &= #39;org-install)
=C2=A0=C2=A0(require 'org-babel-init)
=C2=A0=C2=A0(require 'org-babel-emacs-lisp))
;; load up = all literate org-mode files in this directory
(mapc 'org-babe= l-load-file (directory-files dotfiles-dir t "\\.org$"))
;;; init.el ends here


It's been working nicely until= I tried to clean things up by setting some commonly used variables =C2=A0i= n properties drawers, and access them from emacs-lisp src blocks.

The following illustrates my intent, and will behave as expe= cted with org-babel-execute-buffer, but fails when it is loaded by org-babe= l-load-file :

* Configuration
:PROPERTIES:
:ELISP-DIR:~/emacs.d/elisp/
:END:

*= * Load Path
#+begin_src emacs-lisp=C2=A0
(add-to-list &= #39;load-path (org-entry-get nil "ELISP-DIR" t))
#+end_= src

From my understanding, orb-babel-load-file tangle= s then loads the file, losing the variables in the process.

<= /div>
I've been using this function to get the expected behaviour, = but the default somewhat breaks expectations, don't you think ?
=C2=A0(defun
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0ba/org-ba= bel-load-file (file) (with-temp-buffer (insert-file-contents
=C2= =A0=C2=A0 =C2=A0 =C2=A0 =C2=A0file) (org-mode) (org-babel-execute-buffer)))=

Or, is there a cleaner way to achieve this = ?

Regards,
julien
--000e0ce0d82a9f7d340480af6296-- --===============1601318622== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1601318622==--