emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL] BUG - error on tangling - disappears when changing the filename
@ 2013-09-27 12:23 Rainer M Krug
  2013-09-27 13:30 ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2013-09-27 12:23 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Eric Schulte

[-- Attachment #1: Type: text/plain, Size: 7373 bytes --]

Hi

I have a strange error when tangling.

I have a large org file with several code blocks tangling in about
20 R files and one bash file. Usually tangling works perfectly, but
sometimes one code block does not tangle a code block to a file. These
are different blocks. When I change the name of the fiole to be tangled
to, it works again. After d=some time, I can rename it again and it
works again.

The last time it happened, I was debugging the function. But even when
deleting all the content of the code block, the problem persists.

This persists over restarts of org.

The code block looks as follow:

,----
| *** dispProb2D (./R/dispProd2D.R) 
| :PROPERTIES:
| :tangle:   ./R/dispProd2D.R
| :comments: yes
| :no-expand: TRUE
| :END: 
| #+begin_src R
| cat(5)
| #+end_src  
`----

In the original version, there is obviously code in it, but the error
occurs even in the empty block. I just renamed the block, and it is
working again.

Any idea what is causing this?

Please find the backtrace below.

Cheers,

Rainer

,----
| ebugger entered--Lisp error: (wrong-type-argument stringp nil)
|   set-buffer(nil)
|   (save-current-buffer (set-buffer (get-file-buffer file)) (revert-buffer t t t))
|   org-babel-find-file-noselect-refresh("./R/dispProd2D.R")
|   (let* ((temp-path file) (visited-p (get-file-buffer temp-path)) temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file (get-file-buffer temp-path)) (save-current-buffer (set-buffer temp-file) (setq temp-result (progn (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer temp-file)) temp-result)
|   (lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer temp-path)) temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file (get-file-buffer temp-path)) (save-current-buffer (set-buffer temp-file) (setq temp-result (progn (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer temp-file)) temp-result))("./R/dispProd2D.R")
|   mapc((lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer temp-path)) temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file (get-file-buffer temp-path)) (save-current-buffer (set-buffer temp-file) (setq temp-result (progn (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer temp-file)) temp-result)) ("postTangleScript.sh" "./.gitignore" "./DESCRIPTION" "./.Rbuildignore" "./R/parmsFire.R" "./R/parmsPinus.R" "./R/parmsAcacia.R" "./R/parmsRubus.R" "./R/parmsBudget.R" "./R/parameter.R" "./R/endYear.R" "./R/germEst.R" "./R/seedDispersal.R" "./R/seedProduction.R" "./R/fireAliens.R" "./R/clearAliens.R" "./R/prioritisation.R" "./R/beginYear.R" "./R/main.R" "./R/cumulativeDc.R" "./R/dcToIndLayer.R" "./R/competition.R" "./R/dispProd2D.R" "./R/initfun.R" "./R/newInDrak.R" "./R/resetOptions.R" "./R/stats.R" "./R/layerIO.R" "./R/layerNames.R" "./R/onLoad.R" "./NAMESPACE" "./R/package.R"))
|   (progn (mapc (function (lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer temp-path)) temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file (get-file-buffer temp-path)) (save-current-buffer (set-buffer temp-file) (setq temp-result (progn ...))) (if visited-p nil (kill-buffer temp-file)) temp-result))) (mapcar (function car) path-collector)))
|   (if org-babel-post-tangle-hook (progn (mapc (function (lambda (file) (let* ((temp-path file) (visited-p ...) temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file (get-file-buffer temp-path)) (save-current-buffer (set-buffer temp-file) (setq temp-result ...)) (if visited-p nil (kill-buffer temp-file)) temp-result))) (mapcar (function car) path-collector))))
|   (let ((block-counter 0) (org-babel-default-header-args (if target-file (org-babel-merge-params org-babel-default-header-args (list (cons :tangle target-file))) org-babel-default-header-args)) (tangle-file (if (equal arg (quote (16))) (progn (or (cdr (assoc :tangle ...)) (user-error "Point is not in a source code block"))))) path-collector) (mapc (function (lambda (by-lang) (let* ((lang (car by-lang)) (specs (cdr by-lang)) (ext (or ... lang)) (lang-f (intern ...)) she-banged) (mapc (function (lambda ... ...)) specs)))) (if (equal arg (quote (4))) (org-babel-tangle-single-block 1 t) (org-babel-tangle-collect-blocks lang tangle-file))) (message "Tangled %d code block%s from %s" block-counter (if (= block-counter 1) "" "s") (file-name-nondirectory (buffer-file-name (or (buffer-base-buffer) (current-buffer))))) (if org-babel-post-tangle-hook (progn (mapc (function (lambda (file) (let* (... ... temp-result temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq temp-file ...) (save-current-buffer ... ...) (if visited-p nil ...) temp-result))) (mapcar (function car) path-collector)))) (mapc (function (lambda (pair) (if (cdr pair) (progn (set-file-modes (car pair) (cdr pair)))))) path-collector) (mapcar (function car) path-collector))
|   (save-excursion (let ((block-counter 0) (org-babel-default-header-args (if target-file (org-babel-merge-params org-babel-default-header-args (list (cons :tangle target-file))) org-babel-default-header-args)) (tangle-file (if (equal arg (quote (16))) (progn (or (cdr ...) (user-error "Point is not in a source code block"))))) path-collector) (mapc (function (lambda (by-lang) (let* ((lang ...) (specs ...) (ext ...) (lang-f ...) she-banged) (mapc (function ...) specs)))) (if (equal arg (quote (4))) (org-babel-tangle-single-block 1 t) (org-babel-tangle-collect-blocks lang tangle-file))) (message "Tangled %d code block%s from %s" block-counter (if (= block-counter 1) "" "s") (file-name-nondirectory (buffer-file-name (or (buffer-base-buffer) (current-buffer))))) (if org-babel-post-tangle-hook (progn (mapc (function (lambda (file) (let* ... ... ... ... ... temp-result))) (mapcar (function car) path-collector)))) (mapc (function (lambda (pair) (if (cdr pair) (progn (set-file-modes ... ...))))) path-collector) (mapcar (function car) path-collector)))
|   (save-restriction (if (equal arg (quote (4))) (progn (let ((head (org-babel-where-is-src-block-head))) (if head (goto-char head) (user-error "Point is not in a source code block"))))) (save-excursion (let ((block-counter 0) (org-babel-default-header-args (if target-file (org-babel-merge-params org-babel-default-header-args (list ...)) org-babel-default-header-args)) (tangle-file (if (equal arg (quote ...)) (progn (or ... ...)))) path-collector) (mapc (function (lambda (by-lang) (let* (... ... ... ... she-banged) (mapc ... specs)))) (if (equal arg (quote (4))) (org-babel-tangle-single-block 1 t) (org-babel-tangle-collect-blocks lang tangle-file))) (message "Tangled %d code block%s from %s" block-counter (if (= block-counter 1) "" "s") (file-name-nondirectory (buffer-file-name (or (buffer-base-buffer) (current-buffer))))) (if org-babel-post-tangle-hook (progn (mapc (function (lambda ... ...)) (mapcar (function car) path-collector)))) (mapc (function (lambda (pair) (if (cdr pair) (progn ...)))) path-collector) (mapcar (function car) path-collector))))
|   org-babel-tangle(nil)
|   call-interactively(org-babel-tangle nil nil)
`----


-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

[-- Attachment #2: Type: application/pgp-signature, Size: 486 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BABEL] BUG - error on tangling - disappears when changing the filename
  2013-09-27 12:23 [BABEL] BUG - error on tangling - disappears when changing the filename Rainer M Krug
@ 2013-09-27 13:30 ` Rainer M Krug
  2013-09-27 13:44   ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2013-09-27 13:30 UTC (permalink / raw)
  To: emacs-orgmode


Forgot: tried with 8.2 stable release and with version from git - both
the same.

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

> Hi
>
> I have a strange error when tangling.
>
> I have a large org file with several code blocks tangling in about
> 20 R files and one bash file. Usually tangling works perfectly, but
> sometimes one code block does not tangle a code block to a file. These
> are different blocks. When I change the name of the fiole to be tangled
> to, it works again. After d=some time, I can rename it again and it
> works again.
>
> The last time it happened, I was debugging the function. But even when
> deleting all the content of the code block, the problem persists.
>
> This persists over restarts of org.
>
> The code block looks as follow:
>
> ,----
> | *** dispProb2D (./R/dispProd2D.R) 
> | :PROPERTIES:
> | :tangle:   ./R/dispProd2D.R
> | :comments: yes
> | :no-expand: TRUE
> | :END: 
> | #+begin_src R
> | cat(5)
> | #+end_src  
> `----
>
> In the original version, there is obviously code in it, but the error
> occurs even in the empty block. I just renamed the block, and it is
> working again.
>
> Any idea what is causing this?
>
> Please find the backtrace below.
>
> Cheers,
>
> Rainer
>
> ,----
> | ebugger entered--Lisp error: (wrong-type-argument stringp nil)
> |   set-buffer(nil)
> |   (save-current-buffer (set-buffer (get-file-buffer file)) (revert-buffer t t t))
> |   org-babel-find-file-noselect-refresh("./R/dispProd2D.R")
> |   (let* ((temp-path file) (visited-p (get-file-buffer temp-path))
> | temp-result temp-file) (org-babel-find-file-noselect-refresh
> | temp-path) (setq temp-file (get-file-buffer temp-path))
> | (save-current-buffer (set-buffer temp-file) (setq temp-result (progn
> | (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil
> | (kill-buffer temp-file)) temp-result)
> |   (lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer
> | temp-path)) temp-result temp-file)
> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
> | temp-file) (setq temp-result (progn (run-hooks (quote
> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
> | temp-file)) temp-result))("./R/dispProd2D.R")
> |   mapc((lambda (file) (let* ((temp-path file) (visited-p
> | (get-file-buffer temp-path)) temp-result temp-file)
> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
> | temp-file) (setq temp-result (progn (run-hooks (quote
> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
> | temp-file)) temp-result)) ("postTangleScript.sh" "./.gitignore"
> | "./DESCRIPTION" "./.Rbuildignore" "./R/parmsFire.R"
> | "./R/parmsPinus.R" "./R/parmsAcacia.R" "./R/parmsRubus.R"
> | "./R/parmsBudget.R" "./R/parameter.R" "./R/endYear.R"
> | "./R/germEst.R" "./R/seedDispersal.R" "./R/seedProduction.R"
> | "./R/fireAliens.R" "./R/clearAliens.R" "./R/prioritisation.R"
> | "./R/beginYear.R" "./R/main.R" "./R/cumulativeDc.R"
> | "./R/dcToIndLayer.R" "./R/competition.R" "./R/dispProd2D.R"
> | "./R/initfun.R" "./R/newInDrak.R" "./R/resetOptions.R" "./R/stats.R"
> | "./R/layerIO.R" "./R/layerNames.R" "./R/onLoad.R" "./NAMESPACE"
> | "./R/package.R"))
> |   (progn (mapc (function (lambda (file) (let* ((temp-path file)
> | (visited-p (get-file-buffer temp-path)) temp-result temp-file)
> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
> | temp-file) (setq temp-result (progn ...))) (if visited-p nil
> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
> | path-collector)))
> |   (if org-babel-post-tangle-hook (progn (mapc (function (lambda
> | (file) (let* ((temp-path file) (visited-p ...) temp-result
> | temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq
> | temp-file (get-file-buffer temp-path)) (save-current-buffer
> | (set-buffer temp-file) (setq temp-result ...)) (if visited-p nil
> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
> | path-collector))))
> |   (let ((block-counter 0) (org-babel-default-header-args (if
> | target-file (org-babel-merge-params org-babel-default-header-args
> | (list (cons :tangle target-file))) org-babel-default-header-args))
> | (tangle-file (if (equal arg (quote (16))) (progn (or (cdr (assoc
> | :tangle ...)) (user-error "Point is not in a source code block")))))
> | path-collector) (mapc (function (lambda (by-lang) (let* ((lang (car
> | by-lang)) (specs (cdr by-lang)) (ext (or ... lang)) (lang-f (intern
> | ...)) she-banged) (mapc (function (lambda ... ...)) specs)))) (if
> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
> | (buffer-base-buffer) (current-buffer))))) (if
> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
> | (let* (... ... temp-result temp-file)
> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
> | ...) (save-current-buffer ... ...) (if visited-p nil ...)
> | temp-result))) (mapcar (function car) path-collector)))) (mapc
> | (function (lambda (pair) (if (cdr pair) (progn (set-file-modes (car
> | pair) (cdr pair)))))) path-collector) (mapcar (function car)
> | path-collector))
> |   (save-excursion (let ((block-counter 0)
> | (org-babel-default-header-args (if target-file
> | (org-babel-merge-params org-babel-default-header-args (list (cons
> | :tangle target-file))) org-babel-default-header-args)) (tangle-file
> | (if (equal arg (quote (16))) (progn (or (cdr ...) (user-error "Point
> | is not in a source code block"))))) path-collector) (mapc (function
> | (lambda (by-lang) (let* ((lang ...) (specs ...) (ext ...) (lang-f
> | ...) she-banged) (mapc (function ...) specs)))) (if (equal arg
> | (quote (4))) (org-babel-tangle-single-block 1 t)
> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
> | (buffer-base-buffer) (current-buffer))))) (if
> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
> | (let* ... ... ... ... ... temp-result))) (mapcar (function car)
> | path-collector)))) (mapc (function (lambda (pair) (if (cdr pair)
> | (progn (set-file-modes ... ...))))) path-collector) (mapcar
> | (function car) path-collector)))
> |   (save-restriction (if (equal arg (quote (4))) (progn (let ((head
> | (org-babel-where-is-src-block-head))) (if head (goto-char head)
> | (user-error "Point is not in a source code block")))))
> | (save-excursion (let ((block-counter 0)
> | (org-babel-default-header-args (if target-file
> | (org-babel-merge-params org-babel-default-header-args (list ...))
> | org-babel-default-header-args)) (tangle-file (if (equal arg (quote
> | ...)) (progn (or ... ...)))) path-collector) (mapc (function (lambda
> | (by-lang) (let* (... ... ... ... she-banged) (mapc ... specs)))) (if
> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
> | (buffer-base-buffer) (current-buffer))))) (if
> | org-babel-post-tangle-hook (progn (mapc (function (lambda ... ...))
> | (mapcar (function car) path-collector)))) (mapc (function (lambda
> | (pair) (if (cdr pair) (progn ...)))) path-collector) (mapcar
> | (function car) path-collector))))
> |   org-babel-tangle(nil)
> |   call-interactively(org-babel-tangle nil nil)
> `----
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BABEL] BUG - error on tangling - disappears when changing the filename
  2013-09-27 13:30 ` Rainer M Krug
