@@ -45,7 +45,7 @@ results block ? By default we display it as separate popup."
45
45
When passing a toolchain to a block as argument, this variable won't be
46
46
considered."
47
47
:type '(choice (string :tag " String" )
48
- (const :tag " Nil" nil ))
48
+ (const :tag " Nil" nil ))
49
49
:group 'rustic-babel )
50
50
51
51
(defvar rustic-babel-buffer-name '((:default . " *rust-babel*" )))
@@ -146,17 +146,17 @@ execution with rustfmt."
146
146
(rustic-babel-build-update-result-block result))
147
147
(rustic-with-spinner rustic-babel-spinner nil nil )
148
148
(if rustic-babel-display-error-popup
149
- (if (= (length (with-current-buffer proc-buffer (buffer-string ))) 0 )
150
- (kill-buffer proc-buffer)
151
- (pop-to-buffer proc-buffer))
149
+ (if (= (length (with-current-buffer proc-buffer (buffer-string ))) 0 )
150
+ (kill-buffer proc-buffer)
151
+ (pop-to-buffer proc-buffer))
152
152
(if (> (length (with-current-buffer proc-buffer (buffer-string ))) 0 )
153
153
(progn
154
154
(with-current-buffer proc-buffer
155
- (save-excursion
156
- (save-match-data
157
- (goto-char (point-min ))
158
- (setq result (buffer-string ))
159
- (rustic-babel-run-update-result-block result))))
155
+ (save-excursion
156
+ (save-match-data
157
+ (goto-char (point-min ))
158
+ (setq result (buffer-string ))
159
+ (rustic-babel-run-update-result-block result))))
160
160
(kill-buffer proc-buffer))
161
161
(kill-buffer proc-buffer)))))))
162
162
@@ -342,9 +342,20 @@ executed with the parameter `:include'."
342
342
(defun rustic-babel-block-contents (block-name )
343
343
" Return contents of block with the name BLOCK-NAME"
344
344
(with-current-buffer (current-buffer )
345
- (save-excursion
346
- (org-babel-goto-named-src-block block-name)
347
- (org-element-property :value (org-element-at-point )))))
345
+ (cond
346
+ ; ; Block exists in current file
347
+ ((org-babel-find-named-block block-name)
348
+ (save-excursion
349
+ (org-babel-goto-named-src-block block-name)
350
+ (org-element-property :value (org-element-at-point ))))
351
+ ; ; Block exists in library of babel
352
+ ; ; (see https://orgmode.org/manual/Library-of-Babel.html)
353
+ ((nth 2 (assoc-string block-name org-babel-library-of-babel)))
354
+ ; ; Fallback
355
+ (t
356
+ (progn
357
+ (message " included source code block `%s' not found in this buffer or the library of babel " block-name)
358
+ nil )))))
348
359
349
360
(defun rustic-babel-insert-mod (mods )
350
361
" Build string with module declarations for MODS and return it."
0 commit comments