9

You can output formatted org tables by returning a list of lists as follows (notice no :results output): #+begin_src python :results replace table return (('a', 'a'), None, ('bbbbb', 'bbbbb')) #+end_src #+RESULTS: | a | a | |-------+-------| | bbbbb | bbbbb | a None row creates a separator line. Here are some other examples using :results output #+...


7

With just a few keystrokes, it is possible to insert empty structural blocks, such as ‘#+BEGIN_SRC’ … ‘#+END_SRC’, or to wrap existing text in such a block. C-c C-, (org-insert-structure-template) Documentation


7

Rephrasing and shortening, I guess the question is roughly: "how to obtain stderr output without changing the source block content?" By skimming the comments section of the John Kitchin's post, adding #+PROPERTY: header-args:sh :prologue "exec 2>&1" :epilogue ":" globally, at the top of the file, should do the job (it ...


6

I think you are actually looking for publishing of projects. This does not only work for HTML but also for LaTeX. Projects are managed in org-publish-project-alist. Each entry of that list is one project. There you specify things like project path, publishing path, whether to create latex files that can be translated separately or body only files that can ...


5

Looks like a bug as wasamasa said, but until that gets fixed this works for me: (setq org-babel-js-function-wrapper "console.log(require('util').inspect(function(){\n%s\n}(), { depth: 100 }))") If you want to print deeper or otherwise modify output, change the options for require('util').inspect(...) in that string, as documented here. If you want ...


5

Use TRAMP multi-hop syntax for :dir header. 4.4 Combining ssh or plink with su or sudo If the su or sudo option shall be performed on another host, it could be comnbined with a leading ssh or plink option. That means, TRAMP connects first to the other host with non-administrative credentials, and changes to administrative credentials on that host ...


4

TL;DR: Using a persistent library of babel stored in one file can be a simple 3-step setup: Create an org-mode file ~/.emacs.d/library-of-babel.org. Add a line (org-babel-lob-ingest "~/.emacs.d/library-of-babel.org") to your Emacs conf. Collect useful functions in that file, they will be read during emacs startup. The Library-Of-Babel-file is where e.g. ...


4

Set the state of a header to COMMENT: ** COMMENT This will not be tangled #+BEGIN_SRC elisp (foo) #+END_SRC C-c ; runs the command org-toggle-comment.


4

Hot diggity darn, but minutes later I discovered a crate for that. For future people landing on this question, all I had to do was run cargo install cargo-script and bam you'll be off and org-babel-ing. If you've got Cargo.el installed in your profile, you can evaluate pretty quick using Cargo-run. This may become how I write Rust going forward, if I can ...


4

The org-babel-min-lines-for-block-output variable will help you accomplish this. I've set the following in my configuration files in order to make #+RESULTS code blocks be always enclosed within #+begin_example blocks (setq org-babel-min-lines-for-block-output 0) Here's an example #+begin_src cpp #include <iostream> int main() { std::cout <<...


4