@ 2013-09-27 13:44   ` Rainer M Krug
  2013-09-28 12:22     ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2013-09-27 13:44 UTC (permalink / raw)
  To: emacs-orgmode

OK - narrowed it down to a post tangle hook which I need for proper
debugging of R (jumping to source line in org file and not tangled R file):

,----
| #+begin_src emacs-lisp
| (defvar org-babel-tangled-file nil
|   "If non-nill, current file was tangled with org-babel-tangle")
| (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
| 
| (defun org-babel-mark-file-as-tangled ()
|   (when  (string-match "[.]R" (buffer-file-name))
|     (add-file-local-variable 'org-babel-tangled-file t)
|     (add-file-local-variable 'buffer-read-only t)
|     (add-file-local-variable 'eval: '(auto-revert-mode))
|     (basic-save-buffer)))
| 
| (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
| #+end_src
`----

The question is now why is this function org-babel-mark-file-as-tangled
receives NULL as a buffer-file-name? 
I can't remove the "when" as I am also tangling some files which do not
have any comment characters (DESCRIPTION file in R packages).

Any suggestions welcome,

Rainer


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

> Forgot: tried with 8.2 stable release and with version from git - both
> the same.
>
> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Hi
>>
>> I have a strange error when tangling.
>>
>> I have a large org file with several code blocks tangling in about
>> 20 R files and one bash file. Usually tangling works perfectly, but
>> sometimes one code block does not tangle a code block to a file. These
>> are different blocks. When I change the name of the fiole to be tangled
>> to, it works again. After d=some time, I can rename it again and it
>> works again.
>>
>> The last time it happened, I was debugging the function. But even when
>> deleting all the content of the code block, the problem persists.
>>
>> This persists over restarts of org.
>>
>> The code block looks as follow:
>>
>> ,----
>> | *** dispProb2D (./R/dispProd2D.R) 
>> | :PROPERTIES:
>> | :tangle:   ./R/dispProd2D.R
>> | :comments: yes
>> | :no-expand: TRUE
>> | :END: 
>> | #+begin_src R
>> | cat(5)
>> | #+end_src  
>> `----
>>
>> In the original version, there is obviously code in it, but the error
>> occurs even in the empty block. I just renamed the block, and it is
>> working again.
>>
>> Any idea what is causing this?
>>
>> Please find the backtrace below.
>>
>> Cheers,
>>
>> Rainer
>>
>> ,----
>> | ebugger entered--Lisp error: (wrong-type-argument stringp nil)
>> |   set-buffer(nil)
>> |   (save-current-buffer (set-buffer (get-file-buffer file)) (revert-buffer t t t))
>> |   org-babel-find-file-noselect-refresh("./R/dispProd2D.R")
>> |   (let* ((temp-path file) (visited-p (get-file-buffer temp-path))
>> | temp-result temp-file) (org-babel-find-file-noselect-refresh
>> | temp-path) (setq temp-file (get-file-buffer temp-path))
>> | (save-current-buffer (set-buffer temp-file) (setq temp-result (progn
>> | (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil
>> | (kill-buffer temp-file)) temp-result)
>> |   (lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer
>> | temp-path)) temp-result temp-file)
>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>> | temp-file) (setq temp-result (progn (run-hooks (quote
>> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
>> | temp-file)) temp-result))("./R/dispProd2D.R")
>> |   mapc((lambda (file) (let* ((temp-path file) (visited-p
>> | (get-file-buffer temp-path)) temp-result temp-file)
>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>> | temp-file) (setq temp-result (progn (run-hooks (quote
>> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
>> | temp-file)) temp-result)) ("postTangleScript.sh" "./.gitignore"
>> | "./DESCRIPTION" "./.Rbuildignore" "./R/parmsFire.R"
>> | "./R/parmsPinus.R" "./R/parmsAcacia.R" "./R/parmsRubus.R"
>> | "./R/parmsBudget.R" "./R/parameter.R" "./R/endYear.R"
>> | "./R/germEst.R" "./R/seedDispersal.R" "./R/seedProduction.R"
>> | "./R/fireAliens.R" "./R/clearAliens.R" "./R/prioritisation.R"
>> | "./R/beginYear.R" "./R/main.R" "./R/cumulativeDc.R"
>> | "./R/dcToIndLayer.R" "./R/competition.R" "./R/dispProd2D.R"
>> | "./R/initfun.R" "./R/newInDrak.R" "./R/resetOptions.R" "./R/stats.R"
>> | "./R/layerIO.R" "./R/layerNames.R" "./R/onLoad.R" "./NAMESPACE"
>> | "./R/package.R"))
>> |   (progn (mapc (function (lambda (file) (let* ((temp-path file)
>> | (visited-p (get-file-buffer temp-path)) temp-result temp-file)
>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>> | temp-file) (setq temp-result (progn ...))) (if visited-p nil
>> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
>> | path-collector)))
>> |   (if org-babel-post-tangle-hook (progn (mapc (function (lambda
>> | (file) (let* ((temp-path file) (visited-p ...) temp-result
>> | temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq
>> | temp-file (get-file-buffer temp-path)) (save-current-buffer
>> | (set-buffer temp-file) (setq temp-result ...)) (if visited-p nil
>> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
>> | path-collector))))
>> |   (let ((block-counter 0) (org-babel-default-header-args (if
>> | target-file (org-babel-merge-params org-babel-default-header-args
>> | (list (cons :tangle target-file))) org-babel-default-header-args))
>> | (tangle-file (if (equal arg (quote (16))) (progn (or (cdr (assoc
>> | :tangle ...)) (user-error "Point is not in a source code block")))))
>> | path-collector) (mapc (function (lambda (by-lang) (let* ((lang (car
>> | by-lang)) (specs (cdr by-lang)) (ext (or ... lang)) (lang-f (intern
>> | ...)) she-banged) (mapc (function (lambda ... ...)) specs)))) (if
>> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>> | (buffer-base-buffer) (current-buffer))))) (if
>> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
>> | (let* (... ... temp-result temp-file)
>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>> | ...) (save-current-buffer ... ...) (if visited-p nil ...)
>> | temp-result))) (mapcar (function car) path-collector)))) (mapc
>> | (function (lambda (pair) (if (cdr pair) (progn (set-file-modes (car
>> | pair) (cdr pair)))))) path-collector) (mapcar (function car)
>> | path-collector))
>> |   (save-excursion (let ((block-counter 0)
>> | (org-babel-default-header-args (if target-file
>> | (org-babel-merge-params org-babel-default-header-args (list (cons
>> | :tangle target-file))) org-babel-default-header-args)) (tangle-file
>> | (if (equal arg (quote (16))) (progn (or (cdr ...) (user-error "Point
>> | is not in a source code block"))))) path-collector) (mapc (function
>> | (lambda (by-lang) (let* ((lang ...) (specs ...) (ext ...) (lang-f
>> | ...) she-banged) (mapc (function ...) specs)))) (if (equal arg
>> | (quote (4))) (org-babel-tangle-single-block 1 t)
>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>> | (buffer-base-buffer) (current-buffer))))) (if
>> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
>> | (let* ... ... ... ... ... temp-result))) (mapcar (function car)
>> | path-collector)))) (mapc (function (lambda (pair) (if (cdr pair)
>> | (progn (set-file-modes ... ...))))) path-collector) (mapcar
>> | (function car) path-collector)))
>> |   (save-restriction (if (equal arg (quote (4))) (progn (let ((head
>> | (org-babel-where-is-src-block-head))) (if head (goto-char head)
>> | (user-error "Point is not in a source code block")))))
>> | (save-excursion (let ((block-counter 0)
>> | (org-babel-default-header-args (if target-file
>> | (org-babel-merge-params org-babel-default-header-args (list ...))
>> | org-babel-default-header-args)) (tangle-file (if (equal arg (quote
>> | ...)) (progn (or ... ...)))) path-collector) (mapc (function (lambda
>> | (by-lang) (let* (... ... ... ... she-banged) (mapc ... specs)))) (if
>> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>> | (buffer-base-buffer) (current-buffer))))) (if
>> | org-babel-post-tangle-hook (progn (mapc (function (lambda ... ...))
>> | (mapcar (function car) path-collector)))) (mapc (function (lambda
>> | (pair) (if (cdr pair) (progn ...)))) path-collector) (mapcar
>> | (function car) path-collector))))
>> |   org-babel-tangle(nil)
>> |   call-interactively(org-babel-tangle nil nil)
>> `----
> <#secure method=pgpmime mode=sign>
>
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BABEL] BUG - error on tangling - disappears when changing the filename
  2013-09-27 13:44   ` Rainer M Krug
@ 2013-09-28 12:22     ` Eric Schulte
  2013-09-30  7:30       ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2013-09-28 12:22 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode

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

