Re: [O] header argument :noweb-ref seems can't be resolved
> On Dec 18, 2017, at 9:28 AM, numbch...@gmail.com wrote: > > Hope someone can help here. > OK. I think I have it. `org-babel-params-from-properties' uses `org-babel-current-src-block' to figure out where to look for properties. And o-b-c-s-b-l is let bound in `org-babel-noweb-expand-references' to the src block location with the noweb reference, e.g. `<>'. The problem can be illustrated like so. Put this in a buffer: #+begin_src org ,* abc :PROPERTIES: :header-args: :noweb-ref abcblocks :END: ,#+name: got-abc ,#+begin_src R 1+2 ,#+end_src ,* def #+end_src execute this: #+begin_src emacs-lisp (defun show-prob (obcsbl) (let ((org-babel-current-src-block-location obcsbl)) (assq :noweb-ref (nth 2 (org-babel-get-src-block-info) #+end_src Then put point in the got-abc src block and type M-: (show-prob (point)) RET and you will see `(:noweb-ref . "abcblocks")' in the minibuffer. Now try M-: (show-prob 1000) RET and the result is `nil'. The problem can be fixed by let-binding `org-babel-current-src-block-location' to `beg-body' in `org-babel-noweb-expand-references' like this (org-babel-map-src-blocks nil (let* ((org-babel-current-src-block-location beg-body) (i (org-babel-get-src-block-info 'light))) but maybe it is better to change `org-babel-params-from-properties'. WDYT? Chuck
Re: [O] header argument :noweb-ref seems can't be resolved
You're right, I searched this function through source code and dived into them. Did not found any obvious places which might cause this issue neither. Hope someone can help here. [stardiviner] GPG key ID: 47C32433 IRC(freeenode): stardiviner Twitter: @numbchild Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 Blog: http://stardiviner.github.io/ On Tue, Dec 19, 2017 at 12:46 AM, Berry, Charleswrote: > > > > On Dec 17, 2017, at 8:28 PM, stardiviner wrote: > > > > I can't find `org-babel-noweb-ref-resolve` in any of org-mode `master` > branch source code. > > > Sorry. I was off my medication when I wrote that. I suffer from CDD > (Caffeine Deficit Disorder). Now I am back on my meds and can say that I > should have typed: > > (org-babel-expand-noweb-references info) > > Is there an emoji for chagrin? > > Chuck >
Re: [O] header argument :noweb-ref seems can't be resolved
> On Dec 17, 2017, at 8:28 PM, stardivinerwrote: > > I can't find `org-babel-noweb-ref-resolve` in any of org-mode `master` branch > source code. Sorry. I was off my medication when I wrote that. I suffer from CDD (Caffeine Deficit Disorder). Now I am back on my meds and can say that I should have typed: (org-babel-expand-noweb-references info) Is there an emoji for chagrin? Chuck
Re: [O] header argument :noweb-ref seems can't be resolved
I can't find `org-babel-noweb-ref-resolve` in any of org-mode `master` branch source code. I use `counsel-git-grep` searched through the repository. Not found. Can you point out where is it? On 12/18/2017 12:12 PM, Berry, Charles wrote: On Dec 17, 2017, at 6:08 PM, stardivinerwrote: The example I original copied from is Emacs org-mode info. So I rewrite a hand typing content again: ```org * Test #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh <> #+end_src ** the mount point of the fullest disk :PROPERTIES: :header-args: :noweb-ref fullest-disk :END: *** query all mount disks #+begin_src shell df \ #+end_src *** strip the header row #+begin_src shell | sed '1d' \ #+end_src *** output mount point of fullest disk #+begin_src shell | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' #+end_src ``` I can preview the first src block with [C-c C-v v] now. It is correct: ```shell df \ | sed '1d' \ | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' ``` I can tangle it with [C-c C-v t] to same file name shell script `babel-noweb-ref.sh`. But just can't run [C-c C-v e] or [C-c C-]. (Reports same error) Seems org-mode can find correct noweb-ref for tangle but can't for eval. Nor can I. After a good while, I cannot figure how this works in tangle, but not execute. The calls to `org-babel-noweb-ref-resolve' look the same, but in tangle it returns the :noweb-ref src blocks while in execute "" is returned. FWIW, labelling the individual src-blocks with the :noweb-ref header seems to work. Chuck
Re: [O] header argument :noweb-ref seems can't be resolved
> On Dec 17, 2017, at 6:08 PM, stardivinerwrote: > > The example I original copied from is Emacs org-mode info. > So I rewrite a hand typing content again: > ```org > * Test > > #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh > <> > #+end_src > > ** the mount point of the fullest disk > :PROPERTIES: > :header-args: :noweb-ref fullest-disk > :END: > > *** query all mount disks > > #+begin_src shell > df \ > #+end_src > > *** strip the header row > > #+begin_src shell > | sed '1d' \ > #+end_src > > *** output mount point of fullest disk > > #+begin_src shell > | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' > #+end_src > ``` > > I can preview the first src block with [C-c C-v v] now. It is correct: > ```shell > df \ > | sed '1d' \ > | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' > ``` > I can tangle it with [C-c C-v t] to same file name shell script > `babel-noweb-ref.sh`. > > But just can't run [C-c C-v e] or [C-c C-]. (Reports same error) > Seems org-mode can find correct noweb-ref for tangle but can't for eval. Nor can I. After a good while, I cannot figure how this works in tangle, but not execute. The calls to `org-babel-noweb-ref-resolve' look the same, but in tangle it returns the :noweb-ref src blocks while in execute "" is returned. FWIW, labelling the individual src-blocks with the :noweb-ref header seems to work. Chuck
Re: [O] header argument :noweb-ref seems can't be resolved
The example I original copied from is Emacs org-mode info. So I rewrite a hand typing content again: ```org * Test #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh <> #+end_src ** the mount point of the fullest disk :PROPERTIES: :header-args: :noweb-ref fullest-disk :END: *** query all mount disks #+begin_src shell df \ #+end_src *** strip the header row #+begin_src shell | sed '1d' \ #+end_src *** output mount point of fullest disk #+begin_src shell | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' #+end_src ``` I can preview the first src block with [C-c C-v v] now. It is correct: ```shell df \ | sed '1d' \ | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' ``` I can tangle it with [C-c C-v t] to same file name shell script `babel-noweb-ref.sh`. But just can't run [C-c C-v e] or [C-c C-]. (Reports same error) Seems org-mode can find correct noweb-ref for tangle but can't for eval. On 12/18/2017 01:40 AM, Berry, Charles wrote: On Dec 17, 2017, at 6:58 AM, stardivinerwrote: I have the following org-mode file content: ```org #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh <> #+end_src ** the mount point of the fullest disk :PROPERTIES: :header-args: :noweb-ref fullest-disk :END: *** query all mounted disks When I copied your ECM to a fresh org-buffer and typed `C-c C-v v' with point in the above src block I got an org babel preview buffer with nothing. Looking closely, I saw a character that was not visible in the gnus buffer from which I copied. Before the: PROPERITES: lines you have 32 160 32. 160 renders as a light brown underscore when I eval `(char-to-string 160)' on my MacPro, emacs 25.2.1. 32 is blank. Converting all three to blank. and Running `C-c C-v v' gives the contents of the src blocks under the noweb-ref headline. HTH, Chuck
Re: [O] header argument :noweb-ref seems can't be resolved
> On Dec 17, 2017, at 6:58 AM, stardivinerwrote: > > I have the following org-mode file content: > > ```org > > #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh > <> > #+end_src > > ** the mount point of the fullest disk > :PROPERTIES: > :header-args: :noweb-ref fullest-disk > :END: > > *** query all mounted disks When I copied your ECM to a fresh org-buffer and typed `C-c C-v v' with point in the above src block I got an org babel preview buffer with nothing. Looking closely, I saw a character that was not visible in the gnus buffer from which I copied. Before the: PROPERITES: lines you have 32 160 32. 160 renders as a light brown underscore when I eval `(char-to-string 160)' on my MacPro, emacs 25.2.1. 32 is blank. Converting all three to blank. and Running `C-c C-v v' gives the contents of the src blocks under the noweb-ref headline. HTH, Chuck
[O] header argument :noweb-ref seems can't be resolved
I have the following org-mode file content: ```org #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh <> #+end_src ** the mount point of the fullest disk :PROPERTIES: :header-args: :noweb-ref fullest-disk :END: *** query all mounted disks #+begin_src shell df \ #+end_src *** strip the header row #+begin_src shell | sed '1d' \ #+end_src *** output mount point of fullest disk #+begin_src shell | awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}' #+end_src ``` When I press [C-c C-c] on first src block: ```org #+begin_src shell :tangle yes :noweb yes :shebang #!/bin/sh <> #+end_src ``` Emacs reports error: ``` Debugger entered--Lisp error: (error "<> could not be resolved (see ‘org-babel-noweb-error-langs’)") signal(error ("<> could not be resolved (see ‘org-babel-noweb-error-langs’)")) error("%s could not be resolved (see `org-babel-noweb-error-langs')" "<>") (if (or org-babel-noweb-error-all-langs (member lang org-babel-noweb-error-langs)) (error "%s could not be resolved (see `org-babel-noweb-error-langs')" (org-babel-noweb-wrap source-name)) "") (or (nth 2 (assoc (intern source-name) org-babel-library-of-babel)) (save-excursion (if (org-babel-ref-goto-headline-id source-name) (progn (org-babel-ref-headline-body (save-excursion (goto-char (point-min)) (let* ((name-regexp (org-babel-named-src-block-regexp-for-name source-name)) (comment (string= "noweb" (cdr (assq :comments (nth 2 info) (c-wrap (function (lambda (s) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (funcall (intern (concat lang "-mode"))) (comment-region (point) (progn (insert s) (point))) (org-trim (buffer-string))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer (expand-body (function (lambda (i) (let ((b (org-babel-expand-noweb-references i))) (if (not comment) b (let ((cs (org-babel-tangle-comment-links i))) (concat (funcall c-wrap (car cs)) "\n" b "\n" (funcall c-wrap (car (cdr cs))) (if (re-search-forward name-regexp nil t) (funcall expand-body (org-babel-get-src-block-info 'light)) (let ((expansion nil)) (let* ((case-fold-search t) (file nil) (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 (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 ((i (org-babel-get-src-block-info 'light))) (if (equal source-name (cdr (assq :noweb-ref (nth 2 i (progn (let ((sep (or (cdr (assq :noweb-sep (nth 2 i))) "\n"))) (setq expansion (cons sep (cons (funcall expand-body i) expansion))) (goto-char end-block)) (set-window-configuration wconfig))) (if visited-p nil (kill-buffer to-be-removed)) (goto-char point)) (and expansion (mapconcat (function identity) (nreverse (cdr expansion)) #1="")) (if (or org-babel-noweb-error-all-langs (member lang org-babel-noweb-error-langs)) (error "%s could not be resolved (see `org-babel-noweb-error-langs')" (org-babel-noweb-wrap source-name)) #1#)) (if evaluate (let ((raw (org-babel-ref-resolve source-name))) (if (stringp raw) raw (format "%S" raw))) (or (nth 2 (assoc (intern source-name) org-babel-library-of-babel)) (save-excursion (if (org-babel-ref-goto-headline-id source-name) (progn (org-babel-ref-headline-body (save-excursion (goto-char (point-min)) (let* ((name-regexp (org-babel-named-src-block-regexp-for-name source-name)) (comment (string= "noweb" (cdr (assq :comments (nth 2 info) (c-wrap (function (lambda (s) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (funcall (intern (concat lang "-mode"))) (comment-region (point) (progn (insert s) (point))) (org-trim (buffer-string))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer (expand-body (function (lambda (i) (let ((b (org-babel-expand-noweb-references i))) (if (not comment) b (let ((cs (org-babel-tangle-comment-links i))) (concat (funcall c-wrap (car cs)) "\n" b "\n" (funcall c-wrap (car (cdr cs))) (if (re-search-forward