You need to define org-babel-execute:nim: (defun org-babel-execute:nim (body params) "Execute a block of Nim code with org-babel." While we could use nim via STDIN, it will clutter the current working directory. Therefore, let us use a temporary file instead. nim also needs files to start with a letter and end with .nim, so we adjust the ...


3

You can use RESULTS for the first session to write out the results, and :var in the second session to import results. #+name: make_temporary_directories #+begin_src bash :session *one* :results output _gpg_tmpdir="$( mktemp -d )" echo $_gpg_tmpdir #+end_src #+RESULTS: make_temporary_directories : /tmp/tmp.iAE5oSlwcC #+name: clean_temporary_directories #+...


3

You need to enable evaluation of js code. Section 14.7 of org manual states: By default, only 'emacs-lisp' is enabled for evaluation. To enable or disable other languages, customize the `org-babel-load-languages' variable either through the Emacs customization interface, or by adding code to the init file as shown next: In this example, ...


3

That is one of the main pillars of babel. Give the C source block a name if you want to use in the variable assignments of another source block. You input the result of the C source block to another source block by the :var header argument. The python source blocks are described at https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html. ...


3

This issue is related to recent changes in org-mode (i.e. org 9.3). In the latest change log they mentioned that: :file header argument no longer assume "file" :results The "file" :results value is now mandatory for a code block returning a link to a file. The :file or :file-ext header arguments no longer imply a "file" result is expected. So, one ...


3

I am afraid that moving files manually will mess up my system, confuse my package manager and only work until the next update. Instead, you can simply added the true path for ditaa.jar to your .emacs or .emacs.d/init.el. In my case: (setq org-ditaa-jar-path "/usr/share/ditaa/lib/ditaa.jar")


3

yes-or-no-p is hard-coded into org-babel-confirm-evaluate. We override it with y-or-n-p locally for org-babel-confirm-evaluate: (eval-when-compile (require 'cl-lib)) (defun org+-substitute-yes-or-no-p (fun &rest args) "Run FUN with ARGS and `yes-or-no-p' locally substituted by `y-or-n-p'." (cl-letf (((symbol-function 'yes-or-no-p) #'y-or-n-p)) ...


3

C-c C-c has the key-binding org-ctrl-c-ctrl-c which runs org-babel-exec-src-block if point is inside a source block. C-x C-e runs eval-last-sexp which has nothing to do with Orgmode. org-babel-execute-src-block uses org-babel-insert-result for inserting the result into the Org buffer. There, org-no-properties removes the text properties from the result ...


3

You can use org-babel-ref-resolve to call named code blocks from one of the hooks before-save-hook or after-save-hook. Example Orgmode-file: #+NAME: myblock #+BEGIN_SRC emacs-lisp (message "Running myblock.") #+END_SRC Local Variables: eval: (add-hook 'before-save-hook (lambda () (org-babel-ref-resolve "myblock")) nil t) End:


3

Editorial comment: Session handling (at least with python) is very much a hack: there are markers inserted to signal where the current output ends, the code has to wait to make sure that all the output has been... ahem ... output, any errors that creep through somehow may be reported as part of the output, etc. That said, you might want to try the following ...


3

The example you pointed to (as you probably already know) require a certain amount of configuration, and also require understanding of certain concept in order to figure out what is going on. I'm going to execute a trivial shell code block in an emacs after ensuring that I am not relying on any of my personal emacs configuration Concepts: Skip emacs ...


3

#+PROPERTY: header-args:conf :tangle-mode (identity #o444) Sets the files as read-only (not just for emacs, but for any editor). Then, each block can be: #+BEGIN_SRC conf :tangle ~/.file_rc #+END_SRC Repeat for bash and other specific languages if you want them in BEGIN_SRC bash blocks rather than conf blocks. Tested on Org mode version 9.3.7 (9.3.7-18-...


3

I found the answer: #+begin_src bsh.dash :results verbatim :exports both :wrap "example" echo | time possiblycat 1000 #+end_src #+RESULTS: #+begin_example possiblycat 1000 0.00s user 0.00s system 68% cpu 0.005 total; max RSS 1888 #+end_example


3

Change :results file to :results file graphics.


3

You have to add parentheses after the name of the function in order for the function to be called: #+CALL: named_function_1() #+CALL: named_function_2() See the manual.


3

Turn on the header :lexical, e.g., #+begin_src elisp :lexical t :results pp (lambda ()) #+end_src #+RESULTS: : (closure : (t) : nil) You can also use #+PROPERTY: header-args:elisp :lexical t to turn it on for the whole org file. Or change org-babel-default-header-args:emacs-lisp to turn it on globally. (setq lexical-binding t) in the code does not work ...


2

Overview This answer uses Emacs Org Mode with its noweb syntax and tangling to generate this answer. Included below is the original Org mode file text to use as a starting point. This answer was tangled using Emacs version 26.3 and Org Mode version 9.3.6. Define the org-in-tangle-dir Elisp function Define the following function in your init.el file1 so ...


2

If you want to configure it in .org format instead of Lisp, so that you can keep your property declarations the between files as in a specific file, then you can use the #+SETUPFILE setting: The setup file or a URL pointing to such file is for additional in-buffer settings. Org loads this file and parses it for any settings in it only when Org opens the ...


2

I suddenly come up with string concat idea. Here is the very simple solution. #+begin_src sh :dir (concat "/sudo::" (expand-file-name "data/code")) pwd #+end_src #+RESULTS[(2020-07-20 10:34:50) b20fc4ca99ae523b3497adaa26b8945c57b06254]: : /home/stardiviner/Org/Wiki/Computer Technology/Programming/Emacs/Data/Emacs Packages/Org Mode/data/...


2

Those Control-M characters (^M) are no doubt end-of-line chars used by your OS - probably MS Windows. (Please provide your OS/platform in the question. And if it's Windows then state how you are using OS command ls - e.g., Cygwin, ls-lisp.el, or something else.) You can control this ^M display using the buffer coding for line endings. Something like this ...


Only top voted, non community-wiki answers of a minimum length are eligible