> OK - narrowed it down to a post tangle hook which I need for proper
> debugging of R (jumping to source line in org file and not tangled R file):
>
> ,----
> | #+begin_src emacs-lisp
> | (defvar org-babel-tangled-file nil
> |   "If non-nill, current file was tangled with org-babel-tangle")
> | (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
> | 
> | (defun org-babel-mark-file-as-tangled ()
> |   (when  (string-match "[.]R" (buffer-file-name))
> |     (add-file-local-variable 'org-babel-tangled-file t)
> |     (add-file-local-variable 'buffer-read-only t)
> |     (add-file-local-variable 'eval: '(auto-revert-mode))
> |     (basic-save-buffer)))
> | 
> | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
> | #+end_src
> `----
>
> The question is now why is this function org-babel-mark-file-as-tangled
> receives NULL as a buffer-file-name? 

I'm not sure, but perhaps you could wrap the body of buffer-file-name in
a (when (buffer-file-name) ...) form to protect against null files.

Hope this helps,

> 
> I can't remove the "when" as I am also tangling some files which do
> not have any comment characters (DESCRIPTION file in R packages).
>
> Any suggestions welcome,
>
> Rainer
>
>
> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Forgot: tried with 8.2 stable release and with version from git - both
>> the same.
>>
>> Rainer M Krug <Rainer@krugs.de> writes:
>>
>>> Hi
>>>
>>> I have a strange error when tangling.
>>>
>>> I have a large org file with several code blocks tangling in about
>>> 20 R files and one bash file. Usually tangling works perfectly, but
>>> sometimes one code block does not tangle a code block to a file. These
>>> are different blocks. When I change the name of the fiole to be tangled
>>> to, it works again. After d=some time, I can rename it again and it
>>> works again.
>>>
>>> The last time it happened, I was debugging the function. But even when
>>> deleting all the content of the code block, the problem persists.
>>>
>>> This persists over restarts of org.
>>>
>>> The code block looks as follow:
>>>
>>> ,----
>>> | *** dispProb2D (./R/dispProd2D.R) 
>>> | :PROPERTIES:
>>> | :tangle:   ./R/dispProd2D.R
>>> | :comments: yes
>>> | :no-expand: TRUE
>>> | :END: 
>>> | #+begin_src R
>>> | cat(5)
>>> | #+end_src  
>>> `----
>>>
>>> In the original version, there is obviously code in it, but the error
>>> occurs even in the empty block. I just renamed the block, and it is
>>> working again.
>>>
>>> Any idea what is causing this?
>>>
>>> Please find the backtrace below.
>>>
>>> Cheers,
>>>
>>> Rainer
>>>
>>> ,----
>>> | ebugger entered--Lisp error: (wrong-type-argument stringp nil)
>>> |   set-buffer(nil)
>>> |   (save-current-buffer (set-buffer (get-file-buffer file)) (revert-buffer t t t))
>>> |   org-babel-find-file-noselect-refresh("./R/dispProd2D.R")
>>> |   (let* ((temp-path file) (visited-p (get-file-buffer temp-path))
>>> | temp-result temp-file) (org-babel-find-file-noselect-refresh
>>> | temp-path) (setq temp-file (get-file-buffer temp-path))
>>> | (save-current-buffer (set-buffer temp-file) (setq temp-result (progn
>>> | (run-hooks (quote org-babel-post-tangle-hook))))) (if visited-p nil
>>> | (kill-buffer temp-file)) temp-result)
>>> |   (lambda (file) (let* ((temp-path file) (visited-p (get-file-buffer
>>> | temp-path)) temp-result temp-file)
>>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>>> | temp-file) (setq temp-result (progn (run-hooks (quote
>>> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
>>> | temp-file)) temp-result))("./R/dispProd2D.R")
>>> |   mapc((lambda (file) (let* ((temp-path file) (visited-p
>>> | (get-file-buffer temp-path)) temp-result temp-file)
>>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>>> | temp-file) (setq temp-result (progn (run-hooks (quote
>>> | org-babel-post-tangle-hook))))) (if visited-p nil (kill-buffer
>>> | temp-file)) temp-result)) ("postTangleScript.sh" "./.gitignore"
>>> | "./DESCRIPTION" "./.Rbuildignore" "./R/parmsFire.R"
>>> | "./R/parmsPinus.R" "./R/parmsAcacia.R" "./R/parmsRubus.R"
>>> | "./R/parmsBudget.R" "./R/parameter.R" "./R/endYear.R"
>>> | "./R/germEst.R" "./R/seedDispersal.R" "./R/seedProduction.R"
>>> | "./R/fireAliens.R" "./R/clearAliens.R" "./R/prioritisation.R"
>>> | "./R/beginYear.R" "./R/main.R" "./R/cumulativeDc.R"
>>> | "./R/dcToIndLayer.R" "./R/competition.R" "./R/dispProd2D.R"
>>> | "./R/initfun.R" "./R/newInDrak.R" "./R/resetOptions.R" "./R/stats.R"
>>> | "./R/layerIO.R" "./R/layerNames.R" "./R/onLoad.R" "./NAMESPACE"
>>> | "./R/package.R"))
>>> |   (progn (mapc (function (lambda (file) (let* ((temp-path file)
>>> | (visited-p (get-file-buffer temp-path)) temp-result temp-file)
>>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>>> | (get-file-buffer temp-path)) (save-current-buffer (set-buffer
>>> | temp-file) (setq temp-result (progn ...))) (if visited-p nil
>>> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
>>> | path-collector)))
>>> |   (if org-babel-post-tangle-hook (progn (mapc (function (lambda
>>> | (file) (let* ((temp-path file) (visited-p ...) temp-result
>>> | temp-file) (org-babel-find-file-noselect-refresh temp-path) (setq
>>> | temp-file (get-file-buffer temp-path)) (save-current-buffer
>>> | (set-buffer temp-file) (setq temp-result ...)) (if visited-p nil
>>> | (kill-buffer temp-file)) temp-result))) (mapcar (function car)
>>> | path-collector))))
>>> |   (let ((block-counter 0) (org-babel-default-header-args (if
>>> | target-file (org-babel-merge-params org-babel-default-header-args
>>> | (list (cons :tangle target-file))) org-babel-default-header-args))
>>> | (tangle-file (if (equal arg (quote (16))) (progn (or (cdr (assoc
>>> | :tangle ...)) (user-error "Point is not in a source code block")))))
>>> | path-collector) (mapc (function (lambda (by-lang) (let* ((lang (car
>>> | by-lang)) (specs (cdr by-lang)) (ext (or ... lang)) (lang-f (intern
>>> | ...)) she-banged) (mapc (function (lambda ... ...)) specs)))) (if
>>> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
>>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>>> | (buffer-base-buffer) (current-buffer))))) (if
>>> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
>>> | (let* (... ... temp-result temp-file)
>>> | (org-babel-find-file-noselect-refresh temp-path) (setq temp-file
>>> | ...) (save-current-buffer ... ...) (if visited-p nil ...)
>>> | temp-result))) (mapcar (function car) path-collector)))) (mapc
>>> | (function (lambda (pair) (if (cdr pair) (progn (set-file-modes (car
>>> | pair) (cdr pair)))))) path-collector) (mapcar (function car)
>>> | path-collector))
>>> |   (save-excursion (let ((block-counter 0)
>>> | (org-babel-default-header-args (if target-file
>>> | (org-babel-merge-params org-babel-default-header-args (list (cons
>>> | :tangle target-file))) org-babel-default-header-args)) (tangle-file
>>> | (if (equal arg (quote (16))) (progn (or (cdr ...) (user-error "Point
>>> | is not in a source code block"))))) path-collector) (mapc (function
>>> | (lambda (by-lang) (let* ((lang ...) (specs ...) (ext ...) (lang-f
>>> | ...) she-banged) (mapc (function ...) specs)))) (if (equal arg
>>> | (quote (4))) (org-babel-tangle-single-block 1 t)
>>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>>> | (buffer-base-buffer) (current-buffer))))) (if
>>> | org-babel-post-tangle-hook (progn (mapc (function (lambda (file)
>>> | (let* ... ... ... ... ... temp-result))) (mapcar (function car)
>>> | path-collector)))) (mapc (function (lambda (pair) (if (cdr pair)
>>> | (progn (set-file-modes ... ...))))) path-collector) (mapcar
>>> | (function car) path-collector)))
>>> |   (save-restriction (if (equal arg (quote (4))) (progn (let ((head
>>> | (org-babel-where-is-src-block-head))) (if head (goto-char head)
>>> | (user-error "Point is not in a source code block")))))
>>> | (save-excursion (let ((block-counter 0)
>>> | (org-babel-default-header-args (if target-file
>>> | (org-babel-merge-params org-babel-default-header-args (list ...))
>>> | org-babel-default-header-args)) (tangle-file (if (equal arg (quote
>>> | ...)) (progn (or ... ...)))) path-collector) (mapc (function (lambda
>>> | (by-lang) (let* (... ... ... ... she-banged) (mapc ... specs)))) (if
>>> | (equal arg (quote (4))) (org-babel-tangle-single-block 1 t)
>>> | (org-babel-tangle-collect-blocks lang tangle-file))) (message
>>> | "Tangled %d code block%s from %s" block-counter (if (= block-counter
>>> | 1) "" "s") (file-name-nondirectory (buffer-file-name (or
>>> | (buffer-base-buffer) (current-buffer))))) (if
>>> | org-babel-post-tangle-hook (progn (mapc (function (lambda ... ...))
>>> | (mapcar (function car) path-collector)))) (mapc (function (lambda
>>> | (pair) (if (cdr pair) (progn ...)))) path-collector) (mapcar
>>> | (function car) path-collector))))
>>> |   org-babel-tangle(nil)
>>> |   call-interactively(org-babel-tangle nil nil)
>>> `----
>> <#secure method=pgpmime mode=sign>
>>
> <#secure method=pgpmime mode=sign>
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BABEL] BUG - error on tangling - disappears when changing the filename
  2013-09-28 12:22     ` Eric Schulte
@ 2013-09-30  7:30       ` Rainer M Krug
  2013-10-01  0:10         ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2013-09-30  7:30 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>
>> OK - narrowed it down to a post tangle hook which I need for proper
>> debugging of R (jumping to source line in org file and not tangled R file):
>>
>> ,----
>> | #+begin_src emacs-lisp
>> | (defvar org-babel-tangled-file nil
>> |   "If non-nill, current file was tangled with org-babel-tangle")
>> | (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
>> | 
>> | (defun org-babel-mark-file-as-tangled ()
>> |   (when  (string-match "[.]R" (buffer-file-name))
>> |     (add-file-local-variable 'org-babel-tangled-file t)
>> |     (add-file-local-variable 'buffer-read-only t)
>> |     (add-file-local-variable 'eval: '(auto-revert-mode))
>> |     (basic-save-buffer)))
>> | 
>> | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
>> | #+end_src
>> `----
>>
>> The question is now why is this function org-babel-mark-file-as-tangled
>> receives NULL as a buffer-file-name? 
>
> I'm not sure, but perhaps you could wrap the body of buffer-file-name in
> a (when (buffer-file-name) ...) form to protect against null files.

Sounds reasonable and I'll put it in to have properly tangled files when
this happens - but then the file-local-variables would not be added if
the file name is null. Is there any way that I could find out why this
is happening (or under which conditions)?

Thanks,

Rainer

>
> Hope this helps,
>
>> 
>> I can't remove the "when" as I am also tangling some files which do
>> not have any comment characters (DESCRIPTION file in R packages).
>>
>> Any suggestions welcome,
>>
>> Rainer
>>
>>
>> Rainer M Krug <Rainer@krugs.de> writes:
>>
>>> Forgot: tried with 8.2 stable release and with version from git - both
>>> the same.
>>>
>>> Rainer M Krug <Rainer@krugs.de> writes:
>>>
>>>> Hi
>>>>
>>>> I have a strange error when tangling.
[snip:  Now irrlevant stuff (156 lines)]

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BABEL] BUG - error on tangling - disappears when changing the filename
  2013-09-30  7:30       ` Rainer M Krug
@ 2013-10-01  0:10         ` Eric Schulte
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2013-10-01  0:10 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode

>>>
>>> The question is now why is this function org-babel-mark-file-as-tangled
>>> receives NULL as a buffer-file-name? 
>>
>> I'm not sure, but perhaps you could wrap the body of buffer-file-name in
>> a (when (buffer-file-name) ...) form to protect against null files.
>
> Sounds reasonable and I'll put it in to have properly tangled files when
> this happens - but then the file-local-variables would not be added if
> the file name is null. Is there any way that I could find out why this
> is happening (or under which conditions)?
>

I'm not sure why this is happening.  You could use edebug to step
through the tangling process by edebugging the `org-babel-tangle'
function with (C-u C-M-x) i.e., (eval-defun 'edebug-it).

Cheers,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-01  0:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 12:23 [BABEL] BUG - error on tangling - disappears when changing the filename Rainer M Krug
2013-09-27 13:30 ` Rainer M Krug
2013-09-27 13:44   ` Rainer M Krug
2013-09-28 12:22     ` Eric Schulte
2013-09-30  7:30       ` Rainer M Krug
2013-10-01  0:10         ` Eric Schulte

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).