UP | HOME

Quine for emacs org-mode: a source block that evaluates to itself

The following source block will evaluate to itself using C-c C-c. I'm assuming that org-confirm-babel-evaluate has been set to nil.

#+RESULTS:
#+BEGIN_SRC emacs-lisp :results output raw
(let ((print-escape-newlines t) (s "#+BEGIN_SRC emacs-lisp :results output raw\n(let ((print-escape-newlines t) (s %S)) (princ (format s s)))\n#+END_SRC")) (princ (format s s)))
#+END_SRC

Update: even better, you can set org-confirm-babel-evaluate in the header.

#+RESULTS:
#+BEGIN_SRC emacs-lisp :var d=(setq org-confirm-babel-evaluate nil) :results output raw
(let ((print-escape-newlines t) (s "#+BEGIN_SRC emacs-lisp :var d=(setq org-confirm-babel-evaluate nil) :results output raw\n(let ((print-escape-newlines t) (s %S)) (princ (format s s)))\n#+END_SRC")) (princ (format s s)))
#+END_SRC

Author: Steven Bagley

Date: 2016-04-30 Sat