emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] org-babel-tangle may fail due to (org-babel-tangle-collect-blo


From: Andrea
Subject: Re: [BUG] org-babel-tangle may fail due to (org-babel-tangle-collect-blocks lang-re tangle-file) [9.6.9 ( @ /home/andrea/.emacs.d/elpa/org-9.6.9/)]
Date: Thu, 12 Oct 2023 15:16:58 +0100
User-agent: mu4e 1.6.10; emacs 28.1

Thanks Ihor for the super quick response!

On Thu 12 Oct 2023 at 13:04, Ihor Radchenko <yantar92@posteo.net> wrote:

> Andrea <andrea-dev@hotmail.com> writes:
>
>> ....
>> Sometimes I get an error on org-babel-load-file saying that
>> org-babel-tangle-collect-blocks was called with target-file set to nil.
>
> May it be possible to provide more details about the error you are
> seeing? You can set `debug-on-error' to t and post the backtrace, which
> will give more details. Or, better, provide a reproducer. See
> https://orgmode.org/manual/Feedback.html#Feedback
>

This is the full trace I get running "emacs --debug-init" (sorry I should have 
added it in my bug report):

   Debugger entered--Lisp error: (wrong-type-argument stringp nil)
     string-match("\\`\\(?:e\\(?:\\(?:macs-\\)?lisp\\)\\)\\'" nil nil)
     string-match-p("\\`\\(?:e\\(?:\\(?:macs-\\)?lisp\\)\\)\\'" nil)
     (not (string-match-p lang-re src-lang))
     (and lang-re (not (string-match-p lang-re src-lang)))
     (or (string= src-tfile "no") (and tangle-file (not (equal tangle-file 
src-tfile))) (and lang-re (not (string-match-p lang-re src-lang))))
     (if (or (string= src-tfile "no") (and tangle-file (not (equal tangle-file 
src-tfile))) (and lang-re (not (string-match-p lang-re src-lang)))) nil (let* 
((block (org-babel-tangle-single-block counter)) (src-tfile (cdr (assq :tangle 
(nth 4 block)))) (file-name (org-babel-effective-tangled-filename (nth 1 block) 
src-lang src-tfile)) (by-fn (assoc file-name blocks))) (if by-fn (setcdr by-fn 
(cons (cons src-lang block) (cdr by-fn))) (setq blocks (cons (cons file-name 
(list (cons src-lang block))) blocks)))))
     (let* ((info (org-babel-get-src-block-info 'no-eval)) (src-lang (nth 0 
info)) (src-tfile (cdr (assq :tangle (nth 2 info))))) (if (or (string= 
src-tfile "no") (and tangle-file (not (equal tangle-file src-tfile))) (and 
lang-re (not (string-match-p lang-re src-lang)))) nil (let* ((block 
(org-babel-tangle-single-block counter)) (src-tfile (cdr (assq :tangle (nth 4 
block)))) (file-name (org-babel-effective-tangled-filename (nth 1 block) 
src-lang src-tfile)) (by-fn (assoc file-name blocks))) (if by-fn (setcdr by-fn 
(cons (cons src-lang block) (cdr by-fn))) (setq blocks (cons (cons file-name 
(list ...)) blocks))))))
     (if (or (org-in-commented-heading-p) (org-in-archived-heading-p)) nil 
(let* ((info (org-babel-get-src-block-info 'no-eval)) (src-lang (nth 0 info)) 
(src-tfile (cdr (assq :tangle (nth 2 info))))) (if (or (string= src-tfile "no") 
(and tangle-file (not (equal tangle-file src-tfile))) (and lang-re (not 
(string-match-p lang-re src-lang)))) nil (let* ((block 
(org-babel-tangle-single-block counter)) (src-tfile (cdr (assq :tangle ...))) 
(file-name (org-babel-effective-tangled-filename (nth 1 block) src-lang 
src-tfile)) (by-fn (assoc file-name blocks))) (if by-fn (setcdr by-fn (cons 
(cons src-lang block) (cdr by-fn))) (setq blocks (cons (cons file-name ...) 
blocks)))))))
     (let ((full-block (match-string 0)) (beg-block (match-beginning 0)) 
(end-block (match-end 0)) (lang (match-string 2)) (beg-lang (match-beginning 
2)) (end-lang (match-end 2)) (switches (match-string 3)) (beg-switches 
(match-beginning 3)) (end-switches (match-end 3)) (header-args (match-string 
4)) (beg-header-args (match-beginning 4)) (end-header-args (match-end 4)) (body 
(match-string 5)) (beg-body (match-beginning 5)) (end-body (match-end 5))) 
(ignore full-block beg-block end-block lang beg-lang end-lang switches 
beg-switches end-switches header-args beg-header-args end-header-args body 
beg-body end-body) (let ((current-heading-pos (if (org-element--cache-active-p) 
(or (org-element-property :begin (org-element-lineage ... ... t)) 1) 
(save-excursion (save-restriction (widen) (progn ... ... ... ... ...)))))) (if 
(eq last-heading-pos current-heading-pos) (setq counter (1+ counter)) (setq 
counter 1) (setq last-heading-pos current-heading-pos))) (if (or 
(org-in-commented-heading-p) (org-in-archived-heading-p)) nil (let* ((info 
(org-babel-get-src-block-info 'no-eval)) (src-lang (nth 0 info)) (src-tfile 
(cdr (assq :tangle (nth 2 info))))) (if (or (string= src-tfile "no") (and 
tangle-file (not (equal tangle-file src-tfile))) (and lang-re (not 
(string-match-p lang-re src-lang)))) nil (let* ((block 
(org-babel-tangle-single-block counter)) (src-tfile (cdr ...)) (file-name 
(org-babel-effective-tangled-filename ... src-lang src-tfile)) (by-fn (assoc 
file-name blocks))) (if by-fn (setcdr by-fn (cons ... ...)) (setq blocks (cons 
... blocks))))))) (goto-char end-block))
     (progn (goto-char (match-beginning 0)) (let ((full-block (match-string 0)) 
(beg-block (match-beginning 0)) (end-block (match-end 0)) (lang (match-string 
2)) (beg-lang (match-beginning 2)) (end-lang (match-end 2)) (switches 
(match-string 3)) (beg-switches (match-beginning 3)) (end-switches (match-end 
3)) (header-args (match-string 4)) (beg-header-args (match-beginning 4)) 
(end-header-args (match-end 4)) (body (match-string 5)) (beg-body 
(match-beginning 5)) (end-body (match-end 5))) (ignore full-block beg-block 
end-block lang beg-lang end-lang switches beg-switches end-switches header-args 
beg-header-args end-header-args body beg-body end-body) (let 
((current-heading-pos (if (org-element--cache-active-p) (or 
(org-element-property :begin ...) 1) (save-excursion (save-restriction ... 
...))))) (if (eq last-heading-pos current-heading-pos) (setq counter (1+ 
counter)) (setq counter 1) (setq last-heading-pos current-heading-pos))) (if 
(or (org-in-commented-heading-p) (org-in-archived-heading-p)) nil (let* ((info 
(org-babel-get-src-block-info 'no-eval)) (src-lang (nth 0 info)) (src-tfile 
(cdr (assq :tangle ...)))) (if (or (string= src-tfile "no") (and tangle-file 
(not ...)) (and lang-re (not ...))) nil (let* ((block ...) (src-tfile ...) 
(file-name ...) (by-fn ...)) (if by-fn (setcdr by-fn ...) (setq blocks 
...)))))) (goto-char end-block)))
     (if (org-babel-active-location-p) (progn (goto-char (match-beginning 0)) 
(let ((full-block (match-string 0)) (beg-block (match-beginning 0)) (end-block 
(match-end 0)) (lang (match-string 2)) (beg-lang (match-beginning 2)) (end-lang 
(match-end 2)) (switches (match-string 3)) (beg-switches (match-beginning 3)) 
(end-switches (match-end 3)) (header-args (match-string 4)) (beg-header-args 
(match-beginning 4)) (end-header-args (match-end 4)) (body (match-string 5)) 
(beg-body (match-beginning 5)) (end-body (match-end 5))) (ignore full-block 
beg-block end-block lang beg-lang end-lang switches beg-switches end-switches 
header-args beg-header-args end-header-args body beg-body end-body) (let 
((current-heading-pos (if (org-element--cache-active-p) (or ... 1) 
(save-excursion ...)))) (if (eq last-heading-pos current-heading-pos) (setq 
counter (1+ counter)) (setq counter 1) (setq last-heading-pos 
current-heading-pos))) (if (or (org-in-commented-heading-p) 
(org-in-archived-heading-p)) nil (let* ((info (org-babel-get-src-block-info 
...)) (src-lang (nth 0 info)) (src-tfile (cdr ...))) (if (or (string= src-tfile 
"no") (and tangle-file ...) (and lang-re ...)) nil (let* (... ... ... ...) (if 
by-fn ... ...))))) (goto-char end-block))))
     (while (re-search-forward org-babel-src-block-regexp nil t) (if 
(org-babel-active-location-p) (progn (goto-char (match-beginning 0)) (let 
((full-block (match-string 0)) (beg-block (match-beginning 0)) (end-block 
(match-end 0)) (lang (match-string 2)) (beg-lang (match-beginning 2)) (end-lang 
(match-end 2)) (switches (match-string 3)) (beg-switches (match-beginning 3)) 
(end-switches (match-end 3)) (header-args (match-string 4)) (beg-header-args 
(match-beginning 4)) (end-header-args (match-end 4)) (body (match-string 5)) 
(beg-body (match-beginning 5)) (end-body (match-end 5))) (ignore full-block 
beg-block end-block lang beg-lang end-lang switches beg-switches end-switches 
header-args beg-header-args end-header-args body beg-body end-body) (let 
((current-heading-pos (if ... ... ...))) (if (eq last-heading-pos 
current-heading-pos) (setq counter (1+ counter)) (setq counter 1) (setq 
last-heading-pos current-heading-pos))) (if (or (org-in-commented-heading-p) 
(org-in-archived-heading-p)) nil (let* ((info ...) (src-lang ...) (src-tfile 
...)) (if (or ... ... ...) nil (let* ... ...)))) (goto-char end-block)))))
     (progn (if file (progn (find-file file))) (setq to-be-removed 
(current-buffer)) (goto-char (point-min)) (while (re-search-forward 
org-babel-src-block-regexp nil t) (if (org-babel-active-location-p) (progn 
(goto-char (match-beginning 0)) (let ((full-block (match-string 0)) (beg-block 
(match-beginning 0)) (end-block (match-end 0)) (lang (match-string 2)) 
(beg-lang (match-beginning 2)) (end-lang (match-end 2)) (switches (match-string 
3)) (beg-switches (match-beginning 3)) (end-switches (match-end 3)) 
(header-args (match-string 4)) (beg-header-args (match-beginning 4)) 
(end-header-args (match-end 4)) (body (match-string 5)) (beg-body 
(match-beginning 5)) (end-body (match-end 5))) (ignore full-block beg-block 
end-block lang beg-lang end-lang switches beg-switches end-switches header-args 
beg-header-args end-header-args body beg-body end-body) (let 
((current-heading-pos ...)) (if (eq last-heading-pos current-heading-pos) (setq 
counter ...) (setq counter 1) (setq last-heading-pos current-heading-pos))) (if 
(or (org-in-commented-heading-p) (org-in-archived-heading-p)) nil (let* (... 
... ...) (if ... nil ...))) (goto-char end-block))))))
     (unwind-protect (progn (if file (progn (find-file file))) (setq 
to-be-removed (current-buffer)) (goto-char (point-min)) (while 
(re-search-forward org-babel-src-block-regexp nil t) (if 
(org-babel-active-location-p) (progn (goto-char (match-beginning 0)) (let 
((full-block ...) (beg-block ...) (end-block ...) (lang ...) (beg-lang ...) 
(end-lang ...) (switches ...) (beg-switches ...) (end-switches ...) 
(header-args ...) (beg-header-args ...) (end-header-args ...) (body ...) 
(beg-body ...) (end-body ...)) (ignore full-block beg-block end-block lang 
beg-lang end-lang switches beg-switches end-switches header-args 
beg-header-args end-header-args body beg-body end-body) (let (...) (if ... ... 
... ...)) (if (or ... ...) nil (let* ... ...)) (goto-char end-block)))))) 
(set-window-configuration wconfig))
     (let ((wconfig (current-window-configuration))) (unwind-protect (progn (if 
file (progn (find-file file))) (setq to-be-removed (current-buffer)) (goto-char 
(point-min)) (while (re-search-forward org-babel-src-block-regexp nil t) (if 
(org-babel-active-location-p) (progn (goto-char (match-beginning 0)) (let (... 
... ... ... ... ... ... ... ... ... ... ... ... ... ...) (ignore full-block 
beg-block end-block lang beg-lang end-lang switches beg-switches end-switches 
header-args beg-header-args end-header-args body beg-body end-body) (let ... 
...) (if ... nil ...) (goto-char end-block)))))) (set-window-configuration 
wconfig)))
     (let* ((case-fold-search t) (file (buffer-file-name)) (visited-p (or (null 
file) (get-file-buffer (expand-file-name file)))) (point (point)) 
to-be-removed) (let ((wconfig (current-window-configuration))) (unwind-protect 
(progn (if file (progn (find-file file))) (setq to-be-removed (current-buffer)) 
(goto-char (point-min)) (while (re-search-forward org-babel-src-block-regexp 
nil t) (if (org-babel-active-location-p) (progn (goto-char ...) (let ... ... 
... ... ...))))) (set-window-configuration wconfig))) (if visited-p nil 
(kill-buffer to-be-removed)) (goto-char point))
     (let ((counter 0) last-heading-pos blocks) (let* ((case-fold-search t) 
(file (buffer-file-name)) (visited-p (or (null file) (get-file-buffer 
(expand-file-name file)))) (point (point)) to-be-removed) (let ((wconfig 
(current-window-configuration))) (unwind-protect (progn (if file (progn 
(find-file file))) (setq to-be-removed (current-buffer)) (goto-char 
(point-min)) (while (re-search-forward org-babel-src-block-regexp nil t) (if 
(org-babel-active-location-p) (progn ... ...)))) (set-window-configuration 
wconfig))) (if visited-p nil (kill-buffer to-be-removed)) (goto-char point)) 
(mapcar #'(lambda (b) (cons (car b) (nreverse (cdr b)))) (nreverse blocks)))
     
org-babel-tangle-collect-blocks("\\`\\(?:e\\(?:\\(?:macs-\\)?lisp\\)\\)\\'" nil)
     (if (equal arg '(4)) (org-babel-tangle-single-block 1 t) 
(org-babel-tangle-collect-blocks lang-re tangle-file))
     (mapc #'(lambda (by-fn) (let ((file-name (car by-fn))) (if file-name 
(progn (let (... ... modes make-dir she-banged lang) (let ... ...)))))) (if 
(equal arg '(4)) (org-babel-tangle-single-block 1 t) 
(org-babel-tangle-collect-blocks lang-re tangle-file)))
     (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 
'(16)) (progn (or (cdr (assq :tangle ...)) (user-error "Point is not in a 
source code block"))))) path-collector) (mapc #'(lambda (by-fn) (let 
((file-name (car by-fn))) (if file-name (progn (let ... ...))))) (if (equal arg 
'(4)) (org-babel-tangle-single-block 1 t) (org-babel-tangle-collect-blocks 
lang-re 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) (and (org-src-edit-buffer-p) 
(org-src-source-buffer)))))) (if org-babel-post-tangle-hook (progn (mapc 
#'(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)) 
path-collector))) (run-hooks 'org-babel-tangle-finished-hook) path-collector)
     (save-excursion (if (equal arg '(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"))))) (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 '(16)) (progn (or 
(cdr ...) (user-error "Point is not in a source code block"))))) 
path-collector) (mapc #'(lambda (by-fn) (let ((file-name ...)) (if file-name 
(progn ...)))) (if (equal arg '(4)) (org-babel-tangle-single-block 1 t) 
(org-babel-tangle-collect-blocks lang-re 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) (and (org-src-edit-buffer-p) (org-src-source-buffer)))))) (if 
org-babel-post-tangle-hook (progn (mapc #'(lambda (file) (let* ... ... ... ... 
... temp-result)) path-collector))) (run-hooks 'org-babel-tangle-finished-hook) 
path-collector))
     (save-restriction (save-excursion (if (equal arg '(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"))))) (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 '...) (progn (or ... ...)))) path-collector) (mapc 
#'(lambda (by-fn) (let (...) (if file-name ...))) (if (equal arg '(4)) 
(org-babel-tangle-single-block 1 t) (org-babel-tangle-collect-blocks lang-re 
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) (and ... ...))))) (if 
org-babel-post-tangle-hook (progn (mapc #'(lambda ... ...) path-collector))) 
(run-hooks 'org-babel-tangle-finished-hook) path-collector)))
     org-babel-tangle(nil "~/workspace/agenda/config.el" 
"\\`\\(?:e\\(?:\\(?:macs-\\)?lisp\\)\\)\\'")
     (mapcar #'expand-file-name (org-babel-tangle nil target-file lang-re))
     (save-restriction (widen) (mapcar #'expand-file-name (org-babel-tangle nil 
target-file lang-re)))
     (save-excursion (save-restriction (widen) (mapcar #'expand-file-name 
(org-babel-tangle nil target-file lang-re))))
     (save-current-buffer (set-buffer buffer) (save-excursion (save-restriction 
(widen) (mapcar #'expand-file-name (org-babel-tangle nil target-file 
lang-re)))))
     (prog1 (save-current-buffer (set-buffer buffer) (save-excursion 
(save-restriction (widen) (mapcar #'expand-file-name (org-babel-tangle nil 
target-file lang-re))))) (if visited nil (kill-buffer buffer)))
     (let* ((visited (find-buffer-visiting file)) (buffer (or visited 
(find-file-noselect file)))) (prog1 (save-current-buffer (set-buffer buffer) 
(save-excursion (save-restriction (widen) (mapcar #'expand-file-name 
(org-babel-tangle nil target-file lang-re))))) (if visited nil (kill-buffer 
buffer))))
     org-babel-tangle-file("~/workspace/agenda/config.org" 
"~/workspace/agenda/config.el" "\\`\\(?:e\\(?:\\(?:macs-\\)?lisp\\)\\)\\'")
     org-babel-load-file("~/workspace/agenda/config.org")
     (let ((file-name-handler-alist nil) (gc-cons-threshold 
most-positive-fixnum) (gc-cons-percentage 0.6)) (if window-system (progn 
(menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) (tooltip-mode -1))) 
(add-hook 'focus-out-hook #'garbage-collect) (setq inhibit-startup-message t) 
(setq load-prefer-newer t) (require 'package) '(("melpa-stable" . 
"https://stable.melpa.org/packages/";) ("melpa" . "https://melpa.org/packages/";) 
("gnu" . "https://elpa.gnu.org/packages/";) ("nongnu" . 
"https://elpa.nongnu.org/nongnu/";)) (package-initialize) (require 'cl-lib) (if 
(package-installed-p 'use-package) nil (package-refresh-contents) 
(package-install 'use-package)) (setq use-package-always-ensure t 
use-package-compute-statistics t) (if (package-installed-p 'org-contrib) nil 
(let* ((package--builtins 'nil) (my-packages '(org diminish)) (missing 
(remove-if 'package-installed-p my-packages))) (if missing (progn 
(package-refresh-contents) (mapc 'package-install missing)))) 
(package-refresh-contents) (package-install 'org-contrib)) (require 
'use-package) (require 'diminish) (require 'bind-key) (progn 
(use-package-ensure-elpa 'use-package-ensure-system-package '(t) 'nil) (defvar 
use-package--warning0 #'(lambda (keyword err) (let ((msg ...)) (display-warning 
'use-package msg :error)))) (condition-case err (if (not (require 
'use-package-ensure-system-package nil t)) (display-warning 'use-package 
(format "Cannot load %s" 'use-package-ensure-system-package) :error) 
(condition-case err (progn (setq system-packages-package-manager (if ... ... 
...)) (setq system-packages-use-sudo t) (defalias 
'my/check-package-not-installed-already #'...) (advice-add 
'system-packages-install :around #'my/check-package-not-installed-already) t) 
((debug error) (funcall use-package--warning0 :config err)))) ((debug error) 
(funcall use-package--warning0 :catch err)))) (progn (defvar 
use-package--warning1 #'(lambda (keyword err) (let ((msg ...)) (display-warning 
'use-package msg :error)))) (condition-case err (if (not (require 
'use-package-chords nil t)) (display-warning 'use-package (format "Cannot load 
%s" 'use-package-chords) :error) (condition-case err (progn (key-chord-mode 1) 
t) ((debug error) (funcall use-package--warning1 :config err)))) ((debug error) 
(funcall use-package--warning1 :catch err)))) (load "server") (if 
(server-running-p) nil (server-start)) (message "--- Start loading config.el") 
(setq my/init-file-time (current-time)) (org-babel-load-file 
"~/workspace/agenda/config.org") (message "--- Finish loading config.el") 
(message "Config.el took %s seconds in total" (time-to-seconds (time-subtract 
(current-time) my/init-file-time))))
     eval-buffer(#<buffer  *load*> nil "/home/andrea/.emacs.d/init.el" nil t)  
; Reading at buffer position 3454
     load-with-code-conversion("/home/andrea/.emacs.d/init.el" 
"/home/andrea/.emacs.d/init.el" t t)
     load("/home/andrea/.emacs.d/init" noerror nomessage)
     startup--load-user-init-file(#f(compiled-function () #<bytecode 
-0x8411441f899e09c>) #f(compiled-function () #<bytecode -0x1f3c686ddc0cdc35>) t)
     command-line()
     normal-top-level()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]