New answers tagged

1

SOLUTION: (defun kill-src-block-at-point () (interactive) (kill-new (plist-get (cadr (org-element-at-point)) :value)) )


1

You can get the body of the code block as a string by executing the following with point in the source block: (plist-get (cadr (org-element-at-point)) :value) You can also expand the body of a source block with C-c C-v C-v (bound to org-babel-expand-src-block) which creates a preview buffer with not only the source code but also the surrounding context (e.g....


1

You need to arrange that gcc is called with the flag -I . that tells the preprocessor to look in the current directory (as well as the default directories). You can do that with #+begin_src C :exports both :flags -I . #include "my_header.h" int main(void) { function_from_my_header(); return 0; } #+end_src Why that is needed and why you ...


2

This is not beautiful, but may work well enough for you. (defun set-frame-title () (setq frame-title-format (if (org-in-src-block-p) (format "%s - %s" (buffer-file-name) (org-element-property :language (org-element-context))) (buffer-file-name)))) (add-hook 'post-command-hook 'set-frame-title) if performance is not good, you ...


0

I usually use #+begin_shell :results drawer which wraps the results in a drawer. You can also use :results raw but that has some disadvantages: Org mode does not know where the results end, so you cannot delete them with org-babel-remove-result. You can also use a different wrapper, e.g. #+begin_shell :results drawer :wrap example will wrap the results in a #...


1

I was able to generate a PNG image of TikZ with the following minimal reproducible example. In the GIF shown below, you can see that I execute emacs by using the -Q flag and by loading Lisp code present in the main.el file. The image is generated from the file main.org without any problem. The following code block shows the content of the main.org file #+...


1

I use #+constants: variable=value for this and then (org-table-get-constant "variable") to get the value for src blocks etc. The advantage is that constants can be used directly in tables with $variable.


Top 50 recent answers